-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pulp.apis.core.PulpSolverError: Pulp: cannot execute cbc.exe #347
Comments
As per the error message, the problem appears to be with your Also, please provide:
|
Thank you for the quick response! I used pip install for pulp - version 2.7.0 Spopt - version 0.5.0 Example code import spopt
from spopt.locate import PCenter
import geopandas as gpd
import shapely
from shapely import Point
import pandas as pd
import numpy as np
import pulp
import scipy
grid = pd.read_csv(r"C:\Users\x\Documents\city_spatial_analysis\station_allocation\grid_coords.csv")
grid = grid[['index', 'lon', 'lat']]
# number of candidate facilities in optimal solution
facilities = 35
# set the solver
solver = pulp.COIN_CMD(msg=True, warmStart=True)
# calculate network distance cost matrix
distances = scipy.spatial.distance.squareform(scipy.spatial.distance.pdist(grid [["lon", "lat"]]))
# replacing zeros with 50,000
distances = np.where(distances== 0, 50000, distances)
distances = np.round(distances)
pcenter_from_cm = PCenter.from_cost_matrix(
distances, p_facilities=facilities, name="p-center-network-distance"
)
pcenter_from_cm = pcenter_from_cm.solve(solver) |
For the code chunk above to run (be on the way to a MWE), you will need to provide |
My bad, here are some simulated points taken from the tutorial page for p-center. The same error occurs. I have tried uninstalling and pip installing pulp again, but the same error happens. I am not using coda. I will try using anaconda and a new env perhaps. import spopt
#from spopt.locate import MCLP, simulated_geo_points
from spopt.locate import PMedian
from spopt.locate import PCenter, simulated_geo_points
import geopandas as gpd
import shapely
from shapely import Point
#import matplotlib.pyplot as plt
#from matplotlib.patches import Patch
import pandas as pd
import numpy as np
import pulp
import scipy
import warnings
with warnings.catch_warnings():
warnings.simplefilter("ignore")
# ignore deprecation warning - GH pysal/spaghetti#649
import spaghetti
# quantity demand points
CLIENT_COUNT = 176
# number of candidate facilities in optimal solution
P_FACILITIES = 35
# random seeds for reproducibility
CLIENT_SEED = 5
FACILITY_SEED = 6
# set the solver
solver = pulp.COIN_CMD(msg=False, warmStart=True)
with warnings.catch_warnings():
warnings.simplefilter("ignore")
# ignore deprecation warning - GH pysal/libpysal#468
lattice = spaghetti.regular_lattice((0, 0, 10, 10), 9, exterior=True)
ntw = spaghetti.Network(in_data=lattice)
streets = spaghetti.element_as_gdf(ntw, arcs=True)
streets_buffered = gpd.GeoDataFrame(
gpd.GeoSeries(streets["geometry"].buffer(0.5).unary_union),
crs=streets.crs,
columns=["geometry"],
)
client_points = simulated_geo_points(
streets_buffered, needed=CLIENT_COUNT, seed=CLIENT_SEED
)
with warnings.catch_warnings():
warnings.simplefilter("ignore")
# ignore deprecation warning - GH pysal/libpysal#468
ntw.snapobservations(client_points, "clients", attribute=True)
clients_snapped = spaghetti.element_as_gdf(ntw, pp_name="clients", snapped=True)
clients_snapped.drop(columns=["id", "comp_label"], inplace=True)
cost_matrix = ntw.allneighbordistances(
sourcepattern=ntw.pointpatterns["clients"],
destpattern=ntw.pointpatterns["clients"],
)
cost_matrix = np.where(cost_matrix== 0, 50000, cost_matrix)
cost_matrix = np.round(cost_matrix)
pcenter_from_cm = PCenter.from_cost_matrix(
cost_matrix, p_facilities=P_FACILITIES, name="p-center-network-distance"
)
pcenter_from_cm = pcenter_from_cm.solve(solver) |
Did you install We need to update the docs here to say "highly recommend |
I installed with pip. I have now tried installing via conda and installing using conda install, but get the same error unfortunately. |
Try :
|
Thank you. Unfortunately that didn't work. The same error is there. I got the following for the pulp test. Nothing showing as unavailable but it does look different to the code the pulp page suggests i should see. pulp.pulpTestAll() Ran 1003 tests in 2.016s OK (skipped=944) |
Can you post your full environment file (see here)? |
Thank you so much for your help on this. Attached is the environment file. |
I encountered the similar issue about this too when running the code mclp.ipynb: |
Hey there! Installing If this error persists, please let us know. By the way, the |
I have solved my problem with this code: |
Nice one, thank you! 'solver = pl.PULP_CBC_CMD(keepFiles=True)' also worked for me it seems. Appreciate the help. |
Thanks for troubleshooting @gegen07 . |
Hello,
I am trying to execute the following:
But get the following error:
Does anybody have any suggestions?
I have tried passing the
msg=1
argument to the solver, to get more information.I have checked the precision of the numbers, rounding them.
The cost distance matrix is is a pairwise distance matrix of one df of points - i.e. with itself. Could it be that it is due to duplicated variables / constraints?
The text was updated successfully, but these errors were encountered: