CPXXcallbackpostheursoln and CPXcallbackpostheursoln

Posts a feasible solution to CPLEX.

int CPXXcallbackpostheursoln( CPXCALLBACKCONTEXTptrcontext, CPXDIMcnt, CPXDIM const *ind, double const *val, doubleobj, CPXCALLBACKSOLUTIONSTRATEGYstrat )

int CPXcallbackpostheursoln( CPXCALLBACKCONTEXTptrcontext, CPXDIMcnt, CPXDIM const *ind, double const *val, doubleobj, CPXCALLBACKSOLUTIONSTRATEGYstrat )

Description

This routine posts a feasible solution to CPLEX. The solution passed to the routine may be partial; that is, possibly the solution does not specify values for all the variables in the model. If the solution is partial, then the argument strat specifies the solution strategy; that is, how CPLEX should try to find values for the missing variables. CPLEX applies the following scheme to process a solution posted by this routine:
  1. CPLEX checks whether the solution is incomplete. (A solution is incomplete if the solution does not specify a non-NaN value for each variable, where NaN means not a number.)
  2. If the solution is incomplete, then CPLEX applies the completion strategy specified by the argument strat.
  3. CPLEX checks the feasibility of the completed solution.
  4. CPLEX accepts the completed solution if the completed solution is feasible and improves on the current incumbent.

You must not call this routine from callbacks in the context CPX_CALLBACKCONTEXT_THREAD_UP or CPX_CALLBACKCONTEXT_THREAD_DOWN. If you do so, this routine returns CPXERR_UNSUPPORTED_OPERATION or CPXERR_NO_ENVIRONMENT.

You must not call this routine with Benders algorithm in any context.

Important:

It is possible that CPLEX does not handle the posted solution immediately. Generally, CPLEX adds the solution to a queue, and the next time that CPLEX runs heuristics, CPLEX looks at this queue for feasible solutions that come from an external source. This procedure implies that possibly CPLEX does not use the posted solution at all; for example, if CPLEX found a better solution before it looked at that queue again. Also possibly, CPLEX can run improvement heuristics on the specified solution, and these heuristics result in even better solutions. In such cases, the solution passed to this routine possibly does not appear as a new incumbent.

Arguments

context

The callback context as passed into the callback function.

cnt

The number of elements in ind and val.

ind

Nonzero indices of solution values.

val

Nonzero values of solution values. NaNs (that is, values that are not a number) are allowed in this array. They specify missing values in an incomplete solution.

obj

Objective value of the new solution. This value is merely a hint for CPLEX: CPLEX recalculates this value after completing the solution. However, if the value passed into this routine is worse than the current incumbent at the time CPLEX processes the posted solution, then CPLEX can discard the posted solution.

strat

Strategy to complete the solution in ind and val if the solution is partial.

Return

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

See also

CPXXcallbacksetfunc and CPXcallbacksetfunc

CPXCALLBACKSOLUTIONSTRATEGY