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

How to multiply two linear expressions in java

回答済み

コメント

3件のコメント

  • 正式なコメント
    Simranjit Kaur
    • Gurobi Staff
    This post is more than two 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.
  • Silke Horn
    • Gurobi Staff

    Hi,

    You are right that GRBQuadExpr.addTerm only accepts variables, not complex expressions.

    There are two ways around this:

    • You expand the quadratic expression yourself, i.e., \((K+x+y)^2 = K^2 + x^2 + y^2 + 2Kx + 2Ky + 2xy\), and then build the resulting expression using addTerm.
    • You introduce an auxiliary variable, say \$a\$, and add a constraint that \(a == q\). Then you can use this variable to build our objective expression.
    0
  • WAFA NAFKHA
    • Gurobi-versary
    • First Question
    • First Comment

    Hi,

    Thanks for your response.

    Before asking, I was using the first method, but in my thesis the objectif function will be more complicated and  I'm looking for better method.

    I'll implement your second solution, if i well understand :

    objectif function will be min a^2 , a is a variable and add a new constraint a == K + x + y

    Best regards

    0

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