Solving the Diet Model with the Java API

The problem solved in this example is to minimize the cost of a diet that satisfies certain nutritional constraints, which were described earlier in this chapter. This example was chosen because it is simple enough to be viewed from a row as well as from a column perspective. Both ways are shown in the example.

In this example either perspective can be viewed as natural. Only one approach will seem natural for many models, but there is no general way of determining which is more appropriate in a particular case.

The example accepts a filename and two options -c and -i as command line arguments. Option -i allows you to create a MIP model where the quantities of foods to purchase must be integers. Option -c can be used to build the model by columns.

The example starts by evaluating the command line arguments and reading the input data file. The input data of the dietary problem is read from a file using an object of the embedded class Diet.Data. Its constructor requires a file name as parameter from which it reads the data using class InputDataReader. This class is distributed with the examples but will not be described here as it does not make use of any ILOG CPLEX or Concert Technology functionality.


Previous Page: Modeling by Column  Return to Top Next Page: Creating the Optimizer