org.jacop.examples.fd

## Class Diet

• ```public class Diet
extends ExampleFD```
It specifies a simple diet problem.

Problem from http://www.mcs.vuw.ac.nz/courses/OPRE251/2006T1/Labs/lab09.pdf

My diet requires that all the food I eat come from one of the four .basic food groups. (chocolate cake, ice cream, soft drink, and cheesecake). Each (large) slice of chocolate cake costs 50c, each scoop of chocolate ice cream costs 20c, each bottle of cola costs 30c, and each piece of pineapple cheesecake costs 80c.

Each day, I must ingest at least 500 calories, 6 oz of chocolate, 10 oz of sugar, and 8 oz of fat. The nutritional content per unit of each food is shown in the table below.

Formulate a linear programming model that can be used to satisfy my daily nutritional requirement at minimum cost.

Type of Calories Chocolate Sugar Fat Food (ounces) (ounces) (ounces) Chocolate Cake (1 slice) 400 3 2 2 Chocolate ice cream (1 scoop) 200 2 2 4 Cola (1 bottle) 150 0 4 1 Pineapple cheesecake (1 piece) 500 0 4 5

"""

Version:
4.9

Compare with my MiniZinc model: http://www.hakank.org/minizinc/diet1.mzn

Author:
Hakan Kjellerstrand (hakank@bonetmail.com) and Radoslaw Szymanek
• ### Field Summary

Fields
Modifier and Type Field and Description
`String[]` `food`
`String[]` `ingredients`
`int[]` `limits`
`int` `m`
`int[][]` `matrix`
`int` `n`
`int[]` `price`
`IntVar[]` `x`
• ### Fields inherited from class org.jacop.examples.fd.ExampleFD

`cost, search, store, vars`
• ### Constructor Summary

Constructors
Constructor and Description
`Diet()`
• ### Method Summary

All Methods
Modifier and Type Method and Description
`static void` `main(String[] args)`
It executes the program optimizing the diet.
`void` `model()`
Imposes the model of the problem.
`void` `modelKnapsack()`
Imposes the model of the problem.
`static void` `printLastSolution(Diet diet)`
• ### Methods inherited from class org.jacop.examples.fd.ExampleFD

`creditSearch, getSearch, getSearchVariables, getStore, printMatrix, search, searchAllAtOnce, searchAllOptimal, searchLDS, searchMasterSlave, searchMaxRegretOptimal, searchMiddle, searchMostConstrainedStatic, searchOptimal, searchSmallestDomain, searchSmallestMedian, searchSmallestMiddle, searchSmallestMin, searchWeightedDegree, searchWithMaxRegret, searchWithRestarts, shavingSearch`
• ### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
• ### Field Detail

• #### x

`public IntVar[] x`
• #### n

`public int n`
• #### m

`public int m`
• #### food

`public String[] food`
• #### ingredients

`public String[] ingredients`
• #### price

`public int[] price`
• #### limits

`public int[] limits`
• #### matrix

`public int[][] matrix`
• ### Constructor Detail

• #### Diet

`public Diet()`
• ### Method Detail

• #### model

`public void model()`
Imposes the model of the problem.
Specified by:
`model` in class `ExampleFD`
• #### modelKnapsack

`public void modelKnapsack()`
Imposes the model of the problem.
• #### printLastSolution

`public static void printLastSolution(Diet diet)`
• #### main

`public static void main(String[] args)`
It executes the program optimizing the diet.
Parameters:
`args` - no argument is used.