# Can docplex (module for Constraint Programming optimizer CPLEX for Python) read .lp or .mps file?

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.

• have you tried using other functions from docplex? Like the docplex.mp? Maybe this helps: ibmdecisionoptimization.github.io/docplex-doc/mp/… Aug 1, 2019 at 10:18
• And in the "next topic" section of the link above that @JakobS shared you can find model_reader module
– EhsanK
Aug 1, 2019 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? Aug 1, 2019 at 13:41
• 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" Aug 1, 2019 at 14:03
• @OguzToragay Yeah, and there is no function to read .lp or .mps files. Aug 12, 2019 at 5:44

## 1 Answer

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