Setting objective for absolute error minimization
回答済みDear community,
I'm trying to set an objective function that minimizes the absolute value of the accumulated error of a control strategy.
So I tried,
model.addGenConstrAbs(error[t] == abs_(quicksum(Unit[r, t] for v in Readings) - set_point))
This returns
AttributeError: 'TempConstr' object has no attribute '__colno__'
Can you please advise me to fix this problem?
Best regards
Buddi
-
正式なコメント
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?. -
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 2Also, 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 -
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
投稿コメントは受け付けていません。
コメント
3件のコメント