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

Quadratic function as objective function

回答済み

コメント

5件のコメント

  • 正式なコメント
    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.
  • Jonasz Staszek
    • Community Moderator
    • Gurobi-versary
    • Thought Leader
    • First Question

    You seem to be using the matrix expressions for \(v\) and \(x\), is this correct? If yes, you need to define your objective as MQuadExpr.

    If you store your variables and parameters in (tuple)dicts, this example should shed some light.

    Best regards
    Jonasz

    1
  • Fatima Ezzahra El habibi
    • Gurobi-versary
    • First Comment
    • First Question

    Thank you for your answer Jonasz. 

    Could you explain how I can use MQuadExpr in my case? I didn't understand how to write the code..

    0
  • Jonasz Staszek
    • Community Moderator
    • Gurobi-versary
    • Thought Leader
    • First Question

    Assuming \(x\) corresponds to the variable matrix and \(v\) to some coefficients, I'd imagine the following to work:

    model.setObjective(x @ v @ x, GRB.MAXIMIZE)

    Best regards
    Jonasz

    1
  • Fatima Ezzahra El habibi
    • Gurobi-versary
    • First Comment
    • First Question

    Thank you!!

    Kind regards.

    Fatima

    0

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