Modeling by Rows

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 cplex.numVarArray(). 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(), 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. For building the constraint expression, the methods IloCplex.sum() and IloCplex.prod() are used, as a contrast to the approach used in constructing the objective function.


Previous Page: Building and Solving a Small LP Model in Java  Return to Top Next Page: Modeling by Columns