CPXXgetpwl and CPXgetpwl
The routine
CPXXgetpwl/CPXgetpwl
accesses the definitions of a piecewise linear (PWL) constraint
stored in a CPLEX problem object.
int CPXXgetpwl( CPXCENVptr env, CPXCLPptr lp, CPXDIM pwlindex, CPXDIM * vary_p, CPXDIM * varx_p, double * preslope_p, double * postslope_p, CPXDIM * nbreaks_p, double * breakx, double * breaky, CPXDIM breakspace, CPXDIM * surplus_p)
int CPXgetpwl( CPXCENVptr env, CPXCLPptr lp, int pwlindex, int * vary_p, int * varx_p, double * preslope_p, double * postslope_p, int * nbreaks_p, double * breakx, double * breaky, int breakspace, int * surplus_p)
Description
The routine
CPXXgetpwl/CPXgetpwl
accesses the definitions of a PWL constraint stored in a CPLEX
problem object. The length of the arrays in which the
breakpoints are to be returned (breakx and
breaky) must be provided
in breakspace.
breakspace is 0 (zero),
then the negative of the value of
surplus_p returned
specifies the length needed for the arrays
breakx and
breaky.
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. - pwlindex
- The index of the PWL constraint queried.
- vary_p
-
*vary_pis the index of the variable in the vary=pwl(varx) PWL constraint. - varx_p
-
*varx_pis the index of the variable in the vary=pwl(varx) PWL constraint. - preslope_p
-
*preslope_pis the preslope of the vary=pwl(varx) PWL constraint. - postslope_p
-
*postslope_pis the postslope of the vary=pwl(varx) PWL constraint. - nbreaks_p
-
*nbreaks_pis the number of breakpoints in the vary=pwl(varx) PWL constraint. - breakx
-
An array to contain the x coordinates of the breakpoints
of the vary=pwl(varx) PWL constraint. Can be
NULLifbreakspaceis 0 (zero). - breaky
-
An array to contain the y coordinates of the breakpoints
of the vary=pwl(varx) PWL constraint. Can be
NULLifbreakspaceis 0 (zero). - breakspace
-
An integer specifying the length of the arrays
breakxandbreaky. Can be 0 (zero). - surplus_p
-
A pointer to an integer to contain the difference between
breakspaceand the number of entries in the arraysbreakxandbreaky. A nonnegative value ofsurplus_preports that the length of the arrays was sufficient. A negative value reports that the length was insufficient and that the routine could not complete its task. In this case, the routineCPXXgetpwl/CPXgetpwlreturns the valueCPXERR_NEGATIVE_SURPLUS, and the negative value ofsurplus_pspecifies the amount of insufficient space in the arrays.
Return
The routine returns 0 (zero) if successful and nonzero if an error occurs.
Example
status = CPXgetpwl (env, lp, pwlindex, &vary, &varx,
&preslope, &postslope, NULL,
NULL, NULL, 0, &surplus);
breakx = malloc ((-surplus) * sizeof(double));
breaky = malloc ((-surplus) * sizeof(double));
status = CPXgetpwl (env, lp, pwlindex, &vary, &varx,
&preslope, &postslope, &nbreaks, breakx, breaky, 0, &surplus);