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
-
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
Please sign in to leave a comment.
Comments
2 comments