Gurobi adds to objective although setObjective wasnt called
回答済みI have multiple classes for different devices (like house, battery, heat pump etc), each class sets constraints and variables and writes it to a file (.mps), which gets read by the next class and so on.
Some of my classes add some variables, like below, to the objective which I obtained from the debug.lp which i write for debugging after every class.
Minimize
0 Q_demand_house[1] + 0 Q_demand_house[2] + 0 Q_demand_house[3]
+ 0 Q_demand_house[4] + 0 Q_demand_house[5] + 0 Q_demand_house[6]
+ 0 Q_demand_house[7] + 0 Q_demand_house[8] + 0 Q_demand_house[9]
In the end I set the objective (example code)
model.setObjective(u_hp[0] + u_hp[1],gp.GRB.MINIMIZE)
but the debug.lp shows the following:
Minimize
u_hp[0] + u_hp[1]
+ 0 Q_demand_house[0] + 0 Q_demand_house[1] + 0 Q_demand_house[2]
+ 0 Q_demand_house[3] + 0 Q_demand_house[4] + 0 Q_demand_house[5]
+ 0 Q_demand_house[6] + 0 Q_demand_house[7] + 0 Q_demand_house[8]
+ 0 Q_demand_house[9]
Why does this happen, how can I prevent it?
-
正式なコメント
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?. -
So, you are interested in why some variables appear with an objective coefficient of 0 in the LP file?
The reason is one particular aspect of the LP file format. Namely, if you have variables that do not appear in any of the constraints and that have the standard lower bound of zero and the standard upper bound of infinity, then these variables would not appear at all in the LP file. Hence, reading back in such an LP file would lose those variables. Thus, to make sure that they don't get lost, we add them to the objective function.
Regards,
Tobias
0 -
Thanks for your response :)
0
投稿コメントは受け付けていません。
コメント
3件のコメント