ILOG CPLEX 11.0 User's Manual > Advanced Programming Techniques > Using Optimization Callbacks > Example: Using Callbacks lpex4.c |
Example: Using Callbacks lpex4.c |
INDEX PREVIOUS NEXT |
This example shows you how to use callbacks effectively with routines from the ILOG CPLEX Callable Library. It is based on lpex1.c
, a program from the ILOG CPLEX Getting Started manual. This example about callbacks differs from that simpler one in several ways:
CPX_PARAM_SCRIND
) is not turned on. Only the callback function produces output. Consequently, this program calls CPXgeterrorstring
to retrieve any error messages and then prints them. After the TERMINATE:
label, the program uses separate status variables so that if an error occurred earlier, its error status will not be lost or destroyed by freeing the problem object and closing the ILOG CPLEX environment. Table 30.3 summarizes those status variables.
Variable |
Represents status returned by this routine |
---|---|
frstatus | |
clstatus |
mycallback
at the end of the program is called by the optimizer. This function tests whether the primal simplex optimizer has been called. If so, then a call to CPXgetcallbackinfo
gets the following information:
CPXlpopt
, the default optimizer from the ILOG CPLEX Callable Library, it sets the callback function by calling CPXsetlpcallbackfunc
. It unsets the callback immediately after optimization.
This callback function offers a model for graphic user interfaces that display optimization progress as well as those GUIs that allow a user to interrupt and stop optimization. If you want to provide your end-user a facility like that to interrupt and stop optimization, then you should make mycallback
return a nonzero value to indicate the end-user interrupt.
The complete program lpex4.c
appears online in the standard distribution at yourCPLEXinstallation/examples/src
.
Copyright © 1987-2007 ILOG S.A. All rights reserved. Legal terms. | PREVIOUS NEXT |