Two Expressions for one objective function in Gurobi

111 views Asked by At

With Gurobi (Java), is it possible to write two expressions for one objective function so that only the objective function is subsequently optimized?

More precisely: I have the following objective function:

f = -(a-b)

Both a and b contain my optimization variable. Since the terms are not quite trivial, I am considering splitting both. However, they are not to be optimized individually, but only the objective function (and thus the difference) is to be minimized. Thus, in my opinion, the possibility of multiple objectives falls out, but I can also be wrong. Maybe someone can help me.

Thanks a lot

1

There are 1 answers

8
Erwin Kalvelagen On

You can use a Java variable holding a LinExpr for a and b.

Or you can create extra constraints and decision variables. The overhead of adding a few extra constraints and decision variables is very small. This has the advantage you can see a and b in lp and solution files.