> Discrete Optimization > Transport: Piecewise Linear Optimization > Developing a Model > Adding an Objective

The objective is to minimize costs of supplying cars from factories to showrooms, It is added to the model in these lines:

    IloExpr obj(env);
    for(i = 0; i < nbSupply; i++){
      obj += IloSum(y[i]);
    }

    model.add(IloMinimize(env, obj));