NO FRAMES

CPXcopysos

public int CPXcopysos(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 CPXcopysos copies special ordered set (SOS) information to a problem object of type CPXPROB_MILP, CPXPROB_MIQP, or CPXPROB_MIQCP.

When you build or modify your problem with this routine, you can verify that the results are as you intended by calling CPXcheckcopysos during application development.

Table 1: Settings for sostype
CPX_TYPE_SOS1'1'Type 1
CPX_TYPE_SOS2'2'Type 2

Example

 status = CPXcopysos (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 SOS sets. If numsos is equal to zero, CPXcopysos removes all the SOSs from the LP object.

numsosnz

The total number of members in all sets. CPXcopysos with numsosnz equal to zero removes all the SOSs from the LP object.

sostype

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

sosbeg

An array stating beginning indices as explained in soswt.

sosind

An array stating indices as explained in soswt.

soswt

Arrays declaring the indices and weights for the sets. For every set, the indices and weights must be stored in sequential locations in sosind and soswt, respectively, with sosbeg[j] containing the index of the beginning of set j. The weights must be unique in their array. For j < numsos-1 the indices of 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, sosbeg must be of length at least numsos, while sosind and soswt must be of length at least numsosnz.

sosname

An array containing pointers to character strings that represent the names of the SOSs. May be NULL.

Returns:

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