Advertisement
Dmitrey15

Untitled

Feb 17th, 2012
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.82 KB | None | 0 0
  1. # OpenOpt example, similar to gurobi example from
  2. # http://www.gurobi.com/doc/45/quickstart/node11.html,
  3.  
  4. from FuncDesigner import *
  5. from openopt import MILP
  6. x, y, z = oovars('x y z', domain=bool)
  7. obj = x + y + 2*z
  8. cons = (x + 2*y + 3*z <= 4, x + y >= 1)
  9. startPoint = {x:0, y:0, z:0} # any
  10. p=MILP(obj, startPoint, constraints = cons)
  11. r = p.maximize('glpk', iprint=0) # other OpenOpt MILP solvers: cplex, lpSolve
  12. print(r.xf)
  13. '''
  14. ------------------------- OpenOpt 0.37 -------------------------
  15. solver: glpk   problem: unnamed    type: MILP   goal: maximum
  16. iter   objFunVal   log10(maxResidual)  
  17.    0  -0.000e+00               0.00
  18.    1  3.000e+00            -100.00
  19. istop: 1000 (optimal)
  20. Solver:   Time Elapsed = 0.01   CPU Time Elapsed = 0.01
  21. objFunValue: 3 (feasible, MaxResidual = 0)
  22. {x: 1.0, y: 0.0, z: 1.0}
  23. '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement