Customize variable and constraint names of LP file (in MATLAB)
AnsweredHello everyone,
I have a problem needing your help.
I am modeling an MIP problem on MATLAB and YALMIP. I use the codes like
Decision_State_startup = binvar(Number_gen,Number_horizon);
Decision_Generation = sdpvar(Number_gen,Number_horizon,'full');
CC_General_01 = [CC_General_01, Decision_RES_spilling >= 0];
....
for definition variables and constraints. Currently, I want to export the LP file of the model so that I can check whether I write the model right or not. However, variables in LP file is defaulted to be "C" and constraints in LP file is defaulted to be "R". This is difficult to be read in case of many variables and constraints.
Could you please provide me some commands or ideas to customize the variables? I wish the variables is like "Decision_Generation" in LP file.
Thanks,
Xianbang
-
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 why not try our AI Gurobot?. -
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 -
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,
Xianbang0 -
Sorry, I forget to post the Facility problem's link.
https://www.gurobi.com/documentation/9.0/examples/facility_m.html
0 -
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 -
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 -
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 -
Thanks, it is my pleasure.
0
Post is closed for comments.
Comments
8 comments