We are exporting a optimization problem from matrices to LP format using Cplex.

import cplex

model = cplex.Cplex()
# similarly declare constraints 


  • After receiving the raw optimization problem (as matrices), does Cplex apply any transformations (or dumps the raw problem un-transformed)?

  • Is Cplex's LP transformation code open-source, or available to view?


2 Answers 2


If you export the model, then by default, Cplex will export your original, unaltered model. When you solve a model, Cplex will, by default, first invoke a presolve,during which it will attempt to simplify and tighten your model, e.g. by removing redundant constraints, solving for logical implications, etc. As per this SO post, you can then also export the presolved model.

Cplex is a closed source commercial solver; they don't have any open source code.

  • $\begingroup$ Cplex is indeed commercial. But we just thought - LP format file has quite wide-spread usage in optimization industry that its code/algorithm ought to be publicly accessible. $\endgroup$
    – pqrz
    Commented Aug 25, 2021 at 8:47

While it does not deliberately transform the problem before exporting it, using the LP file format means that double precision coefficients are being converted to character strings (and, in the process, truncated and/or rounded). So there will frequently be a little loss of precision, and sometimes that "little" loss of precision can turn into big adventures if the LP file is read back in (with another text/binary conversion) and solved. For that reason, when debugging a model it is almost always better to use the SAV file format.


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.