7

I want to solve a problem with docplex.cp (module for Constraint Programming optimizer CPLEX for Python), and the problem is available in .lp or .mps formats. But I did not find the attribute for reading a file in it.

For the CPLEX itself, utilizing the cplex module it can be done as following:

import cplex

Model = cplex.Cplex("MyProblem.lp")
Model.solve()

But for the docplex module I tried to use import_model as following:

from docplex.cp.model import CpoModel

m = CpoModel()
Model = CpoModel.import_model(m,"MyProblem.lp")
Model.solve()

But it is not working as import_model only supports .cpo and .fzn formats.

Mostafa
  • 2,104
  • 10
  • 28
  • 1
    have you tried using other functions from docplex? Like the docplex.mp? Maybe this helps: https://ibmdecisionoptimization.github.io/docplex-doc/mp/docplex.mp.model.html – JakobS Aug 01 '19 at 10:18
  • 1
    And in the "next topic" section of the link above that @JakobS shared you can find model_reader module – EhsanK Aug 01 '19 at 12:23
  • Thanks for suggestions. I need to solve with the Constraint Programming optimizer, so I guess "docplex.cp" is the right module. Am I right that "docplex.mp" is equivalent to using "cplex" module? – Mostafa Aug 01 '19 at 13:41
  • That is right you need to use "DOcplex.cp" but more information can be found in the link: "https://ibmdecisionoptimization.github.io/docplex-doc/cp/index.html" – Oguz Toragay Aug 01 '19 at 14:03
  • @OguzToragay Yeah, and there is no function to read .lp or .mps files. – Mostafa Aug 12 '19 at 05:44

1 Answers1

6

Thank you for using docplex. Currently, docplex.cp can import only .cpo and .mzn files. Maybe this could be extended in the next future.

Michiel uit het Broek
  • 2,491
  • 2
  • 15
  • 36