ILOG CPLEX 11.0 Getting Started > Tutorials > Concert Technology Tutorial for C++ Users > Modifying an Optimization Problem: Example ilolpex3.cpp

This example demonstrates:

Here is the problem example ilolpex3 solves:

Minimize 
c^Tx 

 

 

 
subject to 
Hx = d  
Ax = b  
l x

 

 

 
where 
H =  
( -1 0 1 0 1 0 0 0 )  
d =  
( -3 )  
 
 
( 1 -1 0 1 0 0 0 0 )  
 
( 1 )  
 
 
( 0 1 -1 0 0 1 -1 0 )  
 
( 4 )  
 
 
( 0 0 0 -1 0 -1 0 1 )  
 
( 3 )  
 
 
( 0 0 0 0 -1 0 1 -1 )  
 
( -5 )  
 
 

 
 
 
 
A =  
( 2 1 -2 -1 2 -1 -2 -3 )  
b =  
( 4 )  
 
 
( 1 -3 2 3 -1 2 1 1 )  
 
( -2 )  
 
 

 
 
 
 
c =  
(-9 1 4 2 -8 2 8 12 )  
 
 
 
l =  
( 0 0 0 0 0 0 0 0 )  
 
 
 
u =  
(50 50 50 50 50 50 50 50 )  
 
 

The constraints Hx=d represent the flow conservation of a pure network flow. The example solves this problem in two steps:

  1. The ILOG CPLEX Network Optimizer is used to solve
    Minimize 
    c^Tx 
    subject to 
    Hx = d 
    l x
  2. The constraints Ax=b are added to the problem, and the dual simplex optimizer is used to solve the full problem, starting from the optimal basis of the network problem. The dual simplex method is highly effective in such a case because this basis remains dual feasible after the slacks (artificial variables) of the added constraints are initialized as basic.

Notice that the 0 values in the data are omitted in the example program. ILOG CPLEX makes extensive use of sparse matrix methods and, although ILOG CPLEX correctly handles any explicit zero coefficients given to it, most programs solving models of more than modest size benefit (in terms of both storage space and speed) if the natural sparsity of the model is exploited from the very start.

Before the model is solved, the network optimizer is selected by setting the RootAlg parameter to the value IloCplex::Network, as shown in example ilolpex2.cpp. The simplex display parameter IloCplex::SimDisplay is set so that the simplex algorithm issues logging information as it executes.