|
32 | 32 | from pyomo.contrib.solver.common.config import SolverConfig |
33 | 33 | from pyomo.contrib.solver.common.factory import SolverFactory |
34 | 34 | from pyomo.contrib.solver.common.results import SolutionStatus |
35 | | -from pyomo.contrib.solver.common.util import NoOptimalSolutionError, NoSolutionError, NoFeasibleSolutionError |
| 35 | +from pyomo.contrib.solver.common.util import ( |
| 36 | + NoOptimalSolutionError, |
| 37 | + NoSolutionError, |
| 38 | + NoFeasibleSolutionError, |
| 39 | +) |
36 | 40 | from pyomo.util.vars_from_expressions import get_vars_from_components |
37 | 41 |
|
38 | 42 | from pyomo.common.dependencies.scipy import stats |
@@ -198,12 +202,11 @@ def __init__(self, **kwds: Any) -> None: |
198 | 202 | #: Instance configuration; |
199 | 203 | self.config = self.config |
200 | 204 |
|
201 | | - |
202 | 205 | def available(self, exception_flag=True): |
203 | 206 | """Check if solver is available. |
204 | 207 |
|
205 | 208 | The multistart solver wrapper should always be available, |
206 | | - but it is not guaranteed the subsolvers will be. |
| 209 | + but it is not guaranteed the subsolvers will be. |
207 | 210 | Check if the selected subsolver is available, which by default is ipopt. |
208 | 211 | """ |
209 | 212 |
|
@@ -259,7 +262,7 @@ def solve(self, model, **kwds): |
259 | 262 | obj_sign = obj.sign |
260 | 263 |
|
261 | 264 | else: |
262 | | - obj_sign = 1 |
| 265 | + obj_sign = 1 |
263 | 266 |
|
264 | 267 | best_objective = float('inf') * obj_sign |
265 | 268 |
|
@@ -369,11 +372,10 @@ def solve(self, model, **kwds): |
369 | 372 | if config.raise_exception_on_nonoptimal_result and not using_HCS: |
370 | 373 | if best_result.solution_status != SolutionStatus.optimal: |
371 | 374 | raise NoOptimalSolutionError |
372 | | - |
373 | | - |
| 375 | + |
374 | 376 | # if no better result was found than initial solve, then return |
375 | 377 | # that without needing to copy variables. |
376 | | - if best_model is model: |
| 378 | + if best_model is model: |
377 | 379 | return best_result |
378 | 380 |
|
379 | 381 | # reassign the given models vars to the new models vars |
|
0 commit comments