Triss Ashton
Triss Ashton

Reputation: 1

How to fix GLPK "missing variable name CPLEX LP file processing error"

I have a dynamic model that I want to run with the GLPK solver. I am now getting the error missing variable name CPLEX LP file processing error. I say now getting because earlier there was a different error that pointed to a different line (possible 1947 before an update). That code line, as I recall was similar to line 1913.

However, the problem runs with CBC. I have verified GLPK and PuLP are both operating fine in a similar problem.


Full error message:

Traceback (most recent call last):

  Cell In[12], line 1
    result = prob.solve(GLPK(options = ['--ranges', 'sensitivity.txt']))

  File C:\ProgramData\Anaconda3\lib\site-packages\pulp\pulp.py:1913 in solve
    status = solver.actualSolve(self, **kwargs)

  File C:\ProgramData\Anaconda3\lib\site-packages\pulp\apis\glpk_api.py:115 in actualSolve
    raise PulpSolverError("PuLP: Error while executing " + self.path)

PulpSolverError: PuLP: Error while executing glpsol.exe

GLPSOL: GLPK LP/MIP Solver, v4.65
Parameter(s) specified in the command line:
 --cpxlp C:\Users\TRISSD~1\AppData\Local\Temp\e22c89d89a96466681a5fabbb45117b5-pulp.lp
 -o C:\Users\TRISSD~1\AppData\Local\Temp\e22c89d89a96466681a5fabbb45117b5-pulp.sol
 --ranges sensitivity.txt
Reading problem data from 'C:\Users\TRISSD~1\AppData\Local\Temp\e22c89d89a96466681a5fabbb45117b5-pulp.lp'...
C:\Users\TRISSD~1\AppData\Local\Temp\e22c89d89a96466681a5fabbb45117b5-pulp.lp:3: missing variable name
CPLEX LP file processing error

Setting the option msg=1 gets a similar but different response:

Traceback (most recent call last):

  Cell In[17], line 1
    result = prob.solve(GLPK(msg=1))#(options = ['--ranges', 'sensitivity.txt']))

  File C:\ProgramData\Anaconda3\lib\site-packages\pulp\pulp.py:1913 in solve
    status = solver.actualSolve(self, **kwargs)

  File C:\ProgramData\Anaconda3\lib\site-packages\pulp\apis\glpk_api.py:115 in actualSolve
    raise PulpSolverError("PuLP: Error while executing " + self.path)

PulpSolverError: PuLP: Error while executing glpsol.exe

GLPSOL: GLPK LP/MIP Solver, v4.65
Parameter(s) specified in the command line:
 --cpxlp C:\Users\TRISSD~1\AppData\Local\Temp\95d05ec9f5ae43d4906085fc8664b88d-pulp.lp
 -o C:\Users\TRISSD~1\AppData\Local\Temp\95d05ec9f5ae43d4906085fc8664b88d-pulp.sol
Reading problem data from 'C:\Users\TRISSD~1\AppData\Local\Temp\95d05ec9f5ae43d4906085fc8664b88d-pulp.lp'...
C:\Users\TRISSD~1\AppData\Local\Temp\95d05ec9f5ae43d4906085fc8664b88d-pulp.lp:3: missing variable name
CPLEX LP file processing error

The current setup is

Windows 10 Python 3.8.16 Spyder 5.4.3 PuLP 2.7.0 GLPK 4.65

Here is the problem code:

# Import Libraries

import pulp
from pulp import GLPK

prob = pulp.LpProblem('Dynamic_Problem_Continuous_Var', pulp.LpMinimize)

x1 = pulp.LpVariable('1Jan', lowBound = 2000, upBound = 4000)
x2 = pulp.LpVariable('2Feb', lowBound = 1750, upBound = 3500)
x3 = pulp.LpVariable('3Mar', lowBound = 2000, upBound = 4000)
x4 = pulp.LpVariable('4Apr', lowBound = 2250, upBound = 4500)
x5 = pulp.LpVariable('5May', lowBound = 2000, upBound = 4000)
x6 = pulp.LpVariable('6Jun', lowBound = 1750, upBound = 3500) 

# Subject To 
I1 = 2750
prob += I1

I2 = I1 + x1 - 1000
prob += I2 <= 6000
prob += I2 >= 1500

I3 = I2 + x2 - 4500
prob += I3 <= 6000
prob += I3 >= 1500

I4 = I3 + x3 - 6000
prob += I4 <= 6000
prob += I4 >= 1500

I5 = I4 + x4 - 5500
prob += I5 <= 6000
prob += I5 >= 1500 

I6 = I5 + x5 - 3500
prob += I6 <= 6000 
prob += I6 >= 1500

I7 = I6 + x6 - 4000
prob += I7 <= 6000 
prob += I7 >= 1500

# The Objective Function
z = 240*x1 + 250*x2 + 265*x3 + 285*x4 + 280*x5 + 260*x6 + 3.6*(I1 + I2)/2 + 3.75*(I2 + I3)/2 + 3.98*(I3 + I4)/2 + 4.28*(I4 + I5)/2 + 4.20*(I5 + I6)/2 + 3.9*(I6 + I7)/2

prob += z,'Min_Cost'

# Solve the LP using the GLPK solver. 
result = prob.solve(GLPK(options = ['--ranges', 'sensitivity.txt']))

As stated above, the problem runs fine on CBC with these results:

Optimal number of units to build in 1Jan is 4000.0
Optimal number of units to build in 2Feb is 3500.0
Optimal number of units to build in 3Mar is 4000.0
Optimal number of units to build in 4Apr is 4250.0
Optimal number of units to build in 5May is 4000.0
Optimal number of units to build in 6Jun is 3500.0
The end of period inventory is 5750.0
The end of period inventory is 4750.0
The end of period inventory is 2750.0
The end of period inventory is 1500.0
The end of period inventory is 2000.0
The end of period inventory is 1500.0
Total cost is = $ 6,209,432.50

GLPK runs fine in Spyder/PuLP with a similar problem. I have updated from conda-forge, although GLPK 4.65 is still reported.

Upvotes: 0

Views: 479

Answers (0)

Related Questions