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.

may be on or off (producing or not producing power). When a generator is on, it producespower between its minimum and maximum level, and each generator has its own minimumand maximum levels. The cost for producing a unit of output differs for each generator aswell. The aim of the problem is to satisfy demand for power while minimizing cost in thebest way possible.Representing the ProblemAs input for this example, you need such data as the minimum and maximum output levelfor each generator. The application will use Concert Technology arrays minArray andmaxArray for that data. It will read data from a file into these arrays, and then learn theirlength (that is, the number of generators available) by calling the method getSize.The application also needs to know the cost per unit of output for each generator. Again, aConcert Technology array, cost, serves that purpose as the application reads data in from afile with the operator >>.The application also needs to know the demand for power, represented as a numeric variable,demand.Building a ModelAfter the application creates an environment and a model in that environment, it is ready topopulate the model with extractable objects pertinent to the problem.It represents the production level of each generator as a semi-continuous variable. In thatway, with the value 0 (zero), the application can accommodate whether the generator is on oroff; with the semi-continuous lower bound of each variable, it can indicate the minimumlevel of output from each generator; and indicate the maximum level of output for eachgenerator by the upper bound of its semi-continuous variable. The following lines create thearray production of semi-continuous variables (one for each generator), like this:IloNumVarArray production(env);for (IloInt j = 0; j < generators; ++j)production.add(IloSemiContVar(env, minArray[j], maxArray[j]));The application adds an objective to the model to minimize production costs in this way:mdl.add(IloMinimize(env, IloScalProd(cost, production)));It also adds a constraint to the model: it must meet demand.mdl.add(IloSum(production) >= demand);<strong>ILOG</strong> <strong>CPLEX</strong> <strong>11.0</strong> — USER’ S MANUAL 335

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!