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

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

回答済み

コメント

3件のコメント

  • 正式なコメント
    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 try Gurobot, our chatbot interface offering instant, expert-level support.
  • 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

    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

投稿コメントは受け付けていません。