How to show model equation from .mps file to Jupyter notebook?
AnsweredI need to show the model structure/equation to the Jupyter notebook.
I wrote the model into local file (using mps, rlp, lp). Here is the model structure if I open it in text editor. I want to show the same content to Jupyter Notebook/jupyter lab.

But, when I open the saved model.rlp or model.mps, it only shows some information (not the CONTENT I can see from text editor.

0
-
Official comment
This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum, or try Gurobot, our chatbot interface offering instant, expert-level support. -
Gurobi's read() function reads the model file into a Model object. To print the content of a model file, use Python's built-in open() function:
with open("Outputs/model_v1.mps", "r") as f:
contents = f.read()
print(contents)Write the model to the LP (or RLP) format if you want it to be human-readable.
1 -
thanks so much. It works.
0
Post is closed for comments.
Comments
3 comments