NO FRAMES

CPXaddsos

public int CPXaddsos(CPXCENVptr env, CPXLPptr lp, int numsos, int numsosnz, const char * sostype, const int * sosbeg, const int * sosind, const double * soswt, char ** sosname)
Definition file: cplex.h

The routine CPXaddsos adds information about a special ordered set (SOS) to a problem object of type CPXPROB_MILP, CPXPROB_MIQP, or CPXPROB_MIQCP. The problem may already contain SOS information.

Table 1: Values of elements of sostype
CPX_TYPE_SOS1'1'Type 1
CPX_TYPE_SOS2'2'Type 2

The arrays sosbeg, sosind, and soswts follow the same conventions as similar arrays in other routines of the Callable Library. For j < numsos-1, the indices of the set j must be stored in sosind[sosbeg[j]], ..., sosind[sosbeg[j+1]-1] and the weights in soswt[sosbeg[j],..., soswt[sosbeg[j+1]-1]. For the last set, j = numsos-1, the indices must be stored in sosind[sosbeg[numsos-1]],..., sosind[numsosnz-1] and the corresponding weights in soswt[sosbeg[numsos-1]],..., soswt[numsosnz-1]. Hence, the length of sosbeg must be at least numsos, while the lengths of sosind and soswt must must be at least numsosnz.

Example

 status = CPXaddsos (env, lp, numsos, numsosnz, sostype,
                     sosbeg, sosind, soswt, NULL);

Parameters:

env

A pointer to the CPLEX environment as returned by CPXopenCPLEX.

lp

A pointer to a CPLEX problem object as returned by CPXcreateprob.

numsos

The number of sets to be added to existing SOS sets, if any.

numsosnz

The total number of members in all of the sets to be added to existing SOS sets, if any.

sostype

An array containing SOS type information for the sets to be added. According to Table 1, sostype[i] specifies the SOS type of set i. The length of this array must be at least numsos.

sosbeg

An array that with sosind and soswt defines the weights for the sets to be added.

sosind

An array that with sosbeg and soswt defines the weights of the sets to be added.

soswt

An array that with sosbeg and sosind defines the indices and weights for the sets to be added. The indices of each set must be stored in sequential locations in sosind. The weights of each set must be stored in sequential locations in soswt. The array sosbeg[j] containing the index of the beginning of set j. The weights must be unique within each set.

sosname

An array containing pointers to character strings that represent the names of the new SOSs. May be NULL, in which case the new SOSs are assigned default names if the SOSs already resident in the CPLEX problem object have names; otherwise, no names are associated with the sets. If SOS names are passed to CPXaddsos but existing SOSs have no names assigned, default names are created for them.

Returns:

The routine returns zero if successful and nonzero if an error occurs.