3

I'm using docplex to build up a mixed integer program which is then solved via cplex. However, upon trying to solve the MIP I receive the following error:

CPLEX> read plan.lp
CPLEX Error  1434: Line 184224: Couldn't convert '1<->' to a number.
No file read.

Looking at the lp file, the following line can be seen to be the problem:

1 <->
M13790
+ M13791
>= 1

And the line which creates the constraint is:

ilp.add_if_then(
    ilp.sum([x.select_var for x in self.allX]) >= 1,
    self.select_var == 1,
)

Where ilp is the docplex.mp.model object and each select_var is a binary decision variable. I'm really unsure of why this may be happening, and I'd appreciate any help with it!

WristTurn
  • 31
  • 1
  • As a workaround, you could try exporting your model from docplex in SAV format rather than LP format. See [export_as_sav](https://cdn.rawgit.com/IBMDecisionOptimization/docplex-doc/master/docs/mp/docplex.mp.model.html#docplex.mp.model.Model.export_as_sav). – rkersh Mar 01 '18 at 01:26
  • No such luck. I'm using python 3 in this project but I'm currently running cplex 12.6.0. This version of cplex doesn't support python 3, and as export_as_sav requires access to the cplex python module I can't write the model in sav format. – WristTurn Mar 01 '18 at 06:23
  • If it's possible, you could try using the most recent version via the free Community Edition or through the Academic Initiative (see [this](https://www.ibm.com/products/ilog-cplex-optimization-studio/pricing) link). – rkersh Mar 01 '18 at 23:57

1 Answers1

1

Logical constraints (such as add_if_then) require a CPLEX 12.8 runtime to solve. If you run DOcplex with an older version of CPLEX in you PYTHONPATH, then an error should be raised.

If CPLEX is not found in PYTHONPATH, then DOcplex has no way to guess which version you'll be using (you might want to submit a Python job to DOcplexcloud, in which case your model will be solved with a CPLEX 12.8 runtime)

The generated LP file contains logical equivalence syntax (<->) which may not be read by older versions of CPLEX. Again, the best way to solve such LPs is to use a CPLEX 12.8 either by upgrading your local library or going to the cloud.

Philippe Couronne
  • 826
  • 1
  • 5
  • 6