Skip to main content

Facility location problem with a variable capacity constraint

Awaiting user input

Comments

4 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?.
  • Mario Ruthmair
    Gurobi Staff Gurobi Staff

    Hi,

    Are your facility variables y one or two dimensional? They are created for each facility but they seem to be used in the second set of constraints for each facility and product?
    If they would be defined in the latter way, i.e., to decide whether some facility i is open and serves product k, then you could directly use them in your capacity constraints to differentiate between the two capacities, i.e.,

    m.addConstrs( ... <= CAP1 + (CAP2-CAP1) * y[i,0] ... )

    I hope I understood your problem correctly and this solves your modeling issue?

    Best regards,
    Mario

    1
  • Ashraf Ali
    Gurobi-versary
    Conversationalist
    First Question

    Mario,

    Thank you for your response. Sorry for the confusion, but that was I mistake in my post that I have corrected. Yes I was trying to limit facilities to one type of products but that was wrong since a facility can handle multiple type of products at the same time. 

    For my problem, I was thinking to formulate the same idea you proposed but using my one dimensional variable. I want to create an indicator variable for each facility that equals to 1 if a customer with product 0 is assigned to that facility, and equal to 0 otherwise. Then use that indicator variable in the capacity constraint the same way you use the two dimensional variable. I'm not sure to how to formulate that though. 

    Here is what I tried. Let's say the indicator variable is q

    q = m.addVars(fac,vtype=GRB.BINARY,name="indicator")
    q[i] =(x.sum(i,'*', 0) for i in fac)

    now if no customer with product 0 is assigned to facility i, then q[i] is zero and will work on the constraint. But if we have more than one customers with product 0 assigned to facility i, then q[i] is more than one, and will not work on the constraint.

    That was the idea I had, but maybe there is a different way to go about that.

     

    Thank you!

    0
  • Mario Ruthmair
    Gurobi Staff Gurobi Staff

    Hi,

    If you only want to handle product 0 in a special way, then your approach with using a single additional binary variable for each facility is perfectly fine.

    But you have to link variables q and x differently, i.e., by using one constraint for each facility and each customer:

    m.addConstrs((x[i,c,0] <= q[i] for i in fac for c in cust), name="prod0")

    Does this work for you?

    Best regards,
    Mario

    0

Post is closed for comments.