NO FRAMES

CPXsolution

int CPXPUBLIC CPXsolution(CPXCENVptr env, CPXCLPptr lp, int * lpstat_p, double * objval_p, double * x, double * pi, double * slack, double * dj)
Definition file: cplex.h
Include files: cplex.h

The routine CPXsolution accesses the solution values produced by the routines CPXlpopt, CPXprimopt, CPXdualopt, CPXbaropt, CPXhybbaropt, CPXhybnetopt, or CPXqpopt. The solution is maintained until the CPLEX problem object is freed via a call to CPXfreeprob or the solution is rendered invalid because of a call to one of the problem modification routines.

The arguments to 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. Although all of the above data exists after a successful call to one of the LP or QP optimizers, it is possible that the user needs only a subset of the data available. If any part of the solution represented by an argument to CPXsolution is not required, that argument can be passed with the value NULL in a call to 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: CPXgetstat, CPXgetobjval, CPXgetx, CPXgetpi, CPXgetslack, 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 Arguments section.

Example

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

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

See Also:

Parameters:

env

A pointer to the CPLEX environment as returned by CPXopenCPLEX.

lp

A pointer to a CPLEX problem object as returned by CPXcreateprob.

lpstat_p

A pointer to an integer indicating 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 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 primal 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 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 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).

Returns:

This routine returns zero if a solution exists. If no solution exists, or some other failure occurs, CPXsolution returns nonzero.