Skip to main content

Conditional parameter / slow MIP solving

Answered

Comments

3 comments

  • Jaromił Najman
    Gurobi Staff Gurobi Staff

    Hi Michael,

    You could try using a big-M formulation as described in How do I model conditional statements in Gurobi?

    b = m.addVars(range(LEN), vtype=GRB.BINARY)
    m.addConstrs((P[t] >= M*b[t] - M for t in range(LEN)))
    m.addConstrs((P[t] <= M*b[t] for t in range(LEN)))
    m.addConstrs(((b==1) >> (eta[t] == 0.84) for t in range(LEN)))
    m.addConstrs(((b==0) >> (eta[t] == 1.2 ) for t in range(LEN)))

    In the above, you can either set one \(M\) value for all \(P_t\) or compute individual \(M_t\) values for each index \(t\). It is best to choose the big-M value as tight as possible, e.g., the maximum over the absolute value of the lower and upper bound of each \(P_t\).

    Best regards, 
    Jaromił

    0
  • Michael Schäffer
    Gurobi-versary
    First Comment
    First Question

    Hi Jaromił,

    thanks for the quick reply and the detailed answer! I'm running it right now and it seems to be faster.

    However, the run time is still in the hours range. Maybe the model became just too complex when I turned it into a MIP problem.

    Thanks anyway!

    Michael

    0
  • Jaromił Najman
    Gurobi Staff Gurobi Staff

    Hi Michael,

    However, the run time is still in the hours range. Maybe the model became just too complex when I turned it into a MIP problem.

    This is indeed very likely the case. By fixing the \(eta_t\) variables, you also remove all corresponding binary variable and thus also all combination of those reducing the search space by a good bit (depending on the cardinality of the \(t\) index). You might want to try to construct a smaller model first and trying to finding tuning parameter by using Gurobi's parameter tuning tool. These parameters may then help and improve performance of the bigger model.

    Best regards, 
    Jaromił

    0

Please sign in to leave a comment.