Linear programming (PuLP) for location allocation

4701
17
11-29-2016 07:56 PM
LanoYado
New Contributor III

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

Tags (1)
0 Kudos
17 Replies
JaySandhu
Esri Regular Contributor

You can use Network Analyse with external LP solvers using PuLP. An example to do an allocation by first computing the travel cost matrix in ArcMap is here:

http://www.arcgis.com/home/item.html?id=c5ae481f25604d1bb050d9bd1d6e3c06 

Jay Sandhu

MathewSchmidtlein
New Contributor

Deelesh Mandloijsandhu-esristaff

I have used that linked resource (Allocation Tools for ArcGIS) previously (with ArcMap 10.1).  I'm trying to use it again(with 10.5), but keep getting an error: [Errno 13] Permission denied: '7476-pulp.mps'.  The error is thrown at the point where the LP model is solved (line 479, prob.solve()).  There was a similar issue posted in the comments on the page you link a year ago with no response.  Do you have any suggestions on how to address this issue?  Thanks.

0 Kudos
RachelApplebaum
Esri Contributor

Hi Mathew,

I was encountering the same issue so I emailed Deelesh. He has found that this error typically comes from using background processing to run the tool. In my own tests, I found that even if you are using foreground processing, if you have the 64bit background processing extension for ArcMap installed, it will still fail. I was able to get the tool to work by uninstalling the 64bit background processing and running the tool in the foreground.

I think that the issue is caused by the old version of pulp installed with the tool. Newer versiond of the module do support both 32 and 64bit processing, so if you update the pulp module that comes with the tool, the issue with the background processing should go away (though I have not tried that yet.).

Hope this helps!

-Rachel

0 Kudos
MathewSchmidtlein
New Contributor

Thanks, Rachel.  I had been running this in the foreground, but I do believe I have the 64bit background processing installed.  But it ran without a hitch once I installed the updated version of PuLP.

Thanks for your help!

0 Kudos
nataliemartinkus1
Occasional Contributor

Hi Rachel,

Thanks for the helpful information.  I have been trying to install PULP to run with ArcGIS 10.3 and for the life of me cannot figure out how to get it installed.  I have tried installing PIP which appears to be needed to install PULP, and can't even get PIP installed.  I am no developer, and it seems all the install instructions are written for developers.  My goal is to run optimization routines in Python that may or may not involve the use of Network Analyst.  Can you help me out since it sounds like you are past the point of installing the program?

thanks,

natalie 

0 Kudos
DeeleshMandloi
Esri Contributor

Hi Natalie,

     If you are looking to install the latest version of pulp on your machine running ArcMap 10.3, you can do the following

1. Download the get-pip.py file from https://bootstrap.pypa.io/get-pip.py and save it locally such as in c:\data folder. The details are at Installation — pip 9.0.1 documentation 

2. Open a windows command prompt  and type the following command

C:\Python27\ArcGIS10.3\python.exe c:\data\get-pip.py

3. Once pip is installed, install pulp using the following command

C:\Python27\ArcGIS10.3\Scripts\pip.exe install pulp

4. You should now be able to use pulp and arcpy in your python scripts. For example, you can run these commands after starting a python interactive session such as in  IDLE 

import arcpy

import pulp

print arcpy.GetInstallInfo()

pulp.pulpTestAll()

Hope this helps

Deelesh

nataliemartinkus1
Occasional Contributor

dmandloi-esristaff

Thank you so much for your succinct directions.  I was able to quickly get everything installed, as compared to the hours I spent before going between the PULP and PIP sites.  When I run the test you recommend, I get this error shown below in two screen shots,  the bottom one showing the final message.  Can you please provide any insights on this error?

Thanks,

natalie

0 Kudos
DeeleshMandloi
Esri Contributor

Hi Natalie,

    The RuntimeError you are encountering is because arcpy is not licensed for use on your machine. This happens when you don't have a license for ArcMap on your machine. If you don't need to use arcpy or cannot install a license for ArcGIS, you can test your pulp installation by running

import pulp

pulp.pulpTestAll()

Thanks

Deelesh

0 Kudos
nataliemartinkus1
Occasional Contributor

Hi dmandloi-esristaff,

You are right - I have to connect to a GIS license through the Cisco AnyConnect program since the GIS licenses exist on a university server. I did find that the arcpy module runs when I am connected to the license.  Thank you for that info. 

However, when I run the PULP test, I get the error below.  I sure hope you will have a quick answer to this problem as well.

thanks,

natalie 

0 Kudos