Skip to main content

Issues with using MIN for a constraint

Answered

Comments

5 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 why not try our AI Gurobot?.
  • Alison Cozad
    • Gurobi Staff

    There is a good example of using the general max constraint in the Model.addGenConstrMax() documentation.  To translate this to your problem, you would use the following to define c3:

    c3={i:m.addConstr(min_y[i] == grb.min_(y[i,j] for j in J), name="c3".format(i)) for i in I}

     

    One other item of note, there was an error when I ran the objective definition.  According to the quicksum() documentation, the input argument should be a

    List of terms to add. The terms can be constants, Var objects, LinExpr objects, or QuadExpr objects.

    To remedy this, you can use the following to define your objective

    objective = grb.quicksum((y[i,j])for i in I for j in J) + grb.quicksum(min_y[i] for i in I)
    1
  • Jubair Yusuf
    • Gurobi-versary
    • First Comment
    • First Question

    Thanks a lot for your prompt response, Alison. 

    0
  • Jubair Yusuf
    • Gurobi-versary
    • First Comment
    • First Question

    Hi, 

    While I was trying to optimize this, it is taking too long to converge/give an answer. The min_y variable is making it time consuming. Apparently I did not get any answer after keeping it running for a day. I have used/assigned values of MIPFocus=1. Is there anything I can do to make it faster ? I am using a regular laptop with core i-7 and 16 gb RAM.

    0
  • Alison Cozad
    • Gurobi Staff

    There are a few things I can suggest:

    • Provide a warm start: Typically, providing a warm start or initial solution can improve performance significantly.  Even a relatively poor feasible point could be useful for the solver. A warm start can affect many algorithmic choices during Gurobi's solve.
    • Tighten variable bounds: One large challenge in nonconvex optimization is generating tight outer approximations of nonconvex terms. A simple way to improve these approximations is to provide tight bounds on all variables — especially, variables that are part of nonlinear terms. I recommend starting here to see how this affects the solve.
    • Scale variables and constraints: Consider scaling your variable ranges, constraint coefficients, and RHS values. Our reference manual's Tolerances and user-scaling section can walk you through why scaling is important, rules of thumb for scaling, and some examples.
    • Consider tuning parameters: Gurobi has several parameters that affect the solution time. It may be beneficial to try non-default values to see if you can close the gap. I recommend reading through Most Important MIP Parameters along with your log file for ideas. There are a few specific parameters to test that focus on quadratic problems only (e.g., PreMIQCPForm).  While it may be daunting to sift through all of these parameters by hand, Gurobi offers an automated tuning tool to help select quality parameter sets.
    0

Post is closed for comments.