CPXXcopylp and CPXcopylp
The routine CPXXcopylp/CPXcopylp copies data that define an LP
problem to a CPLEX problem object.
int CPXXcopylp( CPXCENVptr env, CPXLPptr lp, CPXDIM numcols, CPXDIM numrows, int objsense, double const * objective, double const * rhs, char const * sense, CPXNNZ const * matbeg, CPXDIM const * matcnt, CPXDIM const * matind, double const * matval, double const * lb, double const * ub, double const * rngval )
int CPXcopylp( CPXCENVptr env, CPXLPptr lp, int numcols, int numrows, int objsense, double const * objective, double const * rhs, char const * sense, int const * matbeg, int const * matcnt, int const * matind, double const * matval, double const * lb, double const * ub, double const * rngval )
Description
The routine CPXXcopylp/CPXcopylp copies data that define an LP
problem to a CPLEX problem object. The arguments to CPXXcopylp/CPXcopylp
define an objective function, the constraint matrix, the righthand side,
and the bounds on the variables.
Calling CPXXcopylp/CPXcopylp destroys any existing data
associated with the problem object.
The routine CPXXcopylp/CPXcopylp does not copy names.
The more comprehensive routine
CPXXcopylpwnames/CPXcopylpwnames can be used
in place of CPXXcopylp/CPXcopylp to copy linear programs with associated
names.
The arguments passed to CPXXcopylp/CPXcopylp define a linear program.
Since these arguments are copied into local arrays maintained by CPLEX, the
LP problem data passed via CPXXcopylp/CPXcopylp may be modified or freed
after the call to CPXXcopylp/CPXcopylp without affecting the state of
the CPLEX problem object.
objsense |
= 1 |
(CPX_MIN) minimize |
objsense |
= -1 |
(CPX_MAX) maximize |
sense[i] |
'L' |
<= constraint |
sense[i] |
'E' |
= constraint |
sense[i] |
'G' |
>= constraint |
sense[i] |
'R' |
ranged constraint |
The arrays
matbeg,
matcnt,
matind, and
matval
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]
Entries in matind are not required to be in row order.
Duplicate entries in matind within a single column are not
allowed. The length of the arrays matbeg and
matind should be at least numcols. The length
of arrays matind and matval should be at least
matbeg[numcols-1]+matcnt[numcols-1].
The arrays matbeg and
matcnt can be NULL if one of
numcols or
numrows is 0 (zero);
that is, if one dimension the
matrix is 0 (zero) and can not contain any coefficients.
When you build or modify your problem with this routine,
you can verify that the results are as you intended
by calling CPXcheckcopylp
during application development.
Arguments
- env
-
A pointer to the CPLEX environment as returned by
CPXXopenCPLEX/CPXopenCPLEX. - lp
-
A pointer to a CPLEX problem object as returned by
CPXXcreateprob/CPXcreateprob. - numcols
- An integer that specifies the number of columns in the constraint matrix, or equivalently, the number of variables in the problem object.
- numrows
- An integer that specifies the number of rows in the constraint matrix, not including the objective function or bounds on the variables.
- objsense
- An integer that specifies whether the problem is a minimization or maximization problem.
- objective
-
An array of length at least
numcolscontaining the objective function coefficients. - rhs
-
An array of length at least
numrowscontaining the righthand side value for each constraint in the constraint matrix. - sense
-
An array of length at least
numrowscontaining the sense of each constraint in the constraint matrix. - matbeg
-
An array that with
matval,matcnt, andmatinddefines the constraint matrix. - matcnt
-
An array that with
matbeg,matval, andmatinddefines the constraint matrix. - matind
-
An array that with
matbeg,matcnt, andmatvaldefines the constraint matrix. - matval
-
An array that with
matbeg,matcnt, andmatinddefines the constraint matrix. CPLEX needs to know only the nonzero coefficients. These are grouped by column in the arraymatval. The nonzero elements of every column must be stored in sequential locations in this array withmatbeg[j]containing the index of the beginning of columnjandmatcnt[j]containing the number of entries in columnj. The components ofmatbegmust be in ascending order. For each k,matind[k]specifies the row number of the corresponding coefficient,matval[k]. - lb
-
An array of length at least
numcolscontaining 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_INFBOUNDis treated as negative infinity.CPX_INFBOUNDis defined in the header file cplex.h. - ub
-
An array of length at least
numcolscontaining 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 constantCPX_INFBOUNDis treated as infinity.CPX_INFBOUNDis defined in the header file cplex.h. - rngval
-
An array of length at least
numrowscontaining the range value of each ranged constraint. Ranged rows are those designated by'R'in thesensearray. If the row is not ranged, therngvalarray entry is ignored. Ifrngval[i]> 0, then rowiactivity is in[rhs[i],rhs[i]+rngval[i]], and ifrngval[i]<= 0,then rowiactivity is in[rhs[i]+rngval[i],rhs[i]]. This argument may be NULL.
Return
The routine returns 0 (zero) if successful and nonzero if an error occurs.Example
status = CPXcopylp (env, lp, numcols, numrows, objsen, obj, rhs,
sense, matbeg, matcnt, matind, matval, lb,
ub, rngval);
See also the example lpex1.c in the
CPLEX User's Manual and in the standard distribution.