> Discrete Optimization > Transport: Piecewise Linear Optimization > Developing a Model > Checking Convexity and Concavity

To illustrate the ideas of convex and concave piecewise linear functions, two tables of costs that vary according to the quantity of cars shipped were introduced in the problem description. To accommodate those two tables in the model, the following lines are added.

    if (convex) {
      for(i = 0; i < nbSupply; i++){
        for(j = 0; j < nbDemand; j++){
          model.add(y[i][j] == IloPiecewiseLinear(x[i][j],
                                        IloNumArray(env, 2, 200., 400.),
                                        IloNumArray(env, 3, 30., 80., 130.),
                                        0, 0));
        }
      }
    }else{
      for(i = 0; i < nbSupply; i++){
        for(j = 0; j < nbDemand; j++){
          model.add(y[i][j] == IloPiecewiseLinear(x[i][j],
                                        IloNumArray(env, 2, 200., 400.),
                                        IloNumArray(env, 3, 120., 80., 50.),
                                        0, 0));
        }
      }
    }