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.

Note: If the value of 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_p is the index of the variable in the vary=pwl(varx) PWL constraint.
varx_p
*varx_p is the index of the variable in the vary=pwl(varx) PWL constraint.
preslope_p
*preslope_p is the preslope of the vary=pwl(varx) PWL constraint.
postslope_p
*postslope_p is the postslope of the vary=pwl(varx) PWL constraint.
nbreaks_p
*nbreaks_p is 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 NULL if breakspace is 0 (zero).
breaky
An array to contain the y coordinates of the breakpoints of the vary=pwl(varx) PWL constraint. Can be NULL if breakspace is 0 (zero).
breakspace
An integer specifying the length of the arrays breakx and breaky. Can be 0 (zero).
surplus_p
A pointer to an integer to contain the difference between breakspace and the number of entries in the arrays breakx and breaky. A nonnegative value of surplus_p reports 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 routine CPXXgetpwl/CPXgetpwl returns the value CPXERR_NEGATIVE_SURPLUS, and the negative value of surplus_p specifies 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);