Accessing a solution in the solution pool

Describes access to a particular solution in the solution pool.

If you want to examine all the solutions available in the solution pool, your application should loop from 0 (zero) to N-1 (that is, one less than the number of solutions in the pool). Index 0 (zero) conventionally refers to the current incumbent solution.

To learn the number of solutions in the pool for such a loop, use one of the following methods or routines.

  • In Concert Technology,

    • In the C++ API, use the method IloCplex::getSolnPoolNsolns.

    • In the Java API, use the method IloCplex.getSolnPoolNsolns.

    • In the .NET API, use the method Cplex.GetSolnPoolNsolns.

  • In the Callable Library, use the routine CPXgetsolnpoolnumsolns.

Table 1 summarizes the methods, routines, or commands that access information about a given solution in the solution pool.
Table 1. Accessing solution information in the solution pool
Purpose Concert Technology Callable Library Interactive Optimizer
Objective value getObjValue CPXgetsolnpoolobjval display solution member i obj
Value of variable getValues CPXgetsolnpoolx display solution member i var
Slack in linear constraints getSlacks CPXgetsolnpoolslack display solution member i slacks
Slack in quadratic constraints getSlacks CPXgetsolnpoolqconstrslack display solution member i qcslacks
Quality getQuality

CPXgetsolnpoolintquality

or

CPXgetsolnpooldblquality

display solution member i quality
Difference between solutions (see Notes) (see Notes) display solution difference i j
Note:

In the Interactive Optimizer, the command

display solution difference 1 2

compares the first and second solution. Likewise, the command

display solution difference 0 2

compares the incumbent and the second solution.

There is no exact equivalent of this difference command in Concert Technology or the Callable Library. In those APIs, first access the solution vector (for example, in the C++ API by means of the method getValues or in the C API by means of the routine CPXgetsolnpoolx) and then write your own comparison.

For a sample of these methods or routines, see the example in yourCPLEXhome /examples :

  • ilopopulate.cpp

  • Populate.java

  • Populate.cs or Populate.vb

  • populate.c