> Languages and APIs > ILOG Concert Technology for C#.NET Users > Describe

The aim of this tutorial is build a simple application with ILOG CPLEX and Concert Technology for .NET users. The tutorial is based on the well known diet problem: to minimize the cost of a daily diet that satisfies certain nutritional constraints. The conventional statement of the problem assumes data indicating the cost and nutritional value of each available food.

The finished application 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 (for example, 10 carrots). Otherwise, the application searches for a solution expressed in continuous variables (for example, 1.7 kilos of carrots). Option -c can be used to build the model by columns. Otherwise, the application builds the model by rows.

The finished application starts by evaluating the command line arguments and reading the input data file. The input data for this example is the same data as for the corresponding C++ and Java examples in this manual. The data is available in the standard distribution at:

yourCPLEXhome\examples\data\diet.dat

Step 1   -  

Describe the Problem

Write a natural language description of the problem and answer these questions:

What is known?

The amount of nutrition provided by a given quantity of a given food.

The cost per unit of food.

The upper and lower bounds on the foods to be purchased for the diet

What are the unknowns?

The quantities of foods to buy.

What are the constraints?

The food bought to consume must satisfy basic nutritional requirements.

The amount of each food purchased must be within its bounds

What is the objective?

Minimize the cost of food to buy

Step 2   -  

Open the file

Open the file yourCPLEXhome\examples\src\tutorials\Dietlesson.cs in your integrated development environment, such as Microsoft Visual Studio. Then go to the comment Step 2 in Dietlesson.cs, and add the following lines to declare a class, a key element of this application.

public class Diet {
   internal class Data {
      internal int nFoods;
      internal int nNutrs;
      internal double[]   foodCost;
      internal double[]   foodMin;
      internal double[]   foodMax;
      internal double[]   nutrMin;
      internal double[]   nutrMax;
      internal double[][] nutrPerFood;

      internal Data(string filename) {
         InputDataReader reader = new InputDataReader(filename);

         foodCost = reader.ReadDoubleArray();
         foodMin  = reader.ReadDoubleArray();
         foodMax  = reader.ReadDoubleArray();
         nutrMin  = reader.ReadDoubleArray();
         nutrMax  = reader.ReadDoubleArray();
         nutrPerFood = reader.ReadDoubleArrayArray();
         nFoods = foodMax.Length;
         nNutrs = nutrMax.Length;

         if ( nFoods != foodMin.Length  ||
              nFoods != foodMax.Length    )
            throw new ILOG.CONCERT.Exception("inconsistent data in file "
                                             + filename);
         if ( nNutrs != nutrMin.Length    ||
              nNutrs != nutrPerFood.Length  )
            throw new ILOG.CONCERT.Exception("inconsistent data in file "
                                             + filename);
         for (int i = 0; i < nNutrs; ++i) {
            if ( nutrPerFood[i].Length != nFoods )
               throw new ILOG.CONCERT.Exception("inconsistent data in file "
                                             + filename);
         }
      }
   }

The input data of the diet problem is read from a file into an object of the nested class Diet.Data. Its constructor requires a file name as an argument. Using an object of the class InputDataReader, your application reads the data from that file.