Pulp Linear Solver/Linear Optimization with Python -


i have been installing different linear solvers , modules python last few hours various installation , runtime errors. here's summary of i've done far:

  • i installed pulp w/ pip install pulp

although said include coin optimizer, did not turn out case. ran 1 of examples:

import pulp # create problem instance giapetto = pulp.lpproblem("giapetto's workshop", pulp.lpmaximize)  # define variables lower bounds of 0 x1 = pulp.lpvariable("soldiers",0) x2 = pulp.lpvariable("trains",0)  # add objective giapetto += 3*x1 + 2*x2, "profit"  # add constraints giapetto += 2*x1 + x2 <= 100,"finishing labor" giapetto += x1 + x2 <= 80, "carpentry labor" giapetto += x1 <= 40, "soldier demand" giapetto += x1 + x2 == 20, "minimum production"  giapetto.solve() #giapetto.solve(glpk())  print pulp.lpstatus[giapetto.status] print pulp.lpsenses[giapetto.sense], giapetto.objective.name, "=", pulp.value(giapetto.objective) 

..included in pulp's documentation, , received error:

attributeerror: 'nonetype' object has no attribute 'actualsolve'

i tried after import glpk (brew install glpk; took >30mins bc of missing gcc dependency), , got error:

nameerror: name 'glpk' not defined

however, when simulated command line in ipython, able glpk run:

%%script glpsol -m /dev/stdin -o /dev/stdout --out output  # declare problem variables var x; var y; var z;  # list equations eqn1 : 3*x + 2*y + z = 12; eqn2 : 2.1*x + y = -3; eqn3 : y - z = 4;  # solve solve;  # display results display x, y, z;  end;  print output  [out:] glpsol: glpk lp/mip solver, v4.52 parameter(s) specified in command line:  -m /dev/stdin -o /dev/stdout reading model section /dev/stdin... 18 lines read generating eqn1... generating eqn2... generating eqn3... model has been generated 

so, question twofold:

  1. how can glpk(or solver) run first code example (without use of command-line)?
  2. is there solver either more compatible python, or easier use, can use inline list below?

* solver pulp.solvers.glpk_cmd passed.  solver pulp.solvers.pulp_cbc_cmd unavailable  solver pulp.solvers.cplex_dll unavailable  solver pulp.solvers.cplex_cmd unavailable  solver pulp.solvers.cplex_py unavailable  solver pulp.solvers.coin_cmd unavailable  solver pulp.solvers.coinmp_dll unavailable  solver pulp.solvers.glpk_cmd unavailable  solver pulp.solvers.xpress unavailable  solver pulp.solvers.gurobi unavailable  solver pulp.solvers.gurobi_cmd unavailable  solver pulp.solvers.pyglpk unavailable  solver pulp.solvers.yaposib unavailable

for me using ubuntu worked perfect installing coin-or libraries repositories:

sudo apt-get install coinor-cbc coinor-clp 

keep in mind commercial solvers expensive reasons; in many cases, coin solver served me well.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -