CPXXsolution and CPXsolution

The routine CPXXsolution/CPXsolution accesses the solution values produced by all the optimization routines except the routine CPXXNETprimopt/CPXNETprimopt.

int  CPXXsolution( CPXCENVptr env, CPXCLPptr lp, int * lpstat_p, double * objval_p, double * x, double * pi, double * slack, double * dj )

int  CPXsolution( CPXCENVptr env, CPXCLPptr lp, int * lpstat_p, double * objval_p, double * x, double * pi, double * slack, double * dj )

Description

The routine CPXXsolution/CPXsolution accesses the solution values produced by all the optimization routines except the routine CPXXNETprimopt/CPXNETprimopt. The solution is maintained until the CPLEX problem object is freed via a call to CPXXfreeprob/CPXfreeprob or the solution is rendered invalid because of a call to one of the problem modification routines.

The arguments to CPXXsolution/CPXsolution are pointers to locations where data are to be written. Such data can include the status of the optimization, the value of the objective function, the values of the primal variables, the dual variables, the slacks and the reduced costs. All of that data exists after a successful call to one of the LP or QP optimizers. However, dual variables and reduced costs are not available after a successful call of the QCP or MIP optimizers. If any part of the solution represented by an argument to CPXXsolution/CPXsolution is not required, that argument can be passed with the value NULL in a call to CPXXsolution/CPXsolution. If only one part is required, it may be more convenient to use the CPLEX routine that accesses that part of the solution individually: CPXXgetstat/CPXgetstat, CPXXgetobjval/CPXgetobjval, CPXXgetx/CPXgetx, CPXXgetpi/CPXgetpi, CPXXgetslack/CPXgetslack, or CPXXgetdj/CPXgetdj.

For barrier, the solution values for x, pi, slack, and dj correspond to the last iterate of the primal-dual algorithm, independent of solution status.

If optimization stopped with an infeasible solution, take care to interpret the meaning of the values in the returned arrays as described in the Parameters section.

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.
lpstat_p
A pointer to an integer specifying the result of the optimization. The specific values which *lpstat_p can take and their meanings are the same as the return values documented for CPXXgetstat/CPXgetstat and are found in the group optim.cplex.statuscodes of this reference manual.
objval_p
A pointer to a double precision variable where the objective function value is to be stored.
x
An array to receive the values of the variables for the problem. The length of the array must be at least as great as the number of columns in the problem object. If the solution was computed using the dual simplex optimizer, and the solution is not feasible, x values are calculated relative to the phase I RHS used by CPXXdualopt/CPXdualopt.
pi
An array to receive the values of the dual variables for each of the constraints. The length of the array must be at least as great as the number of rows in the problem object. If the solution was computed using the primal simplex optimizer, and the solution is not feasible, pi values are calculated relative to the phase I objective (the infeasibility function).
slack
An array to receive the values of the slack or surplus variables for each of the constraints. The length of the array must be at least as great as the number of rows in the problem object. If the solution was computed by the dual simplex optimizer, and the solution is not feasible, slack values are calculated relative to the phase I RHS used by CPXXdualopt/CPXdualopt.
dj
An array to receive the values of the reduced costs for each of the variables. The length of the array must be at least as great as the number of columns in the problem object. If the solution was computed by the primal simplex optimizer, and the solution is not feasible, dj values are calculated relative to the phase I objective (the infeasibility function).

Return

This routine returns 0 (zero) if a solution exists. If no solution exists, or some other failure occurs, CPXXsolution/CPXsolution returns nonzero.

Example


status = CPXsolution (env, lp, &lpstat, &objval, x, pi,
slack, dj);

See also the example lpex1.c in the CPLEX User's Manual and in the standard distribution.