Find minimal between Gurobi expression and one value
回答済みDear Folks,
I am using Gurobi with C++ in VS.
I need to choose a value for one Gurobi expression between zero and another Gurobi expression that can have a negative value as result, the latter contains one Gurobi variable, which was the way to make Optimization influence in this decision.
I tried two approaches, but both were not accepted ( I am not sure if this syntax fits C++):
GRBLinExpr *genCH= new GRBLinExpr[T];
GRBQuadExpr savings_bat = 0;
for (t = 0; t < T; t++) {
for (gen = 0; gen < n; gen++) {
genCH[t] +=- Pp[gen][t];
model.addConstr(savings_bat,min_(genCH[t], 0)); //Approach 1
savings_bat = model.addGenConstrMin(genCH[t], 0, t, "mincnstr"); //Approach 2
}
}
I have already read these two articles :
https://www.gurobi.com/documentation/9.5/refman/py_min_.html ( just available for Python, ?);
Thanks in advance.
BR,
-
正式なコメント
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. -
You are using the Python documentation, which is not compatible with C++. You should have a look at the C++ documentation of the addGenConstrMin method. The genconstr_c++ and workforce5_c++ examples show how to use the addGenConstrMin method.
Best regards,
Jaromił0
投稿コメントは受け付けていません。
コメント
2件のコメント