12.07.2015 Views

ILOG CPLEX 11.0 User's Manual

ILOG CPLEX 11.0 User's Manual

ILOG CPLEX 11.0 User's Manual

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Example: Optimizing the Diet Problem in C++The optimization problem solved in this example is to compose a diet from a set of foods, sothat the nutritional requirements are satisfied and the total cost is minimized. ProblemRepresentation on page 65 describes the problem.The example ilodiet.cpp illustrates these procedures:◆ Creating a Model Row by Row on page 65;◆ Creating a Model Column by Column on page 66.To continue this example, Application Description on page 67 outlines the structure of theapplication. The following sections explain more about data structures useful in thisapplication.◆ Creating Multi-Dimensional Arrays with IloArray on page 67;◆ Using Arrays for Input/Output on page 67;◆ Solving the Model with IloCplex on page 69.Notes about the application are available in Complete Program on page 70.Problem RepresentationThe problem contains a set of foods, which are the modeling variables; a set of nutritionalrequirements to be satisfied, which are the constraints; and an objective of minimizing thetotal cost of the food. There are two ways of looking at this problem:◆The problem can be modeled by rows, by entering the variables first and then adding theconstraints on the variables and the objective function.◆ The problem can be modeled by columns, by constructing a series of empty constraintsand then inserting the variables into the constraints and the objective function.Concert Technology is equally suited for both kinds of modeling; in fact, you can even mixboth approaches in the same program. If a new food product is created, you can create a newvariable for it regardless of how the model was originally built. Similarly, if a new nutrient isdiscovered, you can add a new constraint for it.Creating a Model Row by RowYou walk into the store and compile a list of foods that are offered. For each food, you storethe price per unit and the amount in stock. For some foods that you particularly like, you alsoset a minimum amount you would like to use in your diet. Then, for each of the foods, youcreate a modeling variable to represent the quantity to be purchased for your diet.Now you get a nutrition book and look up which nutrients are known and relevant for you.For each nutrient, you note the minimum and maximum amounts that should be found in<strong>ILOG</strong> <strong>CPLEX</strong> <strong>11.0</strong> — USER’ S MANUAL 65

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!