12.07.2015 Views

ILOG CPLEX 11.0 User's Manual

ILOG CPLEX 11.0 User's Manual

ILOG CPLEX 11.0 User's Manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

For example, let’s look at the synopses for two routines, CPXgetobjval and CPXgetx, asthey are documented in the <strong>ILOG</strong> <strong>CPLEX</strong> Reference <strong>Manual</strong> to clarify this callingconvention. Here is the synopsis of the routine CPXgetobjval:int CPXgetobjval (CPXCENVptr env, CPXCLPptr lp, double *objval_p);In that routine, the third parameter is a pointer to a variable of type double. To call thisroutine from C, declare:double objval;Then call CPXgetobjval in this way:status = CPXgetobjval (env, lp, &objval);In contrast, here is the synopsis of the routine CPXgetx:int CPXgetx (CPXENV env, CPXLPptr lp, double *x, int begin, int end);You call it by creating a double-precision array by means of either one of two methods. Thefirst method dynamically allocates the array, like this:double *x = NULL;x = (double *) malloc (100*sizeof(double));The second method declares the array as a local variable, like this:double x[100];Then to see the optimal values for columns 5 through 104, for example, you could write this:status = CPXgetx (env, lp, x, 5, 104);The parameter objval_p in the synopsis of CPXgetobjval and the parameter x in thesynopsis of CPXgetx are both of type (double *). However, the suffix _p in the parameterobjval_p indicates that you should use an address of a single variable in one call, while thelack of _p in x indicates that you should pass an array in the other.For guidance about how to pass values to <strong>ILOG</strong> <strong>CPLEX</strong> routines from application languagessuch as FORTRAN or BASIC that conventionally call by reference, see Call by Referenceon page 123 in this manual, and consult the documentation for those languages.<strong>ILOG</strong> <strong>CPLEX</strong> <strong>11.0</strong> — USER’ S MANUAL 115

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!