Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # OpenOpt example, similar to gurobi example from
- # http://www.gurobi.com/doc/45/quickstart/node11.html,
- from FuncDesigner import *
- from openopt import MILP
- x, y, z = oovars('x y z', domain=bool)
- obj = x + y + 2*z
- cons = (x + 2*y + 3*z <= 4, x + y >= 1)
- startPoint = {x:0, y:0, z:0} # any
- p=MILP(obj, startPoint, constraints = cons)
- r = p.maximize('glpk', iprint=0) # other OpenOpt MILP solvers: cplex, lpSolve
- print(r.xf)
- '''
- ------------------------- OpenOpt 0.37 -------------------------
- solver: glpk problem: unnamed type: MILP goal: maximum
- iter objFunVal log10(maxResidual)
- 0 -0.000e+00 0.00
- 1 3.000e+00 -100.00
- istop: 1000 (optimal)
- Solver: Time Elapsed = 0.01 CPU Time Elapsed = 0.01
- objFunValue: 3 (feasible, MaxResidual = 0)
- {x: 1.0, y: 0.0, z: 1.0}
- '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement