Skip to main content

how to generate .mps file if using GAMS with gurobi solver?

Answered

Comments

12 comments

  • Simranjit Kaur
    Gurobi Staff Gurobi Staff

    Hi Yanda,

    You can use the writeprob option in GAMS to generate an MPS file.

    Alternatively, you can set the Gurobi parameter GURO_PAR_DUMP to 1 to export the model in an MPS file format. For more details, please see the article: How do I write an MPS model file from a third-party API?.

    Regards,
    Simran

    0
  • Yanda Jiang
    Conversationalist
    First Question
    Gurobi-versary

    Hi Simranjit,

    Thank you for your response. I tried both writeprob and GURO_PAR_DUMP.

    I set them to 1 in the gurobi.opt file and also tested using option writeprob=1 and option GURO_PAR_DUMP=1.

    However, neither approach worked. Did I implement them incorrectly? I would appreciate your guidance.

    Best regards,

    Yanda

    0
  • Simranjit Kaur
    Gurobi Staff Gurobi Staff

    Hi Yanda,

    Could you please try adding the line

    writeprob model.mps
    

    to your gurobi.opt options file? Please note use an options file with Gurobi, you will need to set the optfile model attribute or the optfile option to a positive value. Please see the GAMS documentation on using solver options file.

    I hope this helps.

    Regards,
    Simran

    0
  • Yanda Jiang
    Conversationalist
    First Question
    Gurobi-versary

    Thanks, Simranjit. It works! By the way, do you know how to access the model_analyzer module? After running pip install gurobi-modelanalyzer, the gurobipy module is available, but I can't find the model_analyzer module. Do you know why this might be happening?

     

    Best,

    Yanda

    0
  • Simranjit Kaur
    Gurobi Staff Gurobi Staff

    It's great to know that you can export your model in an MPS file now!

    Could it be the case that gurobi-modelanalyzer is installed in a different environment that gurobipy?

    Also, once gurobi-modelanalyzer is installed, you should import gurobi_modelanalyzer module, not model_analyzer.

    For more details, please see the installation and usage instructions on our Gurobi Model Analyzer github.

    Best regards,
    Simran

    0
  • Yanda Jiang
    Conversationalist
    First Question
    Gurobi-versary

    Thanks, Simranjit. You are very helpful. I tried your suggestion, but ended up with this. 

    0
  • Simranjit Kaur
    Gurobi Staff Gurobi Staff

    This error means that you are using Gurobi version 12, but the license you are using is valid only for versions 11.0 and below. To fix this, you need to update your Gurobi license to the latest version. Please follow the instructions in the article How do I resolve an "ERROR 10009: Version number is xx, license is for version yy"?.

    0
  • Yanda Jiang
    Conversationalist
    First Question
    Gurobi-versary

    Thanks, Simranjit. I move one step forward, but get stuck at a new place. Did I do anything wrong?

    0
  • Yanda Jiang
    Conversationalist
    First Question
    Gurobi-versary

    Never mind. I fixed it. Thanks a lot, Simranjit!!! Many thanks!

    0
  • Simranjit Kaur
    Gurobi Staff Gurobi Staff

    Good! 

    The issue was in perhaps in reading the model file. I assume you fixed it by moving the model.mps file to a folder so that the path to the file had no whitespaces.

    Best regards,
    Simran

    0
  • Yanda Jiang
    Conversationalist
    First Question
    Gurobi-versary

    I used double backslash to replace single backslash and then it works.

    0
  • Simranjit Kaur
    Gurobi Staff Gurobi Staff

    Great! Good luck with your project.

    Best regards,
    Simran

    0

Please sign in to leave a comment.