Skip to main content

Customize variable and constraint names of LP file (in MATLAB)

Answered

Comments

8 comments

  • Official comment
    Simranjit Kaur
    • Gurobi Staff Gurobi Staff
    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 why not try our AI Gurobot?.
  • Jaromił Najman
    • Gurobi Staff Gurobi Staff

    This is a crosspost from the YALMIP forum.

    It seems like YALMIP currently cannot pass custom variable names to the solver. As it is a YALMIP specific question, it is best to wait for an answer in the mentioned YALMIP forum.

    In the meantime, if your application allows, you could try using the Gurobi MATLAB API. You could have a look at Gurobi's MATLAB examples to have a comfortable start with the API.

    Best regards,
    Jaromił

    0
  • Xianbang Chen
    • Gurobi-versary
    • Conversationalist
    • Curious

    Dear Jaromił,


    Thanks for the reply.


    According to my understanding, YALMIP's value is that it can complied the constraints and variables with its format to a format that can be accepted by solvers including Gurobi and CPLEX, is that right? Because, YALMIP has completed the model in its way, so I cannot customize variable names like that in Facility problem.


    In fact, I want to do a MIP warm start for a MIP problem. So, seems like that I can only do it with API rather than with YALMIP, is that right?


    By the way, what is the full name of API? I am really interested.

    Regards,
    Xianbang

    0
  • Xianbang Chen
    • Gurobi-versary
    • Conversationalist
    • Curious

    Sorry, I forget to post the Facility problem's link.

    https://www.gurobi.com/documentation/9.0/examples/facility_m.html

    0
  • Jaromił Najman
    • Gurobi Staff Gurobi Staff

    Dear Xianbang,

    I am no expert on YALMIP, but it seems like YALMIP uses its own private variable names to then pass the according variables and constraints to the attached solvers such as Gurobi or CPLEX. This is very likely the current reason for why you are not able to customize the variable names in your problem. It would be best to wait for a response of the YALMIP developers.

    If you would like to provide a MIP start in YALMIP, you can use the \(\texttt{assign}\) function as described in the YALMIP documentation on Supplying initial guesses to solvers.

    API stands for Application Programming Interface.

    Best regards,
    Jaromił

     

    0
  • Xianbang Chen
    • Gurobi-versary
    • Conversationalist
    • Curious

    Dear Jaromił,

    Thanks for your reply. The works of yours and your colleges make the community so cool.

    I have an idea to customize the variable with YALMIP (Even though it is more natural do this through MATLAB API, I still need some time to get familiar with the API).

    The idea is as following:

    (1). Write the MIP problem via YALMIP and then export its LP file or MPS file with command gurobi_write();

    (2). Read the LP file or MPS file through gurobi_read(), and then I can get a struct variable that describes the model as I model through MATLAB API. In the struct variable, I can find the varnames field.

    (3). Customize the varnames.

    Regards,

    Xianbang

     

    0
  • Jaromił Najman
    • Gurobi Staff Gurobi Staff

    Dear Xianbang,

    Thank you for the kind words!

    Great to hear that you found a workaround for the current situation and shared it with the community!

    Best regards,
    Jaromił

    0
  • Xianbang Chen
    • Gurobi-versary
    • Conversationalist
    • Curious

    Thanks, it is my pleasure.

    0

Post is closed for comments.