2.3.3 Additional functions
In addition to the heuristic function, the user must also define BC_allocHeuristic(…)
and BC_freeHeuristic(…) to allocate and free the global dynamic structure. These
functions are called by the solver at the beginning and at the end of the
execution.
BiqCrunch also provides three useful functions for testing the solution produced
with the heuristic:
- int BC_isFeasibleSolution(int *sol) which allows the user to test if the
solution in the binary vector sol is feasible;
- double BC_evaluateSolution(int *sol) which returns the value of the objective
function computed with the solution sol, a binary vector of size problemSize.
- int update_best(int *xbest, int *xnew, double *best, Problem *P0) which allows
the user to check if the new solution xnew is feasible for problem P0, and
to update, if needed, xbest and best. This function is useful when several
heuristics are sequentially used (e.g., problems/k-cluster/heur.c).
For each problem, a BC_FixVariables function can be defined by the user
to take advantage of particular constraints (see the Max-Independent-set
example in Section 3). This function must be defined in the corresponding
problems/<PROBLEM>/heur.c file.
- void BC_FixVariables(BobNode *node, int ic, int xic). User can set the value of
other variables as soon as x[ic]=xic (i.e., 0 or 1) assuming that constraints
in problem imply it. The node structure contains the full information to
set the values: node->xfixed is an indicator vector for the fixed variables,
node->sol.X contains the values of the fixed variables. The parameters ic
and xic are such that node->xfixed[ic] = 1 and node->sol.X[ic] = xic.