Referencing ranges of objects
Describes coding conventions of the C API with respect to indexing arrays and numbering other objects.
Consistent with standard C programming practices, in CPLEX an array
containing k items will contain these items in locations 0 (zero)
through k-1.
References to rows and columns
A linear program with m rows
and n columns will have its rows indexed from 0 to m-1,
and its columns from 0 to n-1.
Within the linear programming data structure, the rows and columns that represent constraints and variables are referenced by an index number. Each row and column may optionally have an associated name. If you add or delete rows, the index numbers usually change:
for deletions, CPLEX decrements each reference index above the deletion point; and
for additions, CPLEX makes all additions at the end of the existing range.
However, CPLEX updates the names so that each row or column index
will correspond to the correct row or column name. Double checking
names against index numbers is the only sure way to reveal which changes
may have been made to matrix indices in such a context. The routines CPXgetrowindex and CPXgetcolindex translate
names to indices.
References to other objects
Similar conventions (numbering from 0 to k-1)
apply to other objects supported by the Callable Library (C API).
Examples include modeling objects, such as special ordered sets (SOS),
indicator constraints, and quadratic constraints, as well as optimization
objects, such as MIP starts. If an application creates k
such objects, the objects will be indexed in the range 0 to k-1.
For deletions, CPLEX decrements each reference index above the deletion point;
for additions, CPLEX puts all the added elements at the end of the existing range.