80#define HEUR_NAME "initcol"
81#define HEUR_DESC "initial primal heuristic for coloring"
82#define HEUR_DISPCHAR 't'
83#define HEUR_PRIORITY 1
86#define HEUR_MAXDEPTH 0
87#define HEUR_TIMING SCIP_HEURTIMING_BEFORENODE
88#define HEUR_USESSUBSCIP FALSE
92#define DEFAULT_USETABU TRUE
93#define DEFAULT_MAXITER 100000
94#define DEFAULT_TABUBASE 50
95#define DEFAULT_TABUGAMMA 0.9
96#define DEFAULT_OUTPUT 1
97#define DEFAULT_DISPFREQ 10000
171 nnodes = tcliqueGetNNodes(graph);
185 values[
i] = degrees[
i] + ( colors[
i] == -1 ?
nnodes : 0);
192 stablesetnodes[0] = sortednodes[0];
196 if( colors[sortednodes[
i]] != -1 )
201 for( j = 0; j < nstablesetnodes; j++ )
203 if( tcliqueIsEdge(graph, sortednodes[
i], stablesetnodes[j]) )
209 if( indNode ==
TRUE )
211 stablesetnodes[nstablesetnodes] = sortednodes[
i];
216 for(
i = 0;
i < nstablesetnodes;
i++ )
218 assert(colors[stablesetnodes[
i]] == -1);
219 colors[stablesetnodes[
i]] = nextcolor;
285 nnodes = tcliqueGetNNodes(graph);
293 if( colors[
i] == colors[*j] )
345 printf(
"Running tabu coloring with maxcolors = %d...\n", maxcolors);
348 nnodes = tcliqueGetNNodes(graph);
355 if( colors[
i] < 0 || colors[
i] >= maxcolors )
358 colors[
i] = rnd % maxcolors;
360 assert( 0 <= colors[
i] && colors[
i] < maxcolors );
373 for( j = 0; j < maxcolors; j++ )
384 for( node1 = 0; node1 <
nnodes; node1++ )
386 color1 = colors[node1];
389 while( firstedge <= lastedge )
392 color2 = colors[node2];
393 assert( 0 <= color2 && color2 < maxcolors );
394 (adj[node1][color2])++;
395 if( color1 == color2 )
410 for( iter = 1; iter <=
heurdata->maxiter; iter++ )
417 for( node1 = 0; node1 <
nnodes; node1++ )
420 color1 = colors[node1];
421 assert( 0 <= color1 && color1 < maxcolors );
424 if( adj[node1][color1] > 0 )
428 for( j = 0; j < maxcolors; j++ )
434 d = adj[node1][j] - adj[node1][color1];
440 printf(
" Feasible solution found after %d iterations!\n\n", iter);
449 if( tabu[node1][j] < iter && d < minvalue )
472 assert( colors[minnode] != mincolor );
473 oldcolor = colors[minnode];
474 colors[minnode] = mincolor;
482 printf(
"Iter: %d obj: %d critical: %d node: %d color: %d delta: %d\n", iter,
obj, ncritical, minnode,
491 assert( tabu[minnode][oldcolor] < iter );
492 tabu[minnode][oldcolor] = iter + (
heurdata->tabubase) + (
int) (((double) ncritical) * (
heurdata->tabugamma));
497 (adj[*firstedge][mincolor])++;
498 (adj[*firstedge][oldcolor])--;
504 printf(
"Best objective: %d\n ", bestobj);
507 printf(
"\nTabu list is probably too restrictive.\n");
511 if(
heurdata->output >= 1 && bestobj != 0 )
513 printf(
" No feasible solution found after %d iterations!\n\n", iter-1);
525 *success = (
obj == 0);
623 bestcolors[
i] = colors[
i];
629 for(
i = 0;
i <= ncolors;
i++ )
633 for( j = 0; j <
nnodes; j++ )
635 if( bestcolors[j] ==
i )
637 colors[nstablesetnodes] = j;
643 for( j = 0; j <
nnodes; j++ )
646 for( k = 0; k < nstablesetnodes; k++ )
648 if( j == colors[k] || tcliqueIsEdge(graph, j, colors[k]) )
655 if( indnode ==
TRUE )
657 colors[nstablesetnodes] = j;
675 for( j = 0; j < nstablesetnodes; j++ )
737 "heuristics/initcol/usetabu",
738 "should the tabu search heuristic be used in order to improve the greedy-solution?",
742 "heuristics/initcol/maxiter",
743 "maximal number of iterations to be performed in each tabu-run",
747 "heuristics/initcol/tabubase",
748 "constant part of the tabu-duration",
752 "heuristics/initcol/tabugamma",
753 "factor for the linear part of the tabu-duration",
757 "heuristics/initcol/output",
758 "verbosity level for the output of the tabu search, 0: no output, 1: normal, 2: high",
762 "heuristics/initcol/dispfreq",
763 "frequency for displaying status information, only active with output verbosity level 2",
Constraint handler for the set partitioning / packing / covering constraints .
constraint handler for storing the graph at each node of the tree
#define SCIP_STRINGEQ(name, reference, retcode)
SCIP_RETCODE SCIPaddCoefSetppc(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var)
SCIP_RETCODE SCIPaddVar(SCIP *scip, SCIP_VAR *var)
SCIP_RETCODE SCIPgetBoolParam(SCIP *scip, const char *name, SCIP_Bool *value)
SCIP_RETCODE SCIPaddIntParam(SCIP *scip, const char *name, const char *desc, int *valueptr, SCIP_Bool isadvanced, int defaultvalue, int minvalue, int maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
SCIP_RETCODE SCIPaddRealParam(SCIP *scip, const char *name, const char *desc, SCIP_Real *valueptr, SCIP_Bool isadvanced, SCIP_Real defaultvalue, SCIP_Real minvalue, SCIP_Real maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
SCIP_RETCODE SCIPsetIntParam(SCIP *scip, const char *name, int value)
SCIP_RETCODE SCIPaddBoolParam(SCIP *scip, const char *name, const char *desc, SCIP_Bool *valueptr, SCIP_Bool isadvanced, SCIP_Bool defaultvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
SCIP_RETCODE SCIPsetHeurFree(SCIP *scip, SCIP_HEUR *heur,)
SCIP_HEURDATA * SCIPheurGetData(SCIP_HEUR *heur)
SCIP_RETCODE SCIPincludeHeurBasic(SCIP *scip, SCIP_HEUR **heur, const char *name, const char *desc, char dispchar, int priority, int freq, int freqofs, int maxdepth, SCIP_HEURTIMING timingmask, SCIP_Bool usessubscip, SCIP_DECL_HEUREXEC((*heurexec)), SCIP_HEURDATA *heurdata)
SCIP_RETCODE SCIPsetHeurCopy(SCIP *scip, SCIP_HEUR *heur,)
const char * SCIPheurGetName(SCIP_HEUR *heur)
void SCIPheurSetData(SCIP_HEUR *heur, SCIP_HEURDATA *heurdata)
#define SCIPallocMemoryArray(scip, ptr, num)
#define SCIPallocBufferArray(scip, ptr, num)
#define SCIPfreeBufferArray(scip, ptr)
#define SCIPfreeMemoryArray(scip, ptr)
#define SCIPfreeBlockMemory(scip, ptr)
#define SCIPallocBlockMemory(scip, ptr)
SCIP_RETCODE SCIPtrySolFree(SCIP *scip, SCIP_SOL **sol, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *stored)
SCIP_RETCODE SCIPsetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var, SCIP_Real val)
SCIP_RETCODE SCIPcreateVar(SCIP *scip, SCIP_VAR **var, const char *name, SCIP_Real lb, SCIP_Real ub, SCIP_Real obj, SCIP_VARTYPE vartype, SCIP_Bool initial, SCIP_Bool removable, SCIP_DECL_VARDELORIG((*vardelorig)), SCIP_DECL_VARTRANS((*vartrans)), SCIP_DECL_VARDELTRANS((*vardeltrans)), SCIP_DECL_VARCOPY((*varcopy)), SCIP_VARDATA *vardata)
SCIP_RETCODE SCIPchgVarUbLazy(SCIP *scip, SCIP_VAR *var, SCIP_Real lazyub)
void SCIPsortDownIntInt(int *intarray1, int *intarray2, int len)
void SCIPsortDownInt(int *intarray, int len)
SCIPcreateSol(scip, &heurdata->sol, heur))
static SCIP_RETCODE greedyStableSet(SCIP *scip, TCLIQUE_GRAPH *graph, int *colors, int nextcolor)
static SCIP_RETCODE runTabuCol(TCLIQUE_GRAPH *graph, int seed, int maxcolors, int *colors, SCIP_HEURDATA *heurdata, SCIP_Bool *success)
#define DEFAULT_TABUGAMMA
SCIP_RETCODE SCIPincludeHeurInit(SCIP *scip)
static SCIP_RETCODE greedyInitialColoring(SCIP *scip, TCLIQUE_GRAPH *graph, int *colors, int *ncolors)
static SCIP_Bool hasUncoloredNode(int nnodes, int *colors)
static int getNViolatedEdges(TCLIQUE_GRAPH *graph, int *colors)
initial primal heuristic for the vertex coloring problem
assert(minobj< SCIPgetCutoffbound(scip))
variable pricer for the vertex coloring problem
SCIP_CONS ** COLORprobGetConstraints(SCIP *scip)
SCIP_RETCODE COLORprobAddNewStableSet(SCIP *scip, int *stablesetnodes, int nstablesetnodes, int *setindex)
int COLORprobGetNNodes(SCIP *scip)
SCIP_VAR * COLORprobGetVarForStableSet(SCIP *scip, int setindex)
TCLIQUE_GRAPH * COLORprobGetGraph(SCIP *scip)
SCIP_RETCODE COLORprobAddVarForStableSet(SCIP *scip, int setindex, SCIP_VAR *var)
int COLORprobGetNStableSets(SCIP *scip)
problem data for vertex coloring algorithm
file reader for vertex coloring instances
int * tcliqueGetLastAdjedge(TCLIQUE_GRAPH *tcliquegraph, int node)
int * tcliqueGetDegrees(TCLIQUE_GRAPH *tcliquegraph)
int * tcliqueGetFirstAdjedge(TCLIQUE_GRAPH *tcliquegraph, int node)
struct TCLIQUE_Graph TCLIQUE_GRAPH
struct SCIP_Cons SCIP_CONS
#define SCIP_DECL_HEURCOPY(x)
struct SCIP_HeurData SCIP_HEURDATA
struct SCIP_Heur SCIP_HEUR
#define SCIP_DECL_HEURFREE(x)
#define SCIP_DECL_HEUREXEC(x)
enum SCIP_Retcode SCIP_RETCODE
struct SCIP_VarData SCIP_VARDATA