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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

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 <strong>ILOG</strong>.CONCERT.Exception("inconsistent data in file "+ filename);if ( nNutrs != nutrMin.Length ||nNutrs != nutrPerFood.Length )throw new <strong>ILOG</strong>.CONCERT.Exception("inconsistent data in file "+ filename);for (int i = 0; i < nNutrs; ++i) {if ( nutrPerFood[i].Length != nFoods )throw new <strong>ILOG</strong>.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 classDiet.Data. Its constructor requires a file name as an argument. Using an object of the classInputDataReader, your application reads the data from that file.ModelThis example was chosen because it is simple enough to be viewed by rows as well as bycolumns. Both ways are implemented in the finished application. In this example, eitherperspective can be viewed as natural. Only one approach will seem natural for many models,but there is no general way of deciding which is more appropriate (rows or columns) in aparticular case.100 <strong>ILOG</strong> <strong>CPLEX</strong> <strong>11.0</strong> — USER’ S MANUAL

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

Saved successfully!

Ooh no, something went wrong!