Debugging problem formulation with CPLEX and PULP

huangapple go评论59阅读模式
英文:

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 = &#39;/Applications/CPLEX_Studio_Community2211/cplex/bin/x86-64_osx/cplex&#39;
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 &amp; 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 &#39;help&#39; for a list of available commands.
Type &#39;help&#39; followed by a command name for more
information on commands.

CPLEX&gt; CPLEX Error  1608: Line 6: Expected &#39;+&#39;,&#39;-&#39; or sense, found &#39;:&#39;.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'.

huangapple
  • 本文由 发表于 2023年5月22日 17:18:39
  • 转载请务必保留本文链接:https://go.coder-hub.com/76304672.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定