// The following method populates the problem with data for the
    // following linear program:
    //
    //    Maximize
    //     x1 + 2 x2 + 3 x3
    //    Subject To
    //     - x1 + x2 + x3 <= 20
    //     x1 - 3 x2 + x3 <= 30
    //    Bounds
    //     0 <= x1 <= 40
    //    End
    //
    // using the IModeler API

    internal static void PopulateByRow(IModeler model,
                                       INumVar[][] var,
                                       IRange[][] rng)
    {
        double[]  lb      = { 0.0, 0.0, 0.0 };
        double[]  ub      = { 40.0, System.Double.MaxValue, System.Double.MaxValue };
        string[]  varname = { "x1", "x2", "x3" };
        INumVar[] x       = model.NumVarArray(3, lb, ub, varname);
        var[0] = x;

        double[] objvals = { 1.0, 2.0, 3.0 };
        model.AddMaximize(model.ScalProd(x, objvals));

        rng[0]    = new IRange[2];
        rng[0][0] = model.AddLe(model.Sum(model.Prod(-1.0, x[0]),
                                          model.Prod(1.0, x[1]),
                                          model.Prod(1.0, x[2])), 20.0, "c1");
        rng[0][1] = model.AddLe(model.Sum(model.Prod(1.0, x[0]),
                                          model.Prod(-3.0, x[1]),
                                          model.Prod(1.0, x[2])), 30.0, "c2");
    }
    // The following method populates the problem with data for the
    // following linear program:
    //
    //    Maximize
    //     x1 + 2 x2 + 3 x3
    //    Subject To
    //     - x1 + x2 + x3 <= 20
    //     x1 - 3 x2 + x3 <= 30
    //    Bounds
    //     0 <= x1 <= 40
    //    End
    //
    // using the IModeler API
    internal static void PopulateByRow(IModeler model,
                             INumVar[][] var,
                             IRange[][] rng)
    {
        double[]    lb      = {0.0, 0.0, 0.0};
          double[]    ub      = {40.0, System.Double.MaxValue, System.Double.MaxValue};
          string[]    varname = {"x1", "x2", "x3"};
          INumVar[] x       = model.NumVarArray(3, lb, ub, varname);
          var[0] = x;

          double[] objvals = {1.0, 2.0, 3.0};
          model.AddMaximize(model.ScalProd(x, objvals));

          rng[0] = new IRange[2];
          rng[0][0] = model.AddLe(model.Sum(model.Prod(-1.0, x[0]),
                                        model.Prod( 1.0, x[1]),
                                        model.Prod( 1.0, x[2])), 20.0, "c1");
          rng[0][1] = model.AddLe(model.Sum(model.Prod( 1.0, x[0]),
                                        model.Prod(-3.0, x[1]),
                                        model.Prod( 1.0, x[2])), 30.0, "c2");
    }