Skip to content

Commit 281ff01

Browse files
committed
Finished example, ran black
1 parent c5e2109 commit 281ff01

2 files changed

Lines changed: 16 additions & 8 deletions

File tree

pyomo/contrib/multistart/multi.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def __init__(
120120
self.suppress_unbounded_warning = self.declare(
121121
"suppress_unbounded_warning",
122122
ConfigValue(
123-
default=False,
123+
default=True,
124124
domain=bool,
125125
description="True to suppress warning for skipping unbounded variables.",
126126
),
@@ -217,8 +217,8 @@ def solve(self, model, **kwds):
217217
)
218218

219219
# Set options so infeasible solve does not interrupt runs
220-
config.solver_args["load_solutions"] = False
221-
config.solver_args["raise_exception_on_nonoptimal_result"] = False
220+
# config.solver_args["load_solutions"] = False
221+
# config.solver_args["raise_exception_on_nonoptimal_result"] = False
222222

223223
solver = SolverFactory(config.solver)
224224

pyomo/devel/initialization/examples/init_polynomial_ex.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,25 @@ def global_init_ex():
5555

5656
def multistart_init_ex():
5757
m = build_model()
58+
m.obj = pyo.Objective(expr=0)
5859
nlp_solver = SolverFactory('ipopt')
59-
global_solver = SolverFactory('scip_direct')
60-
results = ini.initialize_with_global_opt(
61-
nlp=m, nlp_solver=nlp_solver, global_solver=global_solver
62-
)
60+
multistart_solver = pyo.SolverFactory('multistart')
6361

64-
return results.solution_status, m.x.value
62+
multistart_solver.CONFIG.iterations = 50
63+
64+
opts = {"load_solutions": False, "raise_exception_on_nonoptimal_result": False}
65+
multistart_solver.CONFIG.strategy = "rand"
66+
multistart_solver.CONFIG.solver_args = opts
67+
68+
results = ini.initialize_with_multistart_opt(
69+
nlp=m, nlp_solver=nlp_solver, multistart_solver=multistart_solver, seed=145
70+
)
71+
return results, m.x.value
6572

6673

6774
if __name__ == '__main__':
6875
# stat, x = lp_init_ex()
6976
# stat, x = pwl_init_ex()
7077
stat, x = global_init_ex()
78+
# stat, x = multistart_init_ex()
7179
print(stat, round(x, 4))

0 commit comments

Comments
 (0)