I am using the solver "Minimize Facilities" in the location allocation toolbox, but there is a constraint in my problem the solver doesn't allow me to add it. The constraint is for some nodes, the total demand connected to that specific node is n-1, where n is the total number of nodes or lines connected to that node from the neighbor. This is an extra constraint but I couldn't find any way to include it in my problem.
I found a python package called PuLP used for linear programming optimization. Has anyone used it before? Any other toolboxes that can be used for this problem with an option to add mathematic constraints?
Thanks in advance
Hi Natalie,
When I run the tests for pulp 1.6.8 on my windows machine that has 64 bit python 2.7.14, I don't get any such failures. So I am not sure what would be causing this error on your end. Can you try running the pulp tests from the windows command prompt instead of using an IDE like PyScripter?
Python 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:25:58) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.>>> import pulp
>>> pulp.pulpTestAll()
Testing zero subtraction
Testing inconsistant lp solution
Testing continuous LP solution
Testing maximize continuous LP solution
Testing unbounded continuous LP solution
Testing Long Names
Testing repeated Names
Testing zero constraint
Testing zero objective
Testing LpVariable (not LpAffineExpression) objective
Testing Long lines in LP
Testing LpAffineExpression divide
Testing MIP solution
Testing MIP solution with floats in objective
Testing MIP relaxation
Testing feasibility problem (no objective)
Testing an infeasible problem
Testing an integer infeasible problem
Testing column based modelling
Testing dual variables and slacks reporting
Testing fractional constraints
Testing elastic constraints (no change)
Testing elastic constraints (freebound)
Testing elastic constraints (penalty unchanged)
Testing elastic constraints (penalty unbounded)
* Solver pulp.solvers.PULP_CBC_CMD passed.
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
When I ran it as you suggested, I get the same results as you. Does that mean it is installed and ready to go? Im guessing the reason the PyScripter one failed is that the solvers are unavailable, as we saw in the Python run. It fails in the Solver section of the code.
Yes if pulpTestAll is working fine you should be good. You can also try to run some of the examples such as AmericanSteelProblem.py and see if things are working fine.
$ python AmericanSteelProblem.py
('Status:', 'Optimal')
("Route_('Chicago',_'Gary')", '=', 4000.0)
("Route_('Chicago',_'Tempe')", '=', 2000.0)
("Route_('Cincinatti',_'Albany')", '=', 2000.0)
("Route_('Cincinatti',_'Houston')", '=', 3000.0)
("Route_('Kansas_City',_'Houston')", '=', 4000.0)
("Route_('Kansas_City',_'Tempe')", '=', 2000.0)
("Route_('Pittsburgh',_'Chicago')", '=', 3000.0)
("Route_('Pittsburgh',_'Cincinatti')", '=', 2000.0)
("Route_('Pittsburgh',_'Gary')", '=', 2000.0)
("Route_('Pittsburgh',_'Kansas_City')", '=', 3000.0)
("Route_('Youngstown',_'Albany')", '=', 1000.0)
("Route_('Youngstown',_'Chicago')", '=', 3000.0)
("Route_('Youngstown',_'Cincinatti')", '=', 3000.0)
("Route_('Youngstown',_'Kansas_City')", '=', 3000.0)
('Total Cost of Transportation = ', 15005.0)
Hi Deelesh,
Thank you again for helping me to get PuLP installed. I copied the American Steel problem into PyScripter, and when I run it I get the following error:
Traceback (most recent call last):
File "<module2>", line 101, in <module>
File "C:\Python27\ArcGIS10.3\lib\site-packages\pulp\pulp.py", line 1513, in writeLP
f = open(filename, "w")
IOError: [Errno 13] Permission denied: 'AmericanSteel.lp'
Is there something simple I need to do to fix this?
Natalie
Hi Natalie,
Do you get the same error if you run the script from outside of PyScripter such as from the command line?
Thanks
Deelesh
I just ran it in Python 2.7 and it worked fine. Thanks for pointing that out.
Natalie
I don't use PyScripter as my Python IDE. So I am not sure what could be causing the issue. One thing you might want to check is if you are using the correct Python interpreter from within Pyscripter. i.e. PyScripter might be somehow loading the 64 bit version of Python (in case you have both 32 bit and 64 bit versions of Python interpreters installed on your machine).
Hi Deelesh,
I was able to solve the problem. It had to do with where I was saving the python script. Thanks for all your help and being so responsive. I greatly appreciate it.