Previous Page: CPXcopyctypeFirst PageNext Page: CPXcopylpwnames

CPXcopylp


Description

The routine CPXcopylp() copies data that defines an LP problem to a CPLEX LP problem object. The arguments to CPXcopylp() define an objective function, the constraint matrix, the right-hand side, and the bounds on the variables. The CPXcopylp() routine does not copy names. Calling CPXcopylp() destroys any existing data associated with the LP problem object.

The more comprehensive routine CPXcopylpwnames() can be used in place of CPXcopylp() to copy linear programs with associated names.

The arguments passed to CPXcopylp() define a linear program. Note that these arguments are copied into local arrays maintained by CPLEX. Hence, the LP problem data passed via CPXcopylp() may be modified or freed after the call to CPXcopylp() without affecting the state of the LP problem object.

Return Value

The routine returns a zero on success, and a nonzero if an error occurs.

Synopsis

int CPXcopylp (CPXENVptr env,
               CPXLPptr lp,
               int numcols,
               int numrows,
               int objsen,
               double *obj,
               double *rhs,
               char *sense,
               int *matbeg,
               int *matcnt,
               int *matind,
               double *matval,
               double *lb,
               double *ub,
               double *rngval);

Arguments


CPXENVptr env
The pointer to the CPLEX environment as returned by one of the CPXopenCPLEX routines.

CPXLPptr lp
A pointer to a CPLEX LP problem object as returned by CPXcreateprob().

int numcols
An integer that indicates the number of columns in the constraint matrix, or equivalently, the number of variables in the problem object.

int numrows
An integer that indicates the number of rows in the constraint matrix, not including the objective function or bounds on the variables.

int objsen
An integer that indicates whether the problem is a minimization or maximization problem.

objsen  
= 1  
(CPX_MIN) minimize  
objsen  
= -1  
(CPX_MAX) maximize  

double *obj
An array of length at least numcols containing the objective function coefficients.

double *rhs
An array of at least length numrows containing the right-hand side value for each constraint in the constraint matrix.

char *sense
An array of at least length numrows containing the sense of each constraint in the constraint matrix.

sense[i]  
= 'L'  
constraint  
sense[i]  
= 'E'  
= constraint  
sense[i]  
= 'G'  
constraint  
sense[i]  
= 'R'  
ranged constraint  

int *matbeg
int *matcnt
int *matind
double *matval
These four arguments are all arrays that describe the constraint matrix. CPLEX needs to know only the nonzero coefficients. These are grouped by column in the array matval. Every column must be stored in sequential locations in this array with matbeg[j] containing the index of the beginning of column j and matcnt[j] containing the number of entries in column j. Note that the components of matbeg must be in ascending order. For each k, matind[k] indicates the row number of the corresponding coefficient, matval[k]. These arrays are accessed as follows. Suppose that CPLEX wants to access the entries in some column j. These are assumed to be given by the array entries:

matval[matbeg[j]],.., matval[matbeg[j]+matcnt[j]-1]

The corresponding row indices are:

matind[matbeg[j]],.., matind[matbeg[j]+matcnt[j]-1]

The entries in matind are not required to be in row order. Duplicate entries in matind and matval within a single column are not allowed. The arrays matbeg and matind should be of at least length numcols. The arrays matind and matval should be of at least length matbeg[numcols-1]+matcnt[numcols-1].

double *lb
An array of at least length numcols containing the lower bound on each of the variables. Any lower bound that is set to a value less than or equal to that of the constant -CPX_INFBOUND will be treated as negative ·. CPX_INFBOUND is defined in the header file cplex.h.

double *ub
An array of at least length numcols containing the upper bound on each of the variables. Any upper bound that is set to a value greater than or equal to that of the constant CPX_INFBOUND will be treated as ·. CPX_INFBOUND is defined in the header file cplex.h.

double *rngval
An array of at least length numrows containing the range value of each ranged constraint. Ranged rows are those designated by 'R' in the sense array. If the row is not ranged, the rngval array entry is ignored. If rngval[i] > 0, then row i activity is in [rhs[i],rhs[i]+rngval[i]], and if rngval[i] 0, then row i activity is in [rhs[i]+rngval[i],rhs[i]].

A range value for row i means that the value of row i must be between rhs[i] and rhs[i] + rngval[i]. rngval[i] can be positive or negative. rngval may be NULL.

Example

status = CPXcopylp (env, lp, numcols, numrows, objsen, obj, rhs,
                    sense, matbeg, matcnt, matind, matval, lb,
                    ub, rngval);

See Also

Example lpex1.c in the CPLEX User's Manual.

Previous Page: CPXcopyctypeFirst PageNext Page: CPXcopylpwnames