SCIP Doxygen Documentation
Loading...
Searching...
No Matches
heur_init.c
Go to the documentation of this file.
1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2/* */
3/* This file is part of the program and library */
4/* SCIP --- Solving Constraint Integer Programs */
5/* */
6/* Copyright (c) 2002-2026 Zuse Institute Berlin (ZIB) */
7/* */
8/* Licensed under the Apache License, Version 2.0 (the "License"); */
9/* you may not use this file except in compliance with the License. */
10/* You may obtain a copy of the License at */
11/* */
12/* http://www.apache.org/licenses/LICENSE-2.0 */
13/* */
14/* Unless required by applicable law or agreed to in writing, software */
15/* distributed under the License is distributed on an "AS IS" BASIS, */
16/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
17/* See the License for the specific language governing permissions and */
18/* limitations under the License. */
19/* */
20/* You should have received a copy of the Apache-2.0 license */
21/* along with SCIP; see the file LICENSE. If not visit scipopt.org. */
22/* */
23/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
24
25/**@file heur_init.c
26 * @brief initial primal heuristic for the vertex coloring problem
27 * @author Gerald Gamrath
28 *
29 * This file implements a heuristic which computes a starting solution for the coloring problem. It
30 * therefore computes maximal stable sets and creates one variable for each set, which is added to the
31 * LP.
32 *
33 * The heuristic is called only one time: before solving the root node.
34 *
35 * It checks whether a solution-file was read in and a starting solution already exists. If this
36 * is not the case, an initial possible coloring is computed by a greedy method. After that, a
37 * tabu-search is called, which tries to reduce the number of colors needed. The tabu-search algorithm
38 * follows the description in
39 *
40 * "A Survey of Local Search Methods for Graph Coloring"@n
41 * by P. Galinier and A. Hertz@n
42 * Computers & Operations Research, 33 (2006)
43 *
44 * The tabu-search works as follows: given the graph and a number of colors it tries to color the
45 * nodes of the graph with at most the given number of colors. It starts with a random coloring. In
46 * each iteration, it counts the number of violated edges, that is, edges for which both incident
47 * nodes have the same color. It now switches one node to another color in each iteration, taking
48 * the node and color, that cause the greatest reduction of the number of violated edges, or if no
49 * such combination exists, the node and color that cause the smallest increase of that number. The
50 * former color of the node is forbidden for a couple of iterations in order to give the possibility
51 * to leave a local minimum.
52 *
53 * As long as the tabu-search finds a solution with the given number of colors, this number is reduced
54 * by 1 and the tabu-search is called another time. If no coloring was found after a given number
55 * of iterations, the tabu-search is stopped and variables for all sets of the last feasible coloring
56 * are created and added to the LP (after possible extension to maximal stable sets).
57 *
58 * The variables of these sets result in a feasible starting solution of the coloring problem.
59 *
60 * The tabu-search can be deactivated by setting the parameter <heuristics/initcol/usetabu> to
61 * FALSE. The number of iterations after which the tabu-search stops if no solution was yet found
62 * can be changed by the param <heuristics/initcol/maxiter>. A great effect is also obtained by
63 * changing the parameters <heuristics/initcol/tabubase> and <heuristics/initcol/tabugamma>, which
64 * determine the number of iterations for which the former color of a node is forbidden; more
65 * precisely, this number is <tabubase> + ncritical * <tabugamma>, where ncritical is the number
66 * of nodes, which are incident to violated edges. Finally, the level of output and the frequency of
67 * status lines can be changed by <heuristics/initcol/output> and <heuristics/initcol/dispfreq>.
68 */
69
70/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
71
72#include "heur_init.h"
73#include "pricer_coloring.h"
74#include "probdata_coloring.h"
75#include "reader_col.h"
76#include "scip/cons_setppc.h"
77#include "cons_storeGraph.h"
78#include "tclique/tclique.h"
79
80#define HEUR_NAME "initcol"
81#define HEUR_DESC "initial primal heuristic for coloring"
82#define HEUR_DISPCHAR 't'
83#define HEUR_PRIORITY 1
84#define HEUR_FREQ 1
85#define HEUR_FREQOFS 0
86#define HEUR_MAXDEPTH 0
87#define HEUR_TIMING SCIP_HEURTIMING_BEFORENODE
88#define HEUR_USESSUBSCIP FALSE /**< does the heuristic use a secondary SCIP instance? */
89
90
91/* default values for parameters */
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
98
99
100
101/*
102 * Data structures
103 */
104
105/** primal heuristic data */
106struct SCIP_HeurData
107{
108 SCIP_Bool usetabu; /**< should the tabu search heuristic be used in order to improve the greedy-solution? */
109 int maxiter; /**< maximal number of iterations to be performed in each tabu-run */
110 int tabubase; /**< constant part of the tabu-duration */
111 SCIP_Real tabugamma; /**< factor for the linear part of the tabu-duration */
112 int output; /**< verbosity level for the output of the tabu search, 0: no output, 1: normal, 2: high */
113 int dispfreq; /**< frequency for displaying status information, only active with output verbosity level 2 */
114};
115
116
117
118
119/*
120 * Local methods
121 */
122
123
124
125/** checks whether one of the nodes has no color respectively has color -1 in the given array */
126static
128 int nnodes, /**< the graph that should be colored */
129 int* colors /**< array of ints representing the colors */
130 )
131{
132 int i;
133
134 assert(colors != NULL);
135
136 for( i = 0; i < nnodes; i++)
137 {
138 /* node not yet colored */
139 if(colors[i] == -1)
140 {
141 return TRUE;
142 }
143 }
144 return FALSE;
145}
146
147
148/** computes a stable set with a greedy-method and colors its nodes */
149static
151 SCIP* scip, /**< SCIP data structure */
152 TCLIQUE_GRAPH* graph, /**< pointer to graph data structure */
153 int* colors, /**< array of ints representing the different colors, -1 means uncolored */
154 int nextcolor /**< color in which the stable set will be colored */
155 )
156{
157 SCIP_Bool indNode;
158 int nnodes;
159 int i;
160 int j;
161 int* degrees;
162 int* sortednodes;
163 int* values;
164 int* stablesetnodes;
165 int nstablesetnodes;
166
167 assert(graph != NULL);
168 assert(colors != NULL);
169
170 /* get number of nodes */
171 nnodes = tcliqueGetNNodes(graph);
172
173 /* get the degrees and weights for the nodes in the graph */
174 degrees = tcliqueGetDegrees(graph);
175 SCIP_CALL( SCIPallocBufferArray(scip, &stablesetnodes, nnodes) );
177 SCIP_CALL( SCIPallocBufferArray(scip, &sortednodes, nnodes) );
178
179 /* set values to the nodes which are used for sorting them */
180 /* value = degree of the node + number of nodes if the node is yet uncolored,
181 therefore the yet colored nodes have lower values than the not yet colored nodes */
182 for( i = 0; i < nnodes; i++ )
183 {
184 sortednodes[i] = i;
185 values[i] = degrees[i] + ( colors[i] == -1 ? nnodes : 0);
186 }
187
188 /* sort the nodes w.r.t. the computed values */
189 SCIPsortDownIntInt(values, sortednodes, nnodes);
190
191 /* insert first node */
192 stablesetnodes[0] = sortednodes[0];
193 nstablesetnodes = 1;
194 for( i = 1; i < nnodes; i++)
195 {
196 if( colors[sortednodes[i]] != -1 )
197 {
198 break;
199 }
200 indNode = TRUE;
201 for( j = 0; j < nstablesetnodes; j++ )
202 {
203 if( tcliqueIsEdge(graph, sortednodes[i], stablesetnodes[j]) )
204 {
205 indNode = FALSE;
206 break;
207 }
208 }
209 if( indNode == TRUE )
210 {
211 stablesetnodes[nstablesetnodes] = sortednodes[i];
212 nstablesetnodes++;
213 }
214
215 }
216 for( i = 0; i < nstablesetnodes; i++ )
217 {
218 assert(colors[stablesetnodes[i]] == -1);
219 colors[stablesetnodes[i]] = nextcolor;
220 }
221 SCIPfreeBufferArray(scip, &stablesetnodes);
222 SCIPfreeBufferArray(scip, &sortednodes);
223 SCIPfreeBufferArray(scip, &values);
224
225 return SCIP_OKAY;
226}
227
228
229static
230/** computes the initial coloring with a greedy method */
232 SCIP* scip, /**< SCIP data structure */
233 TCLIQUE_GRAPH* graph, /**< pointer to graph data structure */
234 int* colors, /**< array of ints representing the different colors */
235 int* ncolors /**< number of colors needed */
236 )
237{
238 int nnodes;
239 int i;
240 int color;
241
242 assert(scip != NULL);
243 assert(graph != NULL);
244 assert(colors != NULL);
245
247 assert(nnodes > 0);
248
249 for( i = 0; i < nnodes; i++ )
250 {
251 colors[i] = -1;
252 }
253
254 color = 0;
255 /* create stable sets until all Nodes are covered */
256 while( hasUncoloredNode(nnodes, colors) )
257 {
258 SCIP_CALL( greedyStableSet(scip, graph, colors, color) );
259 color++;
260 }
261 *ncolors = color;
262
263 return SCIP_OKAY;
264
265}
266
267
268#ifndef NDEBUG
269/** computes the number of violated edges, that means the number of edges (i,j) where i and j have the same color */
270static
272 TCLIQUE_GRAPH* graph, /**< the graph */
273 int* colors /**< colors of the nodes */
274 )
275{
276 int nnodes;
277 int i;
278 int* j;
279 int cnt;
280
281 assert(graph != NULL);
282 assert(colors != NULL);
283
284 /* get the number of nodes */
285 nnodes = tcliqueGetNNodes(graph);
286 cnt = 0;
287
288 /* count the number of violated edges, only consider edges (i,j) with i > j since the graph is undirected bu */
289 for( i = 0; i < nnodes; i++ )
290 {
291 for( j = tcliqueGetFirstAdjedge(graph,i); j <= tcliqueGetLastAdjedge(graph,i) && *j < i; j++ )
292 {
293 if( colors[i] == colors[*j] )
294 cnt++;
295 }
296 }
297 return cnt;
298}
299#endif
300
301
302/** runs tabu coloring heuristic, gets a graph and a number of colors
303 * and tries to color the graph with at most that many colors;
304 * starts with a random coloring and switches one node to another color in each iteration,
305 * forbidding the old color for a couple of iterations
306 */
307static
309 TCLIQUE_GRAPH* graph, /**< the graph, that should be colored */
310 int seed, /**< seed for the first random coloring */
311 int maxcolors, /**< number of colors, which are allowed */
312 int* colors, /**< output: the computed coloring */
313 SCIP_HEURDATA* heurdata, /**< data of the heuristic */
314 SCIP_Bool* success /**< pointer to store if something went wrong */
315 )
316{
317 int nnodes;
318 int** tabu;
319 int** adj;
320 int obj;
321 int bestobj;
322 int i;
323 int j;
324 int node1;
325 int node2;
326 int color1;
327 int color2;
328 int* firstedge;
329 int* lastedge;
330 SCIP_Bool restrictive;
331 int iter;
332 int minnode;
333 int mincolor;
334 int minvalue;
335 int ncritical;
336 SCIP_Bool aspiration;
337 int d;
338 int oldcolor;
339
340 assert(graph != NULL);
341 assert(heurdata != NULL);
342 assert(success != NULL);
343
344 if( heurdata->output >= 1 )
345 printf("Running tabu coloring with maxcolors = %d...\n", maxcolors);
346
347 /* get size */
348 nnodes = tcliqueGetNNodes(graph);
349
350 srand( seed ); /*lint !e732*/
351
352 /* init random coloring, optionally keeping colors from a previous coloring */
353 for( i = 0; i < nnodes; i++ )
354 {
355 if( colors[i] < 0 || colors[i] >= maxcolors )
356 {
357 int rnd = rand();
358 colors[i] = rnd % maxcolors;
359 }
360 assert( 0 <= colors[i] && colors[i] < maxcolors );
361 }
362
363 /* init matrices */
364 SCIP_CALL( SCIPallocMemoryArray(scip, &tabu, nnodes) ); /* stores iteration at which tabu node/color pair will
365 * expire to be tabu
366 */
367 SCIP_CALL( SCIPallocMemoryArray(scip, &adj, nnodes) ); /* stores number of adjacent nodes using specified color */
368
369 for( i = 0; i < nnodes; i++ )
370 {
371 SCIP_CALL( SCIPallocMemoryArray(scip, &(tabu[i]), maxcolors) ); /*lint !e866*/
372 SCIP_CALL( SCIPallocMemoryArray(scip, &(adj[i]), maxcolors) ); /*lint !e866*/
373 for( j = 0; j < maxcolors; j++ )
374 {
375 tabu[i][j] = 0;
376 adj[i][j] = 0;
377 }
378 }
379
380 /* objective */
381 obj = 0;
382
383 /* init adj-matrix and objective */
384 for( node1 = 0; node1 < nnodes; node1++ )
385 {
386 color1 = colors[node1];
387 firstedge = tcliqueGetFirstAdjedge(graph, node1);
388 lastedge = tcliqueGetLastAdjedge(graph, node1);
389 while( firstedge <= lastedge )
390 {
391 node2 = *firstedge;
392 color2 = colors[node2];
393 assert( 0 <= color2 && color2 < maxcolors );
394 (adj[node1][color2])++;
395 if( color1 == color2 )
396 obj++;
397 firstedge++;
398 }
399 }
400 assert( obj % 2 == 0 );
401 obj = obj / 2;
402 assert( obj == getNViolatedEdges(graph, colors) );
403
404 bestobj = obj;
405 restrictive = FALSE;
406 iter = 0;
407 if( obj > 0 )
408 {
409 /* perform predefined number of iterations */
410 for( iter = 1; iter <= heurdata->maxiter; iter++ )
411 {
412 /* find best 1-move among those with critical vertex */
413 minnode = -1;
414 mincolor = -1;
415 minvalue = nnodes * nnodes;
416 ncritical = 0;
417 for( node1 = 0; node1 < nnodes; node1++ )
418 {
419 aspiration = FALSE;
420 color1 = colors[node1];
421 assert( 0 <= color1 && color1 < maxcolors );
422
423 /* if node is critical (has incident violated edges) */
424 if( adj[node1][color1] > 0 )
425 {
426 ncritical++;
427 /* check all colors */
428 for( j = 0; j < maxcolors; j++ )
429 {
430 /* if color is new */
431 if( j != color1 )
432 {
433 /* change in the number of violated edges: */
434 d = adj[node1][j] - adj[node1][color1];
435
436 /* 'aspiration criterion': stop if we get feasible solution */
437 if( obj + d == 0 )
438 {
439 if( heurdata->output >= 1 )
440 printf(" Feasible solution found after %d iterations!\n\n", iter);
441 minnode = node1;
442 mincolor = j;
443 minvalue = d;
444 aspiration = TRUE;
445 break;
446 }
447
448 /* if not tabu and better value */
449 if( tabu[node1][j] < iter && d < minvalue )
450 {
451 minnode = node1;
452 mincolor = j;
453 minvalue = d;
454 }
455 }
456 }
457 }
458 if( aspiration )
459 break;
460 }
461
462 /* if no candidate could be found - tabu list is too restrictive: just skip current iteration */
463 if( minnode == -1 )
464 {
465 restrictive = TRUE;
466 continue;
467 }
468 assert( minnode != -1 );
469 assert( mincolor >= 0 );
470
471 /* perform changes */
472 assert( colors[minnode] != mincolor );
473 oldcolor = colors[minnode];
474 colors[minnode] = mincolor;
475 obj += minvalue;
476 assert( obj == getNViolatedEdges(graph, colors) );
477 if( obj < bestobj )
478 bestobj = obj;
479
480 if( heurdata->output == 2 && (iter) % (heurdata->dispfreq) == 0 )
481 {
482 printf("Iter: %d obj: %d critical: %d node: %d color: %d delta: %d\n", iter, obj, ncritical, minnode,
483 mincolor, minvalue);
484 }
485
486 /* terminate if valid coloring has been found */
487 if( obj == 0 )
488 break;
489
490 /* update tabu list */
491 assert( tabu[minnode][oldcolor] < iter );
492 tabu[minnode][oldcolor] = iter + (heurdata->tabubase) + (int) (((double) ncritical) * (heurdata->tabugamma));
493
494 /* update adj matrix */
495 for( firstedge = tcliqueGetFirstAdjedge(graph, minnode); firstedge <= tcliqueGetLastAdjedge(graph, minnode); firstedge++ )
496 {
497 (adj[*firstedge][mincolor])++;
498 (adj[*firstedge][oldcolor])--;
499 }
500 }
501 }
502 if( heurdata->output == 2 )
503 {
504 printf("Best objective: %d\n ", bestobj);
505 if( restrictive )
506 {
507 printf("\nTabu list is probably too restrictive.\n");
508 }
509 printf("\n");
510 }
511 if( heurdata->output >= 1 && bestobj != 0 )
512 {
513 printf(" No feasible solution found after %d iterations!\n\n", iter-1);
514 }
515
516 for( i = 0; i < nnodes; i++ )
517 {
518 SCIPfreeMemoryArray(scip, &(adj[i]));
519 SCIPfreeMemoryArray(scip, &(tabu[i]));
520 }
523
524 /* check whether valid coloring has been found */
525 *success = (obj == 0);
526
527 return SCIP_OKAY;
528}
529
530
531/*
532 * Callback methods of primal heuristic
533 */
534
535/** copy method for primal heuristic plugins (called when SCIP copies plugins) */
536static
538{ /*lint --e{715}*/
539 assert(scip != NULL);
540 assert(heur != NULL);
541
543
544 return SCIP_OKAY;
545}
546
547/** destructor of primal heuristic to free user data (called when SCIP is exiting) */
548/**! [SnippetHeurFreeInit] */
549static
551{
553
554 /* free heuristic rule data */
557 SCIPheurSetData(heur, NULL);
558
559 return SCIP_OKAY;
560}
561/**! [SnippetHeurFreeInit] */
562
563
564/** execution method of primal heuristic */
565static
567{
568 int i;
569 int j;
570 int k;
571 int nnodes;
572 SCIP_SOL* sol;
573 SCIP_Bool stored;
574 SCIP_Bool success;
575 SCIP_Bool indnode;
576 int* colors;
577 int* bestcolors;
578 int ncolors;
579 int nstablesetnodes;
580 int setnumber;
581 SCIP_VAR* var;
582 SCIP_CONS** constraints;
583 TCLIQUE_GRAPH* graph;
585 SCIP_Bool onlybest;
586 int maxvarsround;
587
589 assert(heurdata != NULL);
590
593 graph = COLORprobGetGraph(scip);
594
595 /* create stable sets if no solution was read */
596 if( COLORprobGetNStableSets(scip) == 0 )
597 {
598 /* get memory for arrays */
600 SCIP_CALL( SCIPallocBufferArray(scip, &bestcolors, nnodes) );
601
602 /* get the node-constraits */
603 constraints = COLORprobGetConstraints(scip);
604 assert(constraints != NULL);
605
606 /* compute an initial coloring with a greedy method */
607 SCIP_CALL( greedyInitialColoring(scip, graph, bestcolors, &ncolors) );
608
609 if( heurdata->usetabu )
610 {
611 /* try to find better colorings with tabu search method */
612 success = TRUE;
613 while( success )
614 {
615 ncolors--;
616
617 /* initialize with colors from previous iteration; the last color is randomized */
618 SCIP_CALL( runTabuCol(graph, 0, ncolors, colors, heurdata, &success) );
619
620 if( success )
621 {
622 for( i = 0; i < nnodes; i++ )
623 bestcolors[i] = colors[i];
624 }
625 }
626 }
627
628 /* create vars for the computed coloring */
629 for( i = 0; i <= ncolors; i++ )
630 {
631 /* save nodes with color i in the array colors and the number of such nodes in nstablesetnodes */
632 nstablesetnodes = 0;
633 for( j = 0; j < nnodes; j++ )
634 {
635 if( bestcolors[j] == i )
636 {
637 colors[nstablesetnodes] = j;
638 nstablesetnodes++;
639 }
640 }
641
642 /* try to add more nodes to the stable set without violating the stability */
643 for( j = 0; j < nnodes; j++ )
644 {
645 indnode = TRUE;
646 for( k = 0; k < nstablesetnodes; k++ )
647 {
648 if( j == colors[k] || tcliqueIsEdge(graph, j, colors[k]) )
649 {
650 indnode = FALSE;
651 break;
652 }
653 }
654
655 if( indnode == TRUE )
656 {
657 colors[nstablesetnodes] = j;
658 nstablesetnodes++;
659 }
660 }
661
662 /* create variable for the stable set and add it to SCIP */
663 SCIPsortDownInt(colors, nstablesetnodes);
664 SCIP_CALL( COLORprobAddNewStableSet(scip, colors, nstablesetnodes, &setnumber) );
665 assert(setnumber != -1);
666
667 /* create variable for the stable set and add it to SCIP */
669 TRUE, TRUE, NULL, NULL, NULL, NULL, (SCIP_VARDATA*)(size_t)setnumber) ); /*lint !e571*/
670
674
675 for( j = 0; j < nstablesetnodes; j++ )
676 {
677 /* add variable to node constraints of nodes in the set */
678 SCIP_CALL( SCIPaddCoefSetppc(scip, constraints[colors[j]], var) );
679 }
680 }
681
682 SCIPfreeBufferArray(scip, &bestcolors);
683 SCIPfreeBufferArray(scip, &colors);
684
685 }
686
687 /* create solution consisting of all yet created stable sets, i.e., all sets of the solution given by the solution
688 * file or created by the greedy and tabu search */
690 assert(sol != NULL);
691 for( i = 0; i < COLORprobGetNStableSets(scip); i++ )
692 {
694 }
696 assert(stored);
697
698 /* set maximal number of variables to be priced in each round */
699 SCIP_CALL( SCIPgetBoolParam(scip, "pricers/coloring/onlybest", &onlybest) );
700 if( onlybest )
702 else
703 maxvarsround = 1;
704 SCIP_CALL( SCIPsetIntParam(scip, "pricers/coloring/maxvarsround", maxvarsround) );
705
707
708 return SCIP_OKAY;
709}/*lint !e715*/
710
711/*
712 * primal heuristic specific interface methods
713 */
714
715/** creates the init primal heuristic and includes it in SCIP */
717 SCIP* scip /**< SCIP data structure */
718 )
719{
721 SCIP_HEUR* heur;
722
723 /* create init primal heuristic data */
725
726 heur = NULL;
727 /* include primal heuristic */
730 assert(heur != NULL);
731
732 SCIP_CALL( SCIPsetHeurCopy(scip, heur, heurCopyInit) );
733 SCIP_CALL( SCIPsetHeurFree(scip, heur, heurFreeInit) );
734
735 /* add parameters */
737 "heuristics/initcol/usetabu",
738 "should the tabu search heuristic be used in order to improve the greedy-solution?",
739 &heurdata->usetabu, FALSE, DEFAULT_USETABU, NULL, NULL) );
740
742 "heuristics/initcol/maxiter",
743 "maximal number of iterations to be performed in each tabu-run",
744 &heurdata->maxiter, TRUE, DEFAULT_MAXITER, 0, INT_MAX, NULL, NULL) );
745
747 "heuristics/initcol/tabubase",
748 "constant part of the tabu-duration",
749 &heurdata->tabubase, TRUE, DEFAULT_TABUBASE, 0, INT_MAX, NULL, NULL) );
750
752 "heuristics/initcol/tabugamma",
753 "factor for the linear part of the tabu-duration",
754 &heurdata->tabugamma, TRUE, DEFAULT_TABUGAMMA, -100.0, 100.0, NULL, NULL) );
755
757 "heuristics/initcol/output",
758 "verbosity level for the output of the tabu search, 0: no output, 1: normal, 2: high",
759 &heurdata->output, FALSE, DEFAULT_OUTPUT, 0, 2, NULL, NULL) );
760
762 "heuristics/initcol/dispfreq",
763 "frequency for displaying status information, only active with output verbosity level 2",
764 &heurdata->dispfreq, TRUE, DEFAULT_DISPFREQ, 0, INT_MAX, NULL, NULL) );
765
766
767 return SCIP_OKAY;
768}
Constraint handler for the set partitioning / packing / covering constraints .
constraint handler for storing the graph at each node of the tree
#define NULL
Definition def.h:257
#define SCIP_Bool
Definition def.h:100
#define SCIP_STRINGEQ(name, reference, retcode)
Definition def.h:454
#define SCIP_Real
Definition def.h:165
#define TRUE
Definition def.h:102
#define FALSE
Definition def.h:103
#define SCIP_CALL(x)
Definition def.h:364
#define nnodes
Definition gastrans.c:74
SCIP_RETCODE SCIPaddCoefSetppc(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var)
SCIP_RETCODE SCIPaddVar(SCIP *scip, SCIP_VAR *var)
Definition scip_prob.c:1907
SCIP_RETCODE SCIPgetBoolParam(SCIP *scip, const char *name, SCIP_Bool *value)
Definition scip_param.c:250
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)
Definition scip_param.c:83
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)
Definition scip_param.c:139
SCIP_RETCODE SCIPsetIntParam(SCIP *scip, const char *name, int value)
Definition scip_param.c:487
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)
Definition scip_param.c:57
SCIP_RETCODE SCIPsetHeurFree(SCIP *scip, SCIP_HEUR *heur,)
Definition scip_heur.c:183
SCIP_HEURDATA * SCIPheurGetData(SCIP_HEUR *heur)
Definition heur.c:1368
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)
Definition scip_heur.c:122
SCIP_RETCODE SCIPsetHeurCopy(SCIP *scip, SCIP_HEUR *heur,)
Definition scip_heur.c:167
const char * SCIPheurGetName(SCIP_HEUR *heur)
Definition heur.c:1467
void SCIPheurSetData(SCIP_HEUR *heur, SCIP_HEURDATA *heurdata)
Definition heur.c:1378
#define SCIPallocMemoryArray(scip, ptr, num)
Definition scip_mem.h:64
#define SCIPallocBufferArray(scip, ptr, num)
Definition scip_mem.h:124
#define SCIPfreeBufferArray(scip, ptr)
Definition scip_mem.h:136
#define SCIPfreeMemoryArray(scip, ptr)
Definition scip_mem.h:80
#define SCIPfreeBlockMemory(scip, ptr)
Definition scip_mem.h:108
#define SCIPallocBlockMemory(scip, ptr)
Definition scip_mem.h:89
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)
Definition scip_sol.c:4114
SCIP_RETCODE SCIPsetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var, SCIP_Real val)
Definition scip_sol.c:1569
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)
Definition scip_var.c:120
SCIP_RETCODE SCIPchgVarUbLazy(SCIP *scip, SCIP_VAR *var, SCIP_Real lazyub)
Definition scip_var.c:6362
void SCIPsortDownIntInt(int *intarray1, int *intarray2, int len)
void SCIPsortDownInt(int *intarray, int len)
#define HEUR_TIMING
return SCIP_OKAY
#define HEUR_FREQOFS
#define HEUR_DESC
#define HEUR_DISPCHAR
#define HEUR_MAXDEPTH
#define HEUR_PRIORITY
#define HEUR_NAME
#define HEUR_FREQ
#define HEUR_USESSUBSCIP
SCIPcreateSol(scip, &heurdata->sol, heur))
static SCIP_RETCODE greedyStableSet(SCIP *scip, TCLIQUE_GRAPH *graph, int *colors, int nextcolor)
Definition heur_init.c:150
static SCIP_RETCODE runTabuCol(TCLIQUE_GRAPH *graph, int seed, int maxcolors, int *colors, SCIP_HEURDATA *heurdata, SCIP_Bool *success)
Definition heur_init.c:308
#define DEFAULT_TABUGAMMA
Definition heur_init.c:95
SCIP_RETCODE SCIPincludeHeurInit(SCIP *scip)
Definition heur_init.c:716
#define DEFAULT_TABUBASE
Definition heur_init.c:94
static SCIP_RETCODE greedyInitialColoring(SCIP *scip, TCLIQUE_GRAPH *graph, int *colors, int *ncolors)
Definition heur_init.c:231
static SCIP_Bool hasUncoloredNode(int nnodes, int *colors)
Definition heur_init.c:127
#define DEFAULT_DISPFREQ
Definition heur_init.c:97
static int getNViolatedEdges(TCLIQUE_GRAPH *graph, int *colors)
Definition heur_init.c:271
#define DEFAULT_USETABU
Definition heur_init.c:92
initial primal heuristic for the vertex coloring problem
static SCIP_SOL * sol
SCIP_Real obj
assert(minobj< SCIPgetCutoffbound(scip))
#define DEFAULT_MAXITER
Definition heur_mpec.c:74
SCIP_VAR * var
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
#define DEFAULT_OUTPUT
Definition sepa_cgmip.c:149
tclique user interface
int * tcliqueGetLastAdjedge(TCLIQUE_GRAPH *tcliquegraph, int node)
int * tcliqueGetDegrees(TCLIQUE_GRAPH *tcliquegraph)
int * tcliqueGetFirstAdjedge(TCLIQUE_GRAPH *tcliquegraph, int node)
struct TCLIQUE_Graph TCLIQUE_GRAPH
Definition tclique.h:49
struct SCIP_Cons SCIP_CONS
Definition type_cons.h:63
#define SCIP_DECL_HEURCOPY(x)
Definition type_heur.h:97
struct SCIP_HeurData SCIP_HEURDATA
Definition type_heur.h:77
struct SCIP_Heur SCIP_HEUR
Definition type_heur.h:76
#define SCIP_DECL_HEURFREE(x)
Definition type_heur.h:105
#define SCIP_DECL_HEUREXEC(x)
Definition type_heur.h:163
@ SCIP_DIDNOTFIND
Definition type_result.h:44
@ SCIP_FOUNDSOL
Definition type_result.h:56
@ SCIP_INVALIDCALL
enum SCIP_Retcode SCIP_RETCODE
struct Scip SCIP
Definition type_scip.h:39
struct SCIP_Sol SCIP_SOL
Definition type_sol.h:57
struct SCIP_VarData SCIP_VARDATA
Definition type_var.h:167
struct SCIP_Var SCIP_VAR
Definition type_var.h:166
@ SCIP_VARTYPE_BINARY
Definition type_var.h:64