Exemple #1
0
   internal static void BuildModelByRow(IModeler   model,
                                        Data       data,
                                        INumVar[]  Buy,
                                        NumVarType type) {
      int nFoods = data.nFoods;
      int nNutrs = data.nNutrs;

      for (int j = 0; j < nFoods; j++) {
         Buy[j] = model.NumVar(data.foodMin[j], data.foodMax[j], type);
      }
      model.AddMinimize(model.ScalProd(data.foodCost, Buy));

      for (int i = 0; i < nNutrs; i++) {
         model.AddRange(data.nutrMin[i],
                        model.ScalProd(data.nutrPerFood[i], Buy),
                        data.nutrMax[i]);
      }
   }
Exemple #2
0
    internal static void BuildModelByRow(IModeler model,
                                         Data data,
                                         INumVar[]  Buy,
                                         NumVarType type)
    {
        int nFoods = data.nFoods;
        int nNutrs = data.nNutrs;

        for (int j = 0; j < nFoods; j++)
        {
            Buy[j] = model.NumVar(data.foodMin[j], data.foodMax[j], type);
        }
        model.AddMinimize(model.ScalProd(data.foodCost, Buy));

        for (int i = 0; i < nNutrs; i++)
        {
            model.AddRange(data.nutrMin[i],
                           model.ScalProd(data.nutrPerFood[i], Buy),
                           data.nutrMax[i]);
        }
    }