Search code examples
pythonoptimizationdocplex

Printing all constraints using DOcplex


I am actually running a MILP on Python using DOcplex and it is my very first time using it. It is saying that my model which I ran on Lindo is infeasible. Therefore, I am guessing that I erroneously entered my constraints, but I cannot view them. I used "mdl.print_information()", but it is not helping much. Does anyone know how I can solve my problem?

Thanks in advance.


Solution

  • You can export the model to LP format (a human readable LP format), by Model.export_as_lp(). You can also export the model to a string in LP format with Model.lp_string, to get a complete view of the model.

    In addition, this notebook: https://github.com/IBMDecisionOptimization/docplex-examples/blob/master/examples/mp/jupyter/infeasible.ipynb gives hints on how to investigate infeasible models, in particular with the Relaxer class.

    Knowing which constraint is infeasible (and by how much slack) may lead you to the root cause of the infeasibility.