1 year ago
#236016
Key
PulpSolverError Pulp: Error while executing
I am trying to solve a Linear programming problem by using the PuLP library. After defining the problem correctly, when I run the solver (CBC) I get a very strange error.
PulpSolverError: Pulp: Error while executing c:\users\hp\appdata\local\programs\python\python38\lib\site-packages\pulp\apis..\solverdir\cbc\win\64\cbc.exe
I do not what is the issue, and I think I have hit the wall as I have tried several ways without any success. I also used the following link but it did not help me so I thought to pose it a question: - puLP solver error
The problem defined by me is as follows: -
prob = LpProblem('Diet_Problem', LpMinimize)
#Using only the first 17 rows in the data set
df = pd.read_excel('diet.xls',nrows=17)
food = list(df.Foods)
#Create a dictionary of calories for all items of food
calories = dict(zip(food,df['Calories']))
Similarly created dictionaries for Carbohydrates, proteins, vitamin_A and other components. Exact similar code was used in each case.
# A dictionary called 'food_vars' is created to contain the referenced Variables
food_vars = LpVariable.dicts("Food",food,lowBound=0,cat='Continuous')
#Defined the objective function in the problem
prob += lpSum([costs[i]*food_vars[i] for i in food])
#Defined the constraints and added to the problem
prob += lpSum([food_vars[x]*calories[x] for x in food]) >= 800, "CaloriesMinimum"
prob += lpSum([food_vars[x]*calories[x] for x in food]) <= 1300, "CaloriesMaximum"
After defining all this, when I run the solver I get following error: -
prob.solve()
A snapshot of the data set is here follows: -
Please let me know the solution for this. I have tried all my ways. Thanks in advance
python
pandas
linear-programming
pulp
glpk
0 Answers
Your Answer