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.

The function buildNetwork also includes a few routines that are not strictly necessary tothis example, but illustrate concepts you may find useful in other applications. To delete anode and all arcs dependent on that node, it uses the Callable Library routineCPXNETdelnodes. To change the objective sense to minimization, it uses the CallableLibrary routine CPXNETchgobjsen.Look again at main, where it actually calls the network optimizer with the Callable Libraryroutine, CPXNETprimopt. If CPXNETprimopt returns a nonzero value, then an error hasoccurred; otherwise, the optimization was successful. Before retrieving that solution, it isnecessary to allocate arrays to hold it. Then use CPXNETsolution to copy the solution intothose arrays. After displaying the solution on screen, write the network problem into a file,netex1.net in the NET file format.The TERMINATE: label is used as a place for the program to exit if any type of error occurs.Therefore, code following this label cleans up: it frees the memory that has been allocatedfor the solution data; it frees the network object by calling CPXNETfreeprob; and it freesthe <strong>ILOG</strong> <strong>CPLEX</strong> environment by calling CPXclose<strong>CPLEX</strong>. All freeing should be doneonly if the data is actually available. The Callable Library routine CPXclose<strong>CPLEX</strong> shouldalways be the last <strong>ILOG</strong> <strong>CPLEX</strong> routine called in a <strong>ILOG</strong> <strong>CPLEX</strong> Callable Libraryapplication. In other words, all <strong>ILOG</strong> <strong>CPLEX</strong> objects that have been allocated should befreed before the call to CPXclose<strong>CPLEX</strong>.The complete program netex1.c appears online in the standard distribution atyour<strong>CPLEX</strong>installation/examples/src.Solving Network-Flow Problems as LP ProblemsA network-flow model is an LP model with special structure. The <strong>ILOG</strong> <strong>CPLEX</strong> NetworkOptimizer is a highly efficient implementation of the primal simplex technique adapted totake advantage of this special structure. In particular, no basis factoring occurs. However, itis possible to solve network models using any of the <strong>ILOG</strong> <strong>CPLEX</strong> LP optimizers if first,you convert the network data structures to those of an LP model. To convert the network datastructures to LP data structures, in the Interactive Optimizer, use the commandchange problem lp; from the Callable Library, use the routine CPXcopynettolp.The LP formulation of our example from Figure 11.1 on page 220 looks like this:Minimize3a 1 + 3a 2 + 4a 3 + 3a 4 + 5a 5 + 6a 6 + 7a 7 + 4a 8 + 2a 9 + 6a 10 + 5a 11 + 4a 12 + 3a 13 + 6a 14subject toa 1 = 20224 <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!