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

Setting objective for absolute error minimization

回答済み

コメント

3件のコメント

  • 正式なコメント
    Simranjit Kaur
    • Gurobi Staff 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 why not try our AI Gurobot?.
  • Eli Towle
    • Gurobi Staff Gurobi Staff

    Hi Buddi,

    The Model.addGenConstrAbs() method uses two Var objects as its arguments. Similarly, the abs_() function accepts a single Var object as its argument. So, the first step is to introduce auxiliary variables (say, z[t]) that represent the expressions inside the absolute value functions. E.g.:

    model.addConstr(z[t] == quicksum(Unit[r, t] for v in Readings) - set_point)

    Then, you can add the absolute value constraint in one of two ways:

    model.addConstr(error[t] == abs_(z[t])) # method 1
    model.addGenConstrAbs(error[t], z[t]) # method 2

    Also, note that the quicksum function you use sums over v in Readings, but v is never used. Perhaps this should be r?

    I hope this helps!

    1
  • Charitha Buddhika Heendeniya
    • Gurobi-versary
    • Conversationalist
    • Curious

    Dear Eli,

    Thank you for your answer. It really helps. I didn't realize that addGenConstrAbs() has two arguments :)

    And yes, you are right, there is a typo in my post. 

    Thank you again,

    Buddi

    0

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