@@ -65,27 +65,27 @@ An example that includes the modeling approach may be found below.
65
65
:skipif: not glpk_available
66
66
67
67
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
70
70
71
71
Create a simple model
72
- >>> model = ConcreteModel(name = ' LOA example' )
72
+ >>> model = pyo. ConcreteModel(name = ' LOA example' )
73
73
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 )
77
77
78
78
>>> 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 )
80
80
81
81
>>> 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 )
83
83
84
84
>>> 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)
86
86
87
87
Solve the model using GDPopt
88
- >>> results = SolverFactory(' gdpopt.loa' ).solve(
88
+ >>> results = pyo. SolverFactory(' gdpopt.loa' ).solve(
89
89
... model, mip_solver= ' glpk' ) # doctest: +IGNORE_RESULT
90
90
91
91
Display the final solution
0 commit comments