Hi,
I am trying to come up with the convex objective such that Gurobi solver can solve it. This has resulted in another alternative objective function given below:
minimize ((sum(_h)-sum(a*s)) + (sum(_w) - sum(b*s))), where _h and _w are the constant Java array, a and b are the decision variables defined as GRBVar array, and s is a scalar constant.
Since Gurobi recognises constructs that are defined through GRBVar, so I'm defining s as GRBVar, to be used in the Gurobi expressions, as following:
GRBVar s = m.addVar(300.0, 300.0, 300.0, GRB.INTEGER, "s");
And now rewriting the above objective as following Gurobi Java code:
GRBQuadExpr objQE = new GRBQuadExpr();
for (double value: _h) objQE.addConstant(value);
for (int i = 0; i < a.length; i++)
objQE.addTerm(-1.0, a[i], s);
for (double value: _w) objQE.addConstant(value);
for (int i = 0; i < b.length; i++)
objQE.addTerm(-1.0, b[i], s);
m.setObjective(objQE, GRB.MINIMIZE);
Can someone check the translation seems fine or has some issues?
Thanks in advance.
Bilal