CPXXsetlpcallbackfunc and CPXsetlpcallbackfunc

Modifies the user-written legacy callback routine to be called after each iteration during the optimization of a linear program, and also periodically during the CPLEX presolve algorithm.

int  CPXXsetlpcallbackfunc( CPXENVptr env, int(CPXPUBLIC *callback)(CPXCENVptr, void *, int, void *), void * cbhandle )

int  CPXsetlpcallbackfunc( CPXENVptr env, int(CPXPUBLIC *callback)(CPXCENVptr, void *, int, void *), void * cbhandle )

Description

The routine CPXXsetlpcallbackfunc/CPXsetlpcallbackfunc modifies the user-written legacy callback routine to be called after each iteration during the optimization of a linear program, and also periodically during the CPLEX presolve algorithm.

Tip:

This routine is part of legacy callbacks. Do not use this routine with a generic callback in your application. For more about generic callbacks, see the topic Generic callbacks in the CPLEX User's Manual.

Callback description


int CPXPUBLIC
callback (CPXCENVptr env,
          void *cbdata,
          int wherefrom,
          void *cbhandle);

This is the user-written callback routine.

Callback return value

A nonzero terminates the optimization.

Callback arguments

env

A pointer to the CPLEX environment that was passed into the associated optimization routine.

cbdata

A pointer passed from the optimization routine to the user-written callback function that identifies the problem being optimized. The only purpose for the cbdata pointer is to pass it to the routine CPXXgetcallbackinfo/CPXgetcallbackinfo.

wherefrom

An integer value specifying from which optimization algorithm the user-written callback function was called. Possible values and their meaning appear in the table below.

Value Symbolic Constant Meaning
1 CPX_CALLBACK_PRIMAL From primal simplex
2 CPX_CALLBACK_DUAL From dual simplex
4 CPX_CALLBACK_PRIMAL_CROSSOVER From primal crossover
5 CPX_CALLBACK_DUAL_CROSSOVER From dual crossover
6 CPX_CALLBACK_BARRIER From barrier
7 CPX_CALLBACK_PRESOLVE From presolve
8 CPX_CALLBACK_QPBARRIER From QP barrier
9 CPX_CALLBACK_QPSIMPLEX From QP simplex

cbhandle

Pointer to user private data, as passed to CPXXsetlpcallbackfunc/CPXsetlpcallbackfunc.

Arguments

env

A pointer to the CPLEX environment as returned by CPXXopenCPLEX/CPXopenCPLEX.

callback

A pointer to a user-written callback function. Setting callback to NULL prevents any callback function from being called during optimization. The call to callback occurs after every iteration during optimization and periodically during the CPLEX presolve algorithms. This function is written by the user, and is prototyped as documented here.

cbhandle

A pointer to user private data. This pointer is passed to the callback function.

Return

The routine returns 0 (zero) if successful and nonzero if an error occurs.

Example


status = CPXsetlpcallbackfunc (env, myfunc, NULL);