Sum of all PWL in objective function (Python gurobi)
回答済みHello everybody,
So I am solving a LP problem which objective function consists of only PWL functions ( added with model.setPWLObj() ). Now I would like to add a constraint such that the sum of all the PWL functions is equal to a value.
If they were not PWL functions, an easy solution would be:
model.addConstr(sum(model.getObjective()) == X)
However, model.getPWLObjective() does not work in the same way. Any clue on how can I approach this?. I am thinking on defining extra variables such that:
x'i = PWL(xi) for all i
and this way i could solve:
max sum(x'1 + x'2 + ..... x'N) and define a constraint sum(x'1 + x'2 + ..... x'N) == X
But I don't really know how to implement this without the model.setPWLObj()
Thank you very much! :)
-
正式なコメント
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 Roger,
Your idea is the way to go in this case. If you want to work with the PWL functions outside of the objective function, you have to use the addGenConstrPWL() function and work with the auxiliary variables.
Best regards,
Jaromił0
投稿コメントは受け付けていません。
コメント
2件のコメント