Originally posted by: SystemAdmin
I don't get it. How do expect an expression containing squares to be linear?
Or is your only problem that the summed squares can no longer be represented as an instance of IloLinearNumExpr?
Here is a quick snippet to create your objective function:
import ilog.cplex.*;
import ilog.concert.*;
public final class Square {
public static void main(String[] args) {
try {
IloCplex model = new IloCplex();
IloNumVar X[] = model.numVarArray(1000, -11, 11);
IloNumVar E[] = model.numVarArray(200, -10, 10);
IloNumVar absE[] = model.numVarArray(200, 0, 10);
for (int i = 0; i < E.length; ++i) {
model.addLe(model.prod( 1.0, E[i]), absE[i]);
model.addLe(model.prod(-1.0, E[i]), absE[i]);
}
model.addMinimize(model.sum(model.scalProd(X, X),
model.sum(absE)));
model.end();
} catch (IloException e) {
System.err.println("Got exception: " + e.getMessage());
}
}
}
Handling absolute values was already discussed
here. Note that since you already have squares in your objective function you may also try to model the absolute-value terms as squares
#CPLEXOptimizers#DecisionOptimization