Error in non-convex quadratic constraints

Answered

Comments

4 comments

  • Eli Towle

    \( \texttt{Fi} \), \(\texttt{a_WW_CHP}\), and \( \texttt{a_YF_GDS} \) are all variables. Gurobi supports constraints containing bilinear terms like \(u = x \cdot y \), but not more general multilinear terms like \( u = x \cdot y \cdot z \). For more information, see What types of models can Gurobi solve?.

    As written, the \( \texttt{c0} \) constraint is not quadratic. Do you really want to multiply three variables together? If so, you can model this constraint using a series of bilinear constraints. This approach is described in detail in the article How do I model multilinear terms in Gurobi?.

    There is another issue with \( \texttt{c0} \): the left-hand side evaluates to a scalar value, but \( \texttt{P_e_vect_d_1[t-1]} \) (the right-hand side) is an array. You will encounter an "Invalid argument to QuadExpr addition" error when you try to add a constraint that a quadratic expression is equal to an array, as it's not clear what this means.

    Both of these issues are also present in constraints \( \texttt{c1} \) and \( \texttt{c2} \).

    1
    Comment actions Permalink
  • Julio César Ortegón

    Thank you very mucho for the insight, however regarding the issue with the right side of the term in the first three constraints (P_e_vect_d_1[t-1], in c0) I know I declare it as a vector but it is evaluated at it's t-1 term which is an scalar, is there a problem by doing it this way or should declare a previous variable like a = P_e_vect_d_1[t-1] and then that variable use it in the right side of the constraint. 

     

    0
    Comment actions Permalink
  • Eli Towle

    Your current approach would be fine, except you convert \( \texttt{P_e_vect_d_1} \) to a two-dimensional array with the line

    P_e_vect_d_1 = np.array([P_e_vect_d_1])

    If you print \( \texttt{P_e_vect_d_1[0]} \) (or its type) after this line, you'll see it's an array.

    1
    Comment actions Permalink
  • Julio César Ortegón

    I understand, thanks a lot for the help.

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk