Skip to main content

Quadratic Programming (QP)with gurobipy,why the answer is wrong?

Answered

Comments

2 comments

  • Haury Miao
    • Gurobi-versary
    • First Comment
    • First Question

    So it is because I forget to add the LB and UB in the definition of the decision variable x?

    0
  • Eli Towle
    • Gurobi Staff Gurobi Staff

    By default, variables added to the model with Model.addMVar(), Model.addVar(), and Model.addVars() have a lower bound of \( 0 \) and no upper bound.

    If you specify your lower and upper bounds on \( x \) by adding \( \texttt{lb=a} \) and \( \texttt{ub=b} \) to your call to Model.addMVar(), you obtain the expected optimal solution:

    obj= -1.0
    C0 : -0.5
    C1 : -0.5
    C2 : -0.5
    C3 : -0.5
    0

Please sign in to leave a comment.