Skip to main content

Initial values or start solution

Answered

Comments

6 comments

  • Official comment
    Simranjit Kaur
    • 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 try Gurobot, our chatbot interface offering instant, expert-level support.
  • Jaromił Najman
    • Gurobi Staff

    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
  • Tess
    • Gurobi-versary
    • First Comment
    • First Question

    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,

    Tessa

    0
  • Jaromił Najman
    • Gurobi Staff

    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
  • Tess
    • Gurobi-versary
    • First Comment
    • First Question

    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 | 400

    m.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
  • Tess
    • Gurobi-versary
    • First Comment
    • First Question

    It worked with the if and else statement! Thank you!! 
    Kind Regards,

    Tessa

    0

Post is closed for comments.