Skip to content

Commit 4cc31df

Browse files
committed
Update GDPopt LOA documentation to use explicit pyo imports
1 parent 00ebb73 commit 4cc31df

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

doc/OnlineDocs/explanation/solvers/gdpopt.rst

+10-10
Original file line numberDiff line numberDiff line change
@@ -65,27 +65,27 @@ An example that includes the modeling approach may be found below.
6565
:skipif: not glpk_available
6666

6767
Required imports
68-
>>> from pyomo.environ import *
69-
>>> from pyomo.gdp import *
68+
>>> import pyomo.environ as pyo
69+
>>> from pyomo.gdp import Disjunct, Disjunction
7070

7171
Create a simple model
72-
>>> model = ConcreteModel(name='LOA example')
72+
>>> model = pyo.ConcreteModel(name='LOA example')
7373

74-
>>> model.x = Var(bounds=(-1.2, 2))
75-
>>> model.y = Var(bounds=(-10,10))
76-
>>> model.c = Constraint(expr= model.x + model.y == 1)
74+
>>> model.x = pyo.Var(bounds=(-1.2, 2))
75+
>>> model.y = pyo.Var(bounds=(-10,10))
76+
>>> model.c = pyo.Constraint(expr= model.x + model.y == 1)
7777

7878
>>> model.fix_x = Disjunct()
79-
>>> model.fix_x.c = Constraint(expr=model.x == 0)
79+
>>> model.fix_x.c = pyo.Constraint(expr=model.x == 0)
8080

8181
>>> model.fix_y = Disjunct()
82-
>>> model.fix_y.c = Constraint(expr=model.y == 0)
82+
>>> model.fix_y.c = pyo.Constraint(expr=model.y == 0)
8383

8484
>>> model.d = Disjunction(expr=[model.fix_x, model.fix_y])
85-
>>> model.objective = Objective(expr=model.x + 0.1*model.y, sense=minimize)
85+
>>> model.objective = pyo.Objective(expr=model.x + 0.1*model.y, sense=pyo.minimize)
8686

8787
Solve the model using GDPopt
88-
>>> results = SolverFactory('gdpopt.loa').solve(
88+
>>> results = pyo.SolverFactory('gdpopt.loa').solve(
8989
... model, mip_solver='glpk') # doctest: +IGNORE_RESULT
9090

9191
Display the final solution

0 commit comments

Comments
 (0)