# GRBcbsolution

Filter Content By
Version
Languages

### GRBcbsolution

 int GRBcbsolution ( void *cbdata, const double *solution, double *objP )

Provide a new feasible solution for a MIP model from within a user callback routine. Note that this routine can only be called when the where value on the callback routine is GRB_CB_MIPNODE (see the Callback Codes section for more information).

Heuristics solutions are typically built from the current relaxation solution. To retrieve the relaxation solution at the current node, call GRBcbget with what = GRB_CB_MIPNODE_REL.

When providing a solution, you can specify values for any subset of the variables in the model. To leave a variable value unspecified, set the variable to GRB_UNDEFINED in the solution vector. The Gurobi MIP solver will attempt to extend the specified partial solution to a complete solution.

Return value:

A non-zero return value indicates that a problem occurred while adding the new solution. Refer to the Error Code table for a list of possible return values. Details on the error can be obtained by calling GRBgeterrormsg.

Arguments:

cbdata: The cbdata argument that was passed into the user callback by the Gurobi optimizer. This argument must be passed unmodified from the user callback to GRBcbsolution().

solution: The solution vector. You must provide one entry for each variable in the model. Note that you can leave an entry unspecified by setting it to GRB_UNDEFINED. The Gurobi optimizer will attempt to find appropriate values for the unspecified variables.

objP: Objective value for solution that results from this call. Returns GRB_INFINITY if no solution is found.

Example usage:

  if (where == GRB_CB_MIPNODE) {
error = GRBcbsolution(cbdata, solution, &obj);
if (error) return 0;
}