8.4.5. Callback¶
Functions
Set up a user defined callback function
Retrieve the current user defined callback function
Retrieve additional data about the optimization progress
Add a new cutting plane to the MIP model
Indicate a new branching by specifying a variable and a split point between the lower and upper bounds of this variable
Provide a new feasible solution for a MIP model
- int MDOsetcallbackfunc(MDOmodel *model, callbackfn cb, void *usrdata)¶
Set up a user defined callback function.
- Parameters
model (MDOmodel*) – [in] The model object.
cb (callbackfn) –
[in] The callback function. Type callbackfn is defined as:
typedef int (*callbackfn)(const MDOmodel* model, void* cbdata, int where, const void* usrdata);usrdata (void*) – [in] The user defined callback context.
- Returns
A response code that specifies the status of the function.
- int MDOgetcallbackfunc(MDOmodel *model, callbackfn *cb)¶
Retrieve the current user defined callback function.
- Parameters
model (MDOmodel*) – [in] The model object.
cb (callbackfn*) –
[out] The place to hold current callback function. Type callbackfn defined as:
typedef int (*callbackfn)(const MDOmodel* model, void* cbdata, int where, const void* usrdata);- Returns
A response code that specifies the status of the function.
- int MDOcbget(void *cbdata, int where, int what, void *resultP)¶
Retrieve additional data about the optimization progress.
- Parameters
cbdata (void*) – [in] The cbdata argument passed into user callback function.
where (int) – [in] The where argument passed into user callback function.
what (int) – [in] The data ID requested by the user callback.
resultP (void*) – [out] The place to hold requested data, its type depends on the data requested.
- Returns
A response code that specifies the status of the function.
- int MDOcbcut(void *cbdata, int cutlen, const int *cutind, const double *cutval, char cutsense, double cutrhs)¶
Add a new cutting plane to the MIP model.
- Parameters
cbdata (void*) – [in] The cbdata argument passed into user callback function.
cutlen (int) – [in] The number of variables associated with new cutting plane.
cutind (const int*) – [in] The list of variable indices associated with new cutting plane.
cutval (const double*) – [in] The list of variable coefficients associated with new cutting plane.
cutsense (char) – [in] The sense of new cutting plane.
cutrhs (double) – [in] The right-hand-side value of new cutting plane.
- Returns
A zero or negative response code that specifies the status of the function, otherwise a positive number to indicate the submission status:
1: Submission is valid but incorrect (infeasible, etc)
2: Submission is correct but not being accepted.
- int MDOcbbranch(void *cbdata, int index, double value, int way)¶
Indicate a new branching by specifying a variable and a split point between the lower and upper bounds of this variable.
- Parameters
cbdata (void*) – [in] The cbdata argument passed into user callback function.
index (int) – [in] The variable index.
value (double) – [in] The split point. It should be between the lower and upper bounds of variable.
way (int) –
[in] The branch to consider first. Valid options are:
<0: the down-way branch is considered first.
>0: the up-way branch is considered first.
- Returns
A zero or negative response code that specifies the status of the function, otherwise a positive number to indicate the submission status:
1: Submission is valid but incorrect (infeasible, etc)
2: Submission is correct but not being accepted.
- int MDOcbsolution(void *cbdata, const double *solution, double *objP)¶
Provide a new feasible solution for a MIP model.
- Parameters
cbdata (void*) – [in] The cbdata argument passed into user callback function.
solution (const double*) – [in] The new feasible solution to be provided.
objP (double*) – [out] The place to hold objective value for new provided solution.
- Returns
A zero or negative response code that specifies the status of the function, otherwise a positive number to indicate the submission status:
1: Submission is valid but incorrect (infeasible, etc)
2: Submission is correct but not being accepted.