Skip to content

Commit

Permalink
Merge pull request #3 from MetExplore/development
Browse files Browse the repository at this point in the history
Prepare for 0.9.0-alpha.3
  • Loading branch information
pablormier authored Aug 5, 2021
2 parents 3b2c47e + f931e6d commit aa185ce
Show file tree
Hide file tree
Showing 4 changed files with 929 additions and 7 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/deploy-mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Install dependencies
run: |
Expand All @@ -24,6 +26,4 @@ jobs:
python-version: '3.7'

- name: Deploy with MkDocs
run: |
git pull
mkdocs gh-deploy
run: mkdocs gh-deploy
4 changes: 2 additions & 2 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ name: Unit tests

on:
push:
branches: [ main ]
branches: [ main, development ]
pull_request:
branches: [ main ]
branches: [ main, development ]

jobs:
build:
Expand Down
23 changes: 21 additions & 2 deletions miom/miom.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def wrapper(self, *args, **kwargs):
# Find subclass implementation
fname = '_' + fn.__name__
if not hasattr(self, fname):
raise ValueError(f'Method "{fn.__name__}()" is marked as @fluent '
raise ValueError(f'Method "{fn.__name__}()" is marked as @_autochain '
f'but the expected implementation "{fname}()" was not provided '
f'by {self.__class__.__name__}')
func = getattr(self, fname)
Expand Down Expand Up @@ -336,6 +336,10 @@ def __init__(self, previous_step_model=None, miom_network=None, solver_name=None
def initialize_problem(self):
pass

@abstractmethod
def get_solver_status(self):
pass

@_autochain
def setup(self, **kwargs):
"""Provide the options for the solver.
Expand Down Expand Up @@ -781,7 +785,7 @@ def _solve(self, **kwargs):
self.problem.options["timelimit"] = max_seconds
if verbosity is not None:
self.problem.options["verbosity"] = verbosity
solutions = self.problem.solve()
self.solutions = self.problem.solve()
return True

def _add_constraint(self, constraint, **kwargs):
Expand Down Expand Up @@ -812,6 +816,13 @@ def _select_subnetwork(self, **kwargs):
def _copy(self, **kwargs):
return PicosModel(previous_step_model=self)

def get_solver_status(self):
solver_status = {}
solver_status['status'] = str(self.solutions.claimedStatus)
solver_status['objective_value'] = float(self.problem.value)
solver_status['solver_time_seconds'] = self.solutions.searchTime
return solver_status


class PythonMipModel(BaseModel):
def __init__(self, previous_step_model=None, miom_network=None, solver_name=None):
Expand Down Expand Up @@ -841,6 +852,8 @@ def _setup(self, *args, **kwargs):
self.problem.opt_tol = self.problem.infeas_tol
self.problem.integer_tol = kwargs["int_tol"] if "int_tol" in kwargs else self._options["int_tol"]
self.problem.verbose = kwargs["verbosity"] if "verbosity" in kwargs else self._options["verbosity"]
self.problem.store_search_progress_log = True
self.problem.threads = -1
return True

def _reset(self, **kwargs):
Expand Down Expand Up @@ -933,3 +946,9 @@ def _select_subnetwork(self, **kwargs):
def _copy(self, **kwargs):
return PythonMipModel(previous_step_model=self)

def get_solver_status(self):
solver_status = {}
solver_status['status'] = str(self.problem.status.name)
solver_status['objective_value'] = float(self.problem.objective_value)
solver_status['solver_time_seconds'] = self.problem.search_progress_log.log[-1:][0][0]
return solver_status
Loading

0 comments on commit aa185ce

Please sign in to comment.