英文:
Debugging problem formulation with CPLEX and PULP
问题
I am currently trying to use the CPLEX Solver with PULP. The model I have defined with PULP works with the XPRESS solver, but I am having difficulties with using CPLEX.
When I run (in a jupyter notebook):
path_to_cplex = '/Applications/CPLEX_Studio_Community2211/cplex/bin/x86-64_osx/cplex'
solver = CPLEX_CMD(path=path_to_cplex, msg=True)
prob.solve(solver=solver)
I get:
Welcome to IBM(R) ILOG(R) CPLEX(R) Interactive Optimizer Community Edition 22.1.1.0
with Simplex, Mixed Integer & Barrier Optimizers
5725-A06 5725-A29 5724-Y48 5724-Y49 5724-Y54 5724-Y55 5655-Y21
Copyright IBM Corp. 1988, 2022. All Rights Reserved.
Type 'help' for a list of available commands.
Type 'help' followed by a command name for more
information on commands.
CPLEX> CPLEX Error 1608: Line 6: Expected '+', '-' or sense, found ':'. No file read.
My question is how do I see what line (in this case line 6) CPLEX is referring to? I tried reading the PULP and CPLEX documentation but I couldn't find anything too helpful.
英文:
I am currently trying to use the CPLEX Solver with PULP. The model I have defined with PULP works with the XPRESS solver, but I am having difficulties with using CPLEX.
When I run (in a jupyter notebook):
<!-- language: python -->
path_to_cplex = '/Applications/CPLEX_Studio_Community2211/cplex/bin/x86-64_osx/cplex'
solver = CPLEX_CMD(path=path_to_cplex, msg=True)
prob.solve(solver=solver)
I get:
<!-- language: none -->
Welcome to IBM(R) ILOG(R) CPLEX(R) Interactive Optimizer Community Edition 22.1.1.0
with Simplex, Mixed Integer & Barrier Optimizers
5725-A06 5725-A29 5724-Y48 5724-Y49 5724-Y54 5724-Y55 5655-Y21
Copyright IBM Corp. 1988, 2022. All Rights Reserved.
Type 'help' for a list of available commands.
Type 'help' followed by a command name for more
information on commands.
CPLEX> CPLEX Error 1608: Line 6: Expected '+','-' or sense, found ':'.No file read.
My question is how do I see what line (in this case line 6) CPLEX is referring to? I tried reading the PULP and CPLEX documentation but I couldn't find anything too helpful.
答案1
得分: 0
为了查看CPLEX正在引用的.lp文件,您需要在设置求解器时传递keepFiles=True
,即:
solver = CPLEX_CMD(keepFiles=True)
prob.solve(solver=solver)
然后.lp文件应该会出现在当前目录下,文件名为'{model_name_in_pulp}-pulp.lp'。
英文:
Posting this in case someone else was searching for this.
In order to see the .lp file that CPLEX is referring to, you need to pass keepFiles=True
when setting the solver. i.e.
solver = CPLEX_CMD(keepFiles=True)
prob.solve(solver=solver)
Then the .lp file should appear in the current directory under the name '{model_name_in_pulp}-pulp.lp'.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论