ILOG CPLEX 10.1 Getting Started > Tutorials > Concert Technology Tutorial for C++ Users > Modifying an Optimization Problem: Example ilolpex3.cpp |
Modifying an Optimization Problem: Example ilolpex3.cpp |
INDEX
![]() |
This example demonstrates:
Here is the problem example ilolpex3
solves:
The constraints Hx=d represent the flow conservation of a pure network flow. The example solves this problem in two steps:
Minimize |
c^Tx |
subject to |
Hx = d
l ![]() ![]() |
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.
IloCplex
provides a variety of parameters that allow you to control the solution process. They can be categorized as Boolean, integer, numerical, and string parameters and are represented by the enumeration types IloCplex::BoolParam
, IloCplex::IntParam
, IloCplex::NumParam
, and IloCplex::StringParam
, respectively.
After the simple model is solved and the resulting objective value is passed to the output channel cplex.out
, the remaining constraints are created and added to the model. At this time the model has already been extracted to cplex
. As a consequence, whenever the model is modified by adding a constraint, this addition is immediately reflected in the cplex
object via notification.
Before solving the modified problem, example ilolpex3.cpp
sets the optimizer option to IloCplex::Dual
, as this is the algorithm that can generally take best advantage of the optimal basis from the previous solve after the addition of constraints.
You can view the complete program online in the standard distribution of the product at yourCPLEXinstallation/examples/src/ilolpex3.cpp
.
Copyright © 1987-2006 ILOG S.A. All rights reserved. Legal terms. | PREVIOUS NEXT |