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.

then <strong>ILOG</strong> <strong>CPLEX</strong> will carry out such transformations automatically if you set theNetFind parameter appropriately.Preprocessing and the Network OptimizerIf your LP problem includes network structures, there is a possibility that <strong>ILOG</strong> <strong>CPLEX</strong>preprocessing may eliminate those structures from your model. For that reason, you shouldconsider turning off preprocessing before you invoke the network optimizer on a problem.Example: Using the Network Optimizer with the Callable Library netex1.cIn the standard distribution of <strong>ILOG</strong> <strong>CPLEX</strong>, the file netex1.c contains code that creates,solves, and displays the solution of the network-flow problem illustrated in Figure 11.1 onpage 220.Briefly, the main function initializes the <strong>ILOG</strong> <strong>CPLEX</strong> environment and creates theproblem object; it also calls the optimizer to solve the problem and retrieves the solution.In detail, main first calls the Callable Library routine CPXopen<strong>CPLEX</strong>. As explained inInitialize the <strong>ILOG</strong> <strong>CPLEX</strong> Environment on page 111, CPXopen<strong>CPLEX</strong> must always be thefirst <strong>ILOG</strong> <strong>CPLEX</strong> routine called in a <strong>ILOG</strong> <strong>CPLEX</strong> Callable Library application. Thoseroutines create the <strong>ILOG</strong> <strong>CPLEX</strong> environment and return a pointer (called env) to it. Thispointer will be passed to every Callable Library routine. If this initialization routine fails,env will be NULL and the error code indicating the reason for the failure will be written tostatus. That error code can be transformed into a string by the Callable Library routineCPXgeterrorstring.After main initializes the <strong>ILOG</strong> <strong>CPLEX</strong> environment, it uses the Callable Library routineCPXsetintparam to turn on the <strong>ILOG</strong> <strong>CPLEX</strong> screen indicator parameterCPX_PARAM_SCRIND so that <strong>ILOG</strong> <strong>CPLEX</strong> output appears on screen. If this parameter isturned off, <strong>ILOG</strong> <strong>CPLEX</strong> does not produce viewable output, neither on screen, nor in a logfile. It is a good idea to turn this parameter on when you are debugging your application.The Callable Library routine CPXNETcreateprob creates an empty problem object, that is,a minimum-cost network-flow problem with no arcs and no nodes.The function buildNetwork populates the problem object; that is, it loads the problem datainto the problem object. Pointer variables in the example are initialized as NULL so that youcan check whether they point to valid data (a good programming practice). The mostimportant calls in this function are to the Callable Library routines, CPXNETaddnodes,which adds nodes with the specified supply values to the network problem, andCPXNETaddarcs, which adds the arcs connecting the nodes with the specified objectivevalues and bounds. In this example, both routines are called with their last argument NULLindicating that no names are assigned to the network nodes and arcs. If you want to namearcs and nodes in your problem, pass an array of strings instead.<strong>ILOG</strong> <strong>CPLEX</strong> <strong>11.0</strong> — USER’ S MANUAL 223

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

Saved successfully!

Ooh no, something went wrong!