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.

in demand; in terms of this model, the demand should meet the supply as well. Those ideasare represented as constraints added to the model, like this:for(i = 0; i < nbSupply; i++) { // supply must meet demandmodel.add(IloSum(x[i]) == supply[i]);}for(j = 0; j < nbDemand; j++) { // demand must meet supplyIloExpr v(env);for(i = 0; i < nbSupply; i++)v += x[i][j];model.add(v == demand[j]);v.end();}Checking Convexity and ConcavityTo illustrate the ideas of convex and concave piecewise linear functions, two tables of coststhat vary according to the quantity of cars shipped were introduced in the problemdescription. 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.0, 400.0),IloNumArray(env, 3, 30.0, 80.0, 130.0),0.0, 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.0, 400.0),IloNumArray(env, 3, 120.0, 80.0, 50.0),0.0, 0.0));}}}Adding an ObjectiveThe objective is to minimize costs of supplying cars from factories to showrooms, It is addedto the model in these lines:IloExpr obj(env);for(i = 0; i < nbSupply; i++){obj += IloSum(y[i]);}model.add(IloMinimize(env, obj));obj.end();346 <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!