Initial values or start solution
AnsweredHi! I am modeling a dynamic facility location model that can open and close facilities and struggling with some initial values.
For my model, I have a set of facilities that are open at the beginning and a set of closed facilities! You could write it mathematically like this:
The objective of the model is to minimize costs. There are costs of opening a facility, closing a facility, and costs if a facility stays open.
For the initial open facilities, I don't want to include the costs of opening a facility (the facility already exists) in the objective. Therefore, I think MIP Starts is not possible.
I am wondering what is the best way to enter the initial values of some of the facilities, and where I should do this.
-
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 try Gurobot, our chatbot interface offering instant, expert-level support. -
Hi Tess,
For the initial open facilities, I don't want to include the costs of opening a facility (the facility already exists) in the objective. Therefore, I think MIP Starts is not possible.
You could add equality constraints setting constant values for the specific facilities, i.e., you would fix some specific variables. This is commonly done for situation such as yours where one has a rather general model with some specific initial situation.
Best regards,
Jaromił0 -
Hi Jaromil,
Do you mean like this?
capacity of facility A = 3000 at start
facilityA = q_0 = 300
m.addConstr(q[(facility_a, time_0)] == 3000, name = 'initialcapacity)
The problem is I have many initial values, so it doesn't make sense to add equality constraints for each location. What I would like to have is something like this
Is there an easy way to add such initial values? Or am I missing something?
Kind Regards,
Tessa0 -
Hi Tess,
Do you mean like this?
capacity of facility A = 3000 at start
facilityA = q_0 = 300
m.addConstr(q[(facility_a, time_0)] == 3000, name = 'initialcapacity)Yes.
Is there an easy way to add such initial values? Or am I missing something?
I am not sure about the content of the table but you have to store your data somehow anyway. So couldn't you use this data stored as a list/table/dictionary and automatically construct initial conditions?
Best regards,
Jaromił0 -
Yes, I am struggling with setting the initial values.
So I have this dataframe (with pandas) that looks like the table.
facility |open? | Q_0| Q_max
Fac A | 1 | 300 | 500
Fac B | 0 | 450 | 600
Fac C | 0 | 200 | 400m.addConstr(q[(facility_a, time_0)] == 3000, name = 'initialcapacity)
Right now the capacity constraints looks like this:m.addConstr(quicksum(x[(node, facility, period)]*demanddata.iloc[node][1 + period] for node in range(nodes)) <= o[(facility, period)]*facilitydata.iloc[facility][3], name = 'do not allocate if not open + capacity constraint')
However, o[(facility, period)] is only 1 for facility A at the start. So it could be like this:
m.addConstr(quicksum(x[(node, facility, period)]*demanddata.iloc[node][1 + period] for node in range(nodes)) <= facilitydata.iloc[facility][1]*facilitydata.iloc[facility][3], name = 'do not allocate if not open + capacity constraint')
But the value of o[(facility, period)] can change over time, according to this formula:
m.addConstr(o[(facility, period)] == o[(facility, period-1)] + y[(facility, period)] - z[(facility, period)])
Therefore, I don't want to refer to the Table in the constraint! Or should I make two constraints? One for period = 0 & another one for period = 1:end?
Thanks a lot!
Kind Regards,Tessa
0 -
It worked with the if and else statement! Thank you!!
Kind Regards,
Tessa0
Post is closed for comments.
Comments
6 comments