How to use a dict for .start?
AnsweredHello, I have the following dict, which I would like to use as a start solution for my MIP. Unfortunately, I haven't quite figured out what the correct code for this would be. The dict reflects the indices \(i,t,j\) The variable tyredeg is to be filled with the start values. It is defined as:
tyredeg = m.addVars(I, T, J, vtype=gu.GRB.CONTINUOUS, lb=0, ub=1, name="deg")
Thanks in advance.
The dict:
{(1, 1, 1): 0.0, (1, 1, 2): 0.0, (1, 1, 3): 0.0, (1, 2, 1): 0.0, (1, 2, 2): 0.0, (1, 2, 3): 0.0, (1, 3, 1): 1.0, (1, 3, 2): 0.0, (1, 3, 3): 0.0, (1, 4, 1): 1.0, (1, 4, 2): 0.0, (1, 4, 3): 0.0, (1, 5, 1): 1.0, (1, 5, 2): 0.0, (1, 5, 3): 0.0, (1, 6, 1): 1.0, (1, 6, 2): 0.0, (1, 6, 3): 0.0, (1, 7, 1): 1.0, (1, 7, 2): 0.0, (1, 7, 3): 0.0, (1, 8, 1): 0.0, (1, 8, 2): 0.0, (1, 8, 3): 0.0, (1, 9, 1): 0.0, (1, 9, 2): 0.0, (1, 9, 3): 0.0, (1, 10, 1): 1.0, (1, 10, 2): 0.0, (1, 10, 3): 0.0, (1, 11, 1): 1.0, (1, 11, 2): 0.0, (1, 11, 3): 0.0, (1, 12, 1): 1.0, (1, 12, 2): 0.0, (1, 12, 3): 0.0, (1, 13, 1): 1.0, (1, 13, 2): 0.0, (1, 13, 3): 0.0, (1, 14, 1): 1.0, (1, 14, 2): 0.0, (1, 14, 3): 0.0, (2, 1, 1): 0.0, (2, 1, 2): 0.0, (2, 1, 3): 1.0, (2, 2, 1): 0.0, (2, 2, 2): 0.0, (2, 2, 3): 1.0, (2, 3, 1): 0.0, (2, 3, 2): 0.0, (2, 3, 3): 1.0, (2, 4, 1): 0.0, (2, 4, 2): 0.0, (2, 4, 3): 1.0, (2, 5, 1): 0.0, (2, 5, 2): 0.0, (2, 5, 3): 1.0, (2, 6, 1): 0.0, (2, 6, 2): 0.0, (2, 6, 3): 0.0, (2, 7, 1): 0.0, (2, 7, 2): 0.0, (2, 7, 3): 0.0, (2, 8, 1): 0.0, (2, 8, 2): 0.0, (2, 8, 3): 1.0, (2, 9, 1): 0.0, (2, 9, 2): 0.0, (2, 9, 3): 1.0, (2, 10, 1): 0.0, (2, 10, 2): 0.0, (2, 10, 3): 1.0, (2, 11, 1): 0.0, (2, 11, 2): 0.0, (2, 11, 3): 1.0, (2, 12, 1): 0.0, (2, 12, 2): 0.0, (2, 12, 3): 1.0, (2, 13, 1): 0.0, (2, 13, 2): 0.0, (2, 13, 3): 0.0, (2, 14, 1): 0.0, (2, 14, 2): 0.0, (2, 14, 3): 0.0, (3, 1, 1): 1.0, (3, 1, 2): 0.0, (3, 1, 3): 0.0, (3, 2, 1): 0.0, (3, 2, 2): 0.0, (3, 2, 3): 0.0, (3, 3, 1): 0.0, (3, 3, 2): 0.0, (3, 3, 3): 0.0, (3, 4, 1): 1.0, (3, 4, 2): 0.0, (3, 4, 3): 0.0, (3, 5, 1): 1.0, (3, 5, 2): 0.0, (3, 5, 3): 0.0, (3, 6, 1): 1.0, (3, 6, 2): 0.0, (3, 6, 3): 0.0, (3, 7, 1): 1.0, (3, 7, 2): 0.0, (3, 7, 3): 0.0, (3, 8, 1): 1.0, (3, 8, 2): 0.0, (3, 8, 3): 0.0, (3, 9, 1): 0.0, (3, 9, 2): 0.0, (3, 9, 3): 0.0, (3, 10, 1): 0.0, (3, 10, 2): 0.0, (3, 10, 3): 0.0, (3, 11, 1): 1.0, (3, 11, 2): 0.0, (3, 11, 3): 0.0, (3, 12, 1): 0.0, (3, 12, 2): 0.0, (3, 12, 3): 0.91, (3, 13, 1): 0.0, (3, 13, 2): 0.0, (3, 13, 3): 0.91, (3, 14, 1): 0.0, (3, 14, 2): 0.0, (3, 14, 3): 0.91}
-
Official comment
This post is more than two 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. -
Hi Dejan,
You could set the .Start attribute with the following code:
for key, value in start_dict.items():
tyredeg[key].Start = valueHowever Start values are only valid for integer (including binary) variables, so this code will not have the effect you want it to.
We do have PStart which can be used with continuous variables (the values must be provided for every variable), but it also needs to be used in conjunction with DStart which is related to constraints.
- Riley
0
Post is closed for comments.
Comments
2 comments