pysal / spopt

Spatial Optimization
https://pysal.org/spopt/
BSD 3-Clause "New" or "Revised" License
303 stars 46 forks source link

Unable to run through LSCP example #446

Closed Dekermanjian closed 5 months ago

Dekermanjian commented 5 months ago

I am trying to run the following example locally: https://pysal.org/spopt/notebooks/lscp_gis.html

At this point lscp = lscp.solve(solver) I get a RuntimeError: Model is not solved: Infeasible. See ``pulp.constants.LpStatus`` for more information. Can someone please try to reproduce the results of the example in the link above? I am not certain if this is a PuLP installation issue or something else?

gegen07 commented 5 months ago

Hey @Dekermanjian!

Unfortunately, I am also getting this error. The cost_matrix of durations changed, I think some update on OSM routing service increased the values, and then the model with the same service radius resulted in an infeasible model. Try to increase the service radius and solve the model.

By inspecting the folium maps, I discovered some first aid stations changed their locations. The minnimum value to turn the model infeasible is 290, since it is the minimum acceptable value for one building in university of toronto.

Dekermanjian commented 5 months ago

Hey @gegen07 thank you for the quick response. I guess I am wondering why it would be infeasible. There is no limit to the number of first aid stations that can be situated. If you situate a first aid station on every street then it should be within the constraint of walking from any building to the situated first aid station in 150 seconds (2 minutes and 30 seconds). The only solution as you said is when the radius is large enough such that all buildings can be serviced with 1 situated first aid station.

gegen07 commented 5 months ago

You are right @Dekermanjian, but there are no aid stations in 150 seconds to cover a specific building. The aid stations changed over time since the last commit on the notebook. Then, if there are no aid stations in a service radius $X$ the restriction would not be attended and the model is infeasible.

Dekermanjian commented 5 months ago

Thank you for your response @gegen07 I see, so for the solution to then become feasible I need to either: 1). Add more roads (represented as black points in the figure) or 2). Remove buildings (represented as blue points in the figure) that are outside the bounds of 150 seconds

Is there an easy way to identify which buildings are the ones that are producing an intractable equation?

Dekermanjian commented 5 months ago

@gegen07 never mind, I was able to do option 2 and it is now working again.

Dekermanjian commented 5 months ago

I added the highlighted line of code below to get it to work: image

jGaboardi commented 5 months ago

@gegen07 Shall we update the demo notebook?