Modeling by rows
Java methods support modeling by rows in this example of a Java application of CPLEX.
The method populateByRow
creates the model by adding the finished constraints
and objective function to the active model, one by one. It does so by first creating the variables
with the method IloCplex.numVarArray(ilog.concert.IloColumnArray cols, double[] lb,
double[]
ub)
. Then the minimization objective function is created and added to the active model with the method
IloCplex
.addMinimize. The expression that defines the objective
function is created by a method, IloCplex.scalProd(double[] vals, ilog.concert.IloNumVar[]
vars)
.
, that forms a scalar product using an array of objective coefficients times the array of variables.
Finally, each of the two constraints of the model are created and added to the active model with the
method IloCplex.addLe(double v, ilog.concert.IloNumExpr
e)
.
For building the constraint expression, the methods IloCplex.sum(double v,
ilog.concert.IloNumExpr e1)
and
IloCplex.prod(double v, ilog.concert.IloNumExpr
e1)
are used, as a contrast to the approach used in constructing the objective function.