Skip to content

Commit

Permalink
Pulling more data from coek results
Browse files Browse the repository at this point in the history
  • Loading branch information
whart222 committed Jun 11, 2024
1 parent 3d24041 commit ff66997
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/pyomo_coek/pyomo_coek/components_only/solvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
SolutionLoader,
Results,
Solver,
SolverFactory,
)
from pyomo.opt import SolverFactory
from munch import Munch
import poek as pk
from typing import Tuple, Dict
Expand Down Expand Up @@ -157,7 +157,9 @@ def resolve(self, timer: HierarchicalTimer = None):
res.best_feasible_objective = self._poek_nlp_model.get_objective().value
return res

def solve(self, model: _BlockData, timer: HierarchicalTimer = None) -> Results:
def solve(self, model: _BlockData, options=None, timer: HierarchicalTimer = None) -> Results:
if options is None:
options = {}
if timer is None:
timer = HierarchicalTimer()

Expand All @@ -179,10 +181,14 @@ def solve(self, model: _BlockData, timer: HierarchicalTimer = None) -> Results:
nlp = pk.nlp_model(pm, "cppad")
self._poek_nlp_model = nlp
self._set_options()
for key, option in options.items():
self._opt.set_option(key, option)
_res = self._opt.solve(nlp)
else:
self._opt = pk.solver(self._solver_name)
self._set_options()
for key, option in options.items():
self._opt.set_option(key, option)
_res = self._opt.solve(pm)
timer.stop("coek solve")

Expand All @@ -201,6 +207,7 @@ def solve(self, model: _BlockData, timer: HierarchicalTimer = None) -> Results:
res = Results()
res.solution_loader = self.solution_loader
res.termination_condition = poek2pyomo_termination_condition[_res.termination_condition]
res.message = _res.error_message
res.solution_status = poek2pyomo_solution_status[_res.solution_status]
if pk.check_optimal_termination(_res):
res.best_feasible_objective = _res.objective_value
Expand Down

0 comments on commit ff66997

Please sign in to comment.