-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMINLP.py
More file actions
30 lines (21 loc) · 750 Bytes
/
MINLP.py
File metadata and controls
30 lines (21 loc) · 750 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
## MINLP: PYOMO (COUENNE)
import pyomo.environ as pyo
from pyomo.environ import *
from pyomo.opt import SolverFactory
model = pyo.ConcreteModel()
model.x = pyo.Var(within=Integers, bounds=(0,10))
model.y = pyo.Var(bounds=(0,10))
x = model.x
y = model.y
model.C1 = pyo.Constraint(expr= -x+2*y*x<=8)
model.C2 = pyo.Constraint(expr= 2*x+y<=14)
model.C3 = pyo.Constraint(expr= 2*x-y<=10)
model.obj = pyo.Objective(expr= x+y*x, sense=maximize)
opt = SolverFactory('couenne', executable='C:\\couenne\\bin\\couenne.exe')
opt.solve(model)
model.pprint()
x_value = pyo.value(x)
y_value = pyo.value(y)
print('\n---------------------------------------------------------------------')
print('x=',x_value)
print('y=',y_value)