4
$\begingroup$

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

import cplex

model = cplex.Cplex()
model.objective.set_sense(model.objective.sense.minimize)
model.objective.set_quadratic(Q_martix)
.
.
# similarly declare constraints 
.
.
model.write('my_file.lp')

Questions:

  • 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?

$\endgroup$
6
$\begingroup$

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.

$\endgroup$
1
  • $\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
    Aug 25 at 8:47
7
$\begingroup$

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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