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.

IloObjective obj = cplex.add(cplex.maximize(expr));Not only do the addConstrucorName methods simplify the program, they are also moreefficient than the two equivalent calls because an intermediate copy can be avoided.Building the ModelAll the building blocks are now in place to implement a method that creates a model. Thediet problem consists of finding the least expensive diet using a set of foods such that allnutritional requirements are satisfied. The example in this chapter builds the specific dietmodel, chooses an optimizing algorithm, and shows how to access more detailedinformation about the solution.The example includes a set of foods, where food j has a unit cost of foodCost[j]. Theminimum and maximum amount of food j which can be used in the diet is designatedfoodMin[j] and foodMax[j], respectively. Each food j also has a nutritional valuenutrPerFood[i][j] for all possible nutrients i. The nutritional requirement states that inthe diet the amount of every nutrient i consumed must be within the bounds nutrMin[i]and nutrMax[i].Mathematically, this problem can be modeled using a variable Buy[j] for each food jindicating the amount of food j to buy for the diet. Then the objective is:minimize ∑ j (Buy[j] * foodCost[j])The nutritional requirements mean that the following conditions must be observed; that is,for all i:nutriMin[i] ≤ ∑ i nutrPerFood[i][j] * Buy[j] ≤ nutriMax[i]Finally, every food must be within its bounds; that is, for all j:foodMin[j] ≤ Buy[j] ≤ foodMax[j]<strong>ILOG</strong> <strong>CPLEX</strong> <strong>11.0</strong> — USER’ S MANUAL 79

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

Saved successfully!

Ooh no, something went wrong!