7
$\begingroup$

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.

$\endgroup$
5
  • 1
    $\begingroup$ have you tried using other functions from docplex? Like the docplex.mp? Maybe this helps: ibmdecisionoptimization.github.io/docplex-doc/mp/… $\endgroup$
    – JakobS
    Commented Aug 1, 2019 at 10:18
  • 1
    $\begingroup$ And in the "next topic" section of the link above that @JakobS shared you can find model_reader module $\endgroup$
    – EhsanK
    Commented Aug 1, 2019 at 12:23
  • $\begingroup$ 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? $\endgroup$
    – Mostafa
    Commented Aug 1, 2019 at 13:41
  • $\begingroup$ That is right you need to use "DOcplex.cp" but more information can be found in the link: "ibmdecisionoptimization.github.io/docplex-doc/cp/index.html" $\endgroup$ Commented Aug 1, 2019 at 14:03
  • $\begingroup$ @OguzToragay Yeah, and there is no function to read .lp or .mps files. $\endgroup$
    – Mostafa
    Commented Aug 12, 2019 at 5:44

1 Answer 1

6
$\begingroup$

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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.