メインコンテンツへスキップ

How do i solve two non linear constraints that depend on one another?

回答済み

コメント

1件のコメント

  • Jaromił Najman
    • Gurobi Staff

    Hi Gatta,

    Your implementation is correct and the behavior you see is not unusual. The constraints you modeled are nonconvex and high dimensional. Still, maybe there is something to improve here.

    You set the lower bound of your \(\texttt{p}\) variables to \(0\).

    p=m.addVars(time,lb=0,vtype=GRB.CONTINUOUS)

    Theoretically, you allow for division by \(0\). Your formulation does not allow for it because you use multiplication but you are actually interested in the division. If you are sure that at least one of the \(\texttt{p}\) variables is strictly \(> 0\), then it is usually OK and should not lead to numerical difficulties. However, there are cases where it might be beneficial to actually provide a strictly positive lower bound.

    You definitely should provide tight finite upper bounds for all variables. Relaxing constraints of the type you present without bounds (or very loose bounds) is often not possible and results in a vast B&B tree. It would be best if you can derive some tight valid bounds from the application you are modeling and it would be even better if you can tighten these bounds even further manually by some specific problem knowledge.

    You could try eliminating the constraint

    m.addConstr(qc[s,t]*p[t]==l,name="Constraint6_{}_{}".format(s,t))

    by substituting \(\texttt{qc[s,t]}\) into

    m.addConstr(h_time[s]*qc[s,t]-k==0,name="Constraint5_{}_{}".format(s,t))

    which would give

    m.addConstr(h_time[s]*p[t]-k*l==0,name="Constraint_new_{}_{}".format(s,t))

    Here, there are multiple options to consider. You could drop constraints 5 and 6 and only use the new constraint. You could also drop only one of the constraints and add the new constraint or you could keep both constraints 5 and 6 and add the additional nonconvex new constraint. It is hard to tell which option would perform best here so it is something you could experiment with.

    There is also an alternative where you use constraint 5 to substitute \(\texttt{qc[s,t]}\) into constraint 6 to get

    m.addConstr(k*p[t]==l*h_time[s],name="Constraint_new2_{}_{}".format(s,t))

    There is quite a bit to experiment here but nothing can be said a priori about the performance of each reformulation.

    I hope this helps.

    Best regards, 
    Jaromił

    0

サインインしてコメントを残してください。