GCG 4.1.1 (dev)

Generic Column Generation

Loading...
Searching...
No Matches
solver_cliquer.c
Go to the documentation of this file.
1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2/* */
3/* This file is part of the program and library */
4/* GCG --- Generic Column Generation */
5/* a Dantzig-Wolfe decomposition based extension */
6/* of the branch-cut-and-price framework */
7/* SCIP --- Solving Constraint Integer Programs */
8/* */
9/* Copyright (C) 2010-2026 Operations Research, RWTH Aachen University */
10/* Zuse Institute Berlin (ZIB) */
11/* */
12/* Licensed under the Apache License, Version 2.0 (the "License"); */
13/* you may not use this file except in compliance with the License. */
14/* You may obtain a copy of the License at */
15/* */
16/* http://www.apache.org/licenses/LICENSE-2.0 */
17/* */
18/* Unless required by applicable law or agreed to in writing, software */
19/* distributed under the License is distributed on an "AS IS" BASIS, */
20/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
21/* See the License for the specific language governing permissions and */
22/* limitations under the License. */
23/* */
24/* You should have received a copy of the Apache-2.0 license */
25/* along with GCG; see the file LICENSE. If not visit gcg.or.rwth-aachen.de.*/
26/* */
27/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
28
29/**@file solver_cliquer.c
30 * @brief heuristic solver for pricing problems that solves independent set problems with cliquer
31 * @author Henri Lotze
32 * @author Christian Puchert
33 * @author Johannes Ehls
34 */
35
36/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
37/* #define SCIP_DEBUG */
38
39#include <assert.h>
40
41#include "gcg/solver_cliquer.h"
42#include "scip/cons_linear.h"
43#include "scip/cons_varbound.h"
44#include "gcg/pub_solver.h"
45#include "gcg/pricer_gcg.h"
46#include "gcg/relax_gcg.h"
47#include "gcg/pub_gcgcol.h"
48#include "gcg/pub_gcgvar.h"
49#include "gcg/gcg.h"
50#include "gcg/scip_misc.h"
51
52#include "cliquer/cliquer.h"
53
54
55#define SOLVER_NAME "cliquer"
56#define SOLVER_DESC "heuristic solver for pricing problems that solves independent set problems with cliquer"
57#define SOLVER_PRIORITY 150
58
59#define SOLVER_HEURENABLED TRUE /**< indicates whether the solver should be enabled */
60#define SOLVER_EXACTENABLED FALSE /**< indicates whether the solver should be enabled */
61
62#define DEFAULT_MAXNODES 200
63#define DEFAULT_MAXDENSITY 1.0
64#define DEFAULT_SKIPCHECKSNODELIMIT 75
65#define DEFAULT_USELINCUTOFF TRUE
66#define DEFAULT_SLOPE -1980
67#define DEFAULT_INTERCEPT 2000
68#define DEFAULT_OBJCOEFDISTR 0
69#define DEFAULT_USEMULTIPL FALSE
70#define DEFAULT_MAXCLIQUECONSPERC 0.5
71
72/*
73 * Data structures.
74 */
75
76/* Constraint type (combination of handler type and constraint form) to use in this solver. */
89
91{
92 SCIP_Real maxdensity; /**< maximum graph density the solver should run on */
93 int skipchecksnodelimit;/**< maximum number of graph nodes for which additional checks (density threshold / linear cutoff) are skipped */
94 int maxnodes; /**< maximum number of graph nodes the solver should run on */
95 SCIP_Real maxcliqueconsperc; /**< maximum clique constraint percentage the solver should run on */
96 SCIP_Bool* isnotapplicable; /**< array tracking if solver is not applicable in root node (& no cuts) */
97 int objcoefdistr; /**< param deciding strategy for distributing obj coefs of coupling vars */
98 SCIP_Bool usemultiplicity; /**< boolean for activating usage of var multiplicities for weighting */
99 SCIP_Bool uselincutoff; /**< boolean for activating linear cutoff */
100 SCIP_Real lincutoffslope; /**< slope for linear cutoff */
101 SCIP_Real lincutoffintercept; /**< intercept for linear cutoff */
102};
103
104
105/*
106 * Local methods
107 */
108
109/** Returns whether the given var is linked in some way with other variables */
110static INLINE
112 SCIP_VAR** linkedvars, /**< Array of variables that are linked by eq-constraints */
113 int nlinkedvars, /**< Index of linkedvars array */
114 SCIP_VAR* var /**< Variable whose membership in the linkedvars array is to be checked */
115 )
116{
117 SCIP_Bool islinked;
118 int i;
119
120 islinked = FALSE;
121 for( i = 0; i < nlinkedvars; ++i )
122 {
123 if( linkedvars[i] == var )
124 islinked = TRUE;
125 }
126 return islinked;
127}
128
129/** Returns whether 2 variables are linked, either simply or in a transitive way in respect to a given linkmatrix matrix.
130 * Use of the wrapper function areVarsLinked(..) is recommended
131 */
132static
134 int** linkmatrix, /**< Matrix indicating which variables are linked by a node */
135 int vindex1, /**< Problem index of the first variable in the pair that is to be checked */
136 int vindex2, /**< Problem index of the second variable in the pair that is to be checked */
137 int* vartrace, /**< Array to keep track of which nodes have already been visited during recursion */
138 int* traceindex, /**< Pointer to index to keep track of the number of visited nodes during recursion */
139 SCIP_VAR** linkedvars, /**< Array of variables that are linked by eq-constraints */
140 int nlinkedvars /**< Index of linkedvars array */
141 )
142{
143 SCIP_Bool varintrace;
144 int nextvarindex;
145 int i;
146 int j;
147
148 /* Simple, direct link? (Matrix is symmetric) */
149 if( linkmatrix[vindex1][vindex2] )
150 {
151 return TRUE;
152 }
153
154 /* More complex link by transitivity? */
155 /* Mark current node visited by adding it to the trace. */
156 vartrace[*traceindex] = vindex1;
157 (*traceindex)++;
158 for( i = 0; i < nlinkedvars; ++i )
159 {
160 nextvarindex = SCIPvarGetProbindex(linkedvars[i]);
161 if( linkmatrix[vindex1][nextvarindex] )
162 {
163 /* To ensure termination, we have to keep track of the visited vars */
164 varintrace = FALSE;
165 for( j = 0; j < *traceindex; ++j )
166 {
167 if( vartrace[j] == nextvarindex )
168 {
169 varintrace = TRUE;
170 break;
171 }
172 }
173 if( !varintrace && areVarsLinkedRec(linkmatrix, nextvarindex, vindex2, vartrace, traceindex, linkedvars, nlinkedvars) )
174 {
175 return TRUE;
176 }
177 }
178 }
179 return FALSE;
180}
181
182/** Wrapper function for areVarsLinkedRec, mallocs and cleans up the necessary memory and passes through the result */
183static
185 SCIP* scip, /**< The problem instance */
186 int** linkmatrix, /**< Matrix indicating which variables are linked by a node */
187 SCIP_VAR* var1, /**< The first variable in the pair that is to be checked */
188 SCIP_VAR* var2, /**< The second variable in the pair that is to be checked */
189 SCIP_VAR** linkedvars, /**< Array of variables that are linked by eq-constraints */
190 int nlinkedvars /**< Index of linkedvars array */
191 )
192{
193 int* vartrace;
194 int traceindex;
195 int i;
196 int vindex1;
197 int vindex2;
198 SCIP_Bool varslinked;
199
200 vindex1 = SCIPvarGetProbindex(var1);
201 vindex2 = SCIPvarGetProbindex(var2);
202
203 /* We can save effort if a direct link is present */
204 if( linkmatrix[vindex1][vindex2] )
205 {
206 return TRUE;
207 }
208
209 SCIP_CALL_ABORT( SCIPallocBufferArray(scip, &vartrace, nlinkedvars) );
210
211 traceindex = 0;
212 for( i = 0; i < nlinkedvars; ++i )
213 {
214 vartrace[i] = -1;
215 }
216
217 varslinked = areVarsLinkedRec(linkmatrix, vindex1, vindex2, vartrace, &traceindex, linkedvars, nlinkedvars);
218
219 SCIPfreeBufferArray(scip, &vartrace);
220
221 return varslinked;
222}
223
224/** Update transitivity in the linkmatrix matrix between 2 variables that are to be linked and all linked variables */
225static
227 SCIP* scip, /**< The Problem instance */
228 int** linkmatrix, /**< Matrix indicating which variables are linked by a node */
229 SCIP_VAR* var1, /**< The first variable in the pair that is to be checked */
230 SCIP_VAR* var2, /**< The second variable in the pair that is to be checked */
231 SCIP_VAR** linkedvars, /**< Array of variables that are linked by eq-constraints */
232 int* nlinkedvars /**< Index of linkedvars array */
233 )
234{
235 int varindex1, varindex2;
236 int i;
237 SCIP_Bool newvar1;
238 SCIP_Bool newvar2;
239
240 newvar1 = TRUE;
241 newvar2 = TRUE;
242
243 /* Check if the variables are part of a link already, add them elsewise to the linkedvars array */
244 for( i = 0; i < *nlinkedvars; ++i )
245 {
246 if( linkedvars[i] == var1 )
247 {
248 newvar1 = FALSE;
249 }
250 else if( linkedvars[i] == var2 )
251 {
252 newvar2 = FALSE;
253 }
254 }
255 if( newvar1 )
256 {
257 linkedvars[*nlinkedvars] = var1;
258 ++(*nlinkedvars);
259 }
260 if( newvar2 )
261 {
262 linkedvars[*nlinkedvars] = var2;
263 ++(*nlinkedvars);
264 }
265
266 varindex1 = SCIPvarGetProbindex(var1);
267 varindex2 = SCIPvarGetProbindex(var2);
268
269 /* Variables may have not been simply linked before */
270 linkmatrix[varindex1][varindex2] = 1;
271 linkmatrix[varindex2][varindex1] = 1;
272
273 /* The following loop is not necessary, as the equality graph itself is enough.
274 * One might want to check performance implications of establishing cliques from all connected components.
275 * This might increase speed of method areVarsLinked().
276 * Or the converse: Delete the following loop to save time in this function but potentially increase time
277 * consumption of areVarsLinked() which would need to traverse more nodes (increased transitivity).
278 * [Test this!]
279 */
280 for( i = 0; i < *nlinkedvars; ++i )
281 {
282 /* It is sufficient to check the links between var1 and all other vars, since var1 and var2 are linked */
283 if( varindex1 != SCIPvarGetProbindex(linkedvars[i]) )
284 {
285 if( areVarsLinked(scip, linkmatrix, var1, linkedvars[i], linkedvars, *nlinkedvars) )
286 {
287 /* Add links to both var1 and var2 */
288 linkmatrix[varindex1][SCIPvarGetProbindex(linkedvars[i])] = 1;
289 linkmatrix[SCIPvarGetProbindex(linkedvars[i])][varindex1] = 1;
290 linkmatrix[varindex2][SCIPvarGetProbindex(linkedvars[i])] = 1;
291 linkmatrix[SCIPvarGetProbindex(linkedvars[i])][varindex2] = 1;
292 }
293 }
294 }
295}
296
297/** Get the node index of a given variable in a given array (for graph), else return -1 */
298static INLINE
300 SCIP_VAR* var, /**< Variable for which the node index is to be determined */
301 SCIP_VAR** vararray, /**< Array of variables that are mapped to a node of the graph */
302 int indexcount /**< Number of variables that are mapped in the graph */
303 )
304{
305 int i;
306
307 for( i = 0; i < indexcount; ++i )
308 {
309 if( var == vararray[i] )
310 return i;
311 }
312 return -1;
313}
314
315/** Returns the node index of a given variable in the bijection or that of a linked variable, if any. */
316static
318 SCIP* scip, /**< The problem instance */
319 SCIP_VAR* var, /**< Variable for which the node index is to be determined */
320 SCIP_VAR** indsetvars, /**< Array of variables that are mapped to a node of the graph */
321 int indexcount, /**< Number of variables that are mapped in the graph */
322 int** linkmatrix, /**< Matrix indicating which variables are linked by a node */
323 SCIP_VAR** linkedvars, /**< Array of variables that are linked by eq-constraints */
324 int nlinkedvars /**< Index of linkedvars array */
325 )
326{
327 int nodeindex;
328 int i;
329
330 nodeindex = getNodeIndex(var, indsetvars, indexcount);
331 if( nodeindex == -1 && isVarLinked(linkedvars, nlinkedvars, var) )
332 {
333 for( i = 0; i < nlinkedvars; ++i )
334 {
335 if( linkedvars[i] != var )
336 {
337 if( areVarsLinked(scip, linkmatrix, var, linkedvars[i], linkedvars, nlinkedvars) )
338 {
339 nodeindex = getNodeIndex(linkedvars[i], indsetvars, indexcount);
340 if( nodeindex != -1 )
341 {
342 return nodeindex;
343 }
344 }
345 }
346 }
347 }
348 else
349 {
350 return nodeindex;
351 }
352 return -1;
353}
354
355/** Computes the number of reachable nodes from a given variable */
356static INLINE
358 SCIP* scip, /**< The problem instance */
359 int** linkmatrix, /**< Matrix indicating which variables are linked */
360 SCIP_VAR* var, /**< The starting variable */
361 SCIP_VAR** linkedvars, /**< Array of variables that are linked by eq-constraints */
362 int nlinkedvars /**< Number of linked variables */
363)
364{
365 int* stack; /* Stack for DFS */
366 SCIP_Bool* varvisited; /* Array to track visited nodes */
367 int stacksize; /* Current size of stack */
368 int count; /* Count of reachable nodes */
369 int actind;
370 int popedvarind;
371 int i;
372
373 count = 0;
374 stacksize = 0;
375
376 actind = SCIPvarGetProbindex(var);
377
378 SCIP_CALL_ABORT( SCIPallocBufferArray(scip, &stack, nlinkedvars) );
379 SCIP_CALL_ABORT( SCIPallocCleanBufferArray(scip, &varvisited, nlinkedvars) );
380
381 /* Start DFS from the given variable */
382 stack[stacksize++] = actind;
383 varvisited[getNodeIndex(var, linkedvars, nlinkedvars)] = TRUE;
384
385 while( stacksize > 0 )
386 {
387 popedvarind = stack[--stacksize]; /* pop from stack */
388 count++;
389
390 /* Explore all linked variables */
391 for( i = 0; i < nlinkedvars; i++ )
392 {
393 actind = SCIPvarGetProbindex(linkedvars[i]);
394 if( linkmatrix[popedvarind][actind] && !varvisited[i] )
395 {
396 stack[stacksize++] = actind;
397 varvisited[i] = TRUE;
398 }
399 }
400 }
401
402 SCIPfreeBufferArray(scip, &varvisited);
403 SCIPfreeBufferArray(scip, &stack);
404
405 return count;
406}
407
408/** Returns a representative variable for a given variable in the linked variable-bijection, if any, else NULL.*/
409static INLINE
411 SCIP* scip, /**< The problem instance */
412 SCIP_VAR* var, /**< Variable for which the node index is to be determined */
413 int** linkmatrix, /**< Matrix indicating which variables are linked by a node */
414 SCIP_VAR** linkedvars, /**< Array of variables that are linked by eq-constraints */
415 int nlinkedvars /**< Index of linkedvars array */
416)
417{
418 int i;
419
420 for( i = 0; i < nlinkedvars; ++i )
421 {
422 if( linkedvars[i] == var || areVarsLinked(scip, linkmatrix, var, linkedvars[i], linkedvars, nlinkedvars) )
423 return linkedvars[i];
424 }
425 return NULL;
426}
427
428/** Returns the index of the representative variable for a given variable in the linked variable-bijection, if any.*/
429static INLINE
431 SCIP* scip, /**< The problem instance */
432 SCIP_VAR* var, /**< Variable for which the node index is to be determined */
433 int** linkmatrix, /**< Matrix indicating which variables are linked by a node */
434 SCIP_VAR** linkedvars, /**< Array of variables that are linked by eq-constraints */
435 int nlinkedvars, /**< Index of linkedvars array */
436 SCIP_VAR** varsincouplings, /**< Array of variables that are involved in couplings */
437 int nvarsincouplings /**< Index of varsincouplings array */
438 )
439{
440 if( isVarLinked(linkedvars, nlinkedvars, var) )
441 var = getLinkedNodeVar(scip, var, linkmatrix, linkedvars, nlinkedvars);
442
443 return (var == NULL) ? -1 : getNodeIndex(var, varsincouplings, nvarsincouplings);
444}
445
446/** Aggregates objective coefficients for linked variables in the aggrobjcoef array. */
447static
449 SCIP* scip, /**< The problem instance */
450 int** linkmatrix, /**< Matrix indicating which variables are linked by a node */
451 SCIP_VAR** linkedvars, /**< Array of variables that are linked by eq-constraints */
452 int nlinkedvars, /**< Index of linkedvars array */
453 SCIP_Real* aggrobjcoef /**< Array of aggregated objective coefficients. */
454 )
455{
456 int i;
457 int j;
458 SCIP_Real aggr;
459 int* valisset; /* 0 : unset; 1 : set; 2 : to be set. */
460
461 SCIP_CALL_ABORT( SCIPallocClearBufferArray(scip, &valisset, nlinkedvars) );
462
463 for( i = 0; i < nlinkedvars; i++)
464 {
465 if( valisset[i] == 1 )
466 continue;
467
468 aggr = SCIPvarGetObj(linkedvars[i]);
469 valisset[i] = 2;
470
471 for( j = i + 1; j < nlinkedvars; j++ )
472 {
473 if( !valisset[j] && areVarsLinked(scip, linkmatrix, linkedvars[i], linkedvars[j], linkedvars, nlinkedvars) )
474 {
475 aggr += SCIPvarGetObj(linkedvars[j]);
476 valisset[j] = 2;
477 }
478 }
479
480 for( j = i; j < nlinkedvars; j++ )
481 {
482 if( valisset[j] == 2 )
483 {
484 aggrobjcoef[SCIPvarGetProbindex(linkedvars[j])] = aggr;
485 valisset[j] = 1;
486 }
487 }
488 }
489
490 SCIPfreeBufferArray(scip, &valisset);
491}
492
493/** Returns the aggregated objective coefficient. */
494static INLINE
496 SCIP_VAR* var, /**< The variable for which the aggr. obj. coef. should be returned */
497 int nlinkedvars, /**< Index of linkedvars array */
498 int nvarsincouplings, /**< Index of varsincouplings array */
499 SCIP_Real* aggrobjcoef /**< Array of aggregated objective coefficients. */
500 )
501{
502 if( nlinkedvars > 0 || nvarsincouplings > 0 )
503 return aggrobjcoef[SCIPvarGetProbindex(var)];
504 return SCIPvarGetObj(var);
505}
506
507/** Set (/update) aggregated objective coefficients savely. */
508static INLINE
510 SCIP* scip, /**< The problem instance */
511 SCIP_VAR* var, /**< The variable for which the aggr. obj. coef. should be updated */
512 SCIP_Real value, /**< Value to set for given var (and linked vars) */
513 SCIP_VAR** linkedvars, /**< Array of variables that are linked by eq-constraints */
514 int nlinkedvars, /**< Index of linkedvars array */
515 int** linkmatrix, /**< Matrix indicating which variables are linked by a node */
516 SCIP_Real* aggrobjcoef /**< Array of aggregated objective coefficients. */
517)
518{
519 int i;
520
521 /* If variable is linked, we need to update all linked variables' objective coefficients too */
522 if( isVarLinked(linkedvars, nlinkedvars, var) )
523 {
524 for( i = 0; i < nlinkedvars; i++ )
525 {
526 if( areVarsLinked(scip, linkmatrix, var, linkedvars[i], linkedvars, nlinkedvars) )
527 aggrobjcoef[SCIPvarGetProbindex(linkedvars[i])] = value;
528 }
529 }
530 else
531 {
532 aggrobjcoef[SCIPvarGetProbindex(var)] = value;
533 }
534}
535
536/** Add a variable to the bijection graph g and indsetvars array. Returns the index of the corresponding node in the graph. */
537static
539 SCIP* scip, /**< The problem instance */
540 graph_t* g, /**< Graph into which to insert the new variable as a node */
541 SCIP_VAR* consvar, /**< The variable that is to be assigned a node in the graph */
542 int* indexcount, /**< Pointer to Index of the next unassigned node in the graph */
543 SCIP_Real scalingfactor, /**< Factor for scaling the weight of newly mapped nodes */
544 SCIP_VAR** indsetvars, /**< Array that keeps track of variables that are part of the graph */
545 int** linkmatrix, /**< Matrix indicating which variables are linked by a node */
546 SCIP_VAR** linkedvars, /**< Array of variables that are linked by eq-constraints */
547 int nlinkedvars, /**< Index of linkedvars array */
548 int nvarsincouplings, /**< Index of varsincouplings array */
549 SCIP_Real* aggrobjcoef /**< Array of aggregated objective coefficients. */
550 )
551{
552 int nodeindex;
553 SCIP_Real aggrObj;
554 if( isVarLinked(linkedvars, nlinkedvars, consvar) )
555 {
556 nodeindex = getLinkedNodeIndex(scip, consvar, indsetvars, *indexcount, linkmatrix, linkedvars, nlinkedvars);
557 }
558 else
559 {
560 nodeindex = getNodeIndex(consvar, indsetvars, *indexcount);
561 }
562 if( nodeindex == -1 )
563 {
564 /* Var not yet part of graph, add it with its corresponding weight */
565 indsetvars[*indexcount] = consvar;
566 aggrObj = getAggrObjCoef(indsetvars[*indexcount], nlinkedvars, nvarsincouplings, aggrobjcoef);
567 if( SCIPisLT(scip, aggrObj, 0.0) )
568 {
569 g->weights[*indexcount] = 1 + abs((int) (scalingfactor * aggrObj));
570 }
571 else
572 {
573 g->weights[*indexcount] = 1;
574 }
575 nodeindex = *indexcount;
576 ++(*indexcount);
577 }
578 return nodeindex;
579}
580
581/** Set the solvals of a variable and of all its linked variables, if any */
582static
584 SCIP* scip, /**< The problem instance */
585 SCIP_Real* solvals, /**< Array holding the current solution values of all variables of the problem */
586 int** linkmatrix, /**< Matrix indicating which variables are linked by a node */
587 SCIP_VAR** linkedvars, /**< Array of variables that are linked by eq-constraints */
588 int nlinkedvars, /**< Index of linkedvars array */
589 SCIP_VAR* var, /**< Var that may be linked that itself should be set to the value val */
590 SCIP_Real val /**< Value to which all linked vars are supposed to be set to */
591 )
592{
593 int i;
594
595 solvals[SCIPvarGetProbindex(var)] = val;
596
597 for( i = 0; i < nlinkedvars; ++i )
598 {
599 if( var != linkedvars[i] )
600 {
601 if( areVarsLinked(scip, linkmatrix, var, linkedvars[i], linkedvars, nlinkedvars) )
602 {
603 solvals[SCIPvarGetProbindex(linkedvars[i])] = val;
604 assert(SCIPisGE(scip, val, SCIPvarGetLbLocal(linkedvars[i])) &&
605 SCIPisLE(scip, val, SCIPvarGetUbLocal(linkedvars[i])));
606 }
607 }
608 }
609}
610
611/** Check if the objective coefficients of the variables are already Integral */
612static
614 SCIP* scip, /**< The problem instance */
615 SCIP_VAR** linkedvars, /**< Array of variables that are linked by eq-constraints */
616 int nlinkedvars, /**< Index of linkedvars array */
617 SCIP_VAR** varsincouplings, /**< Array of variables that are involved in coupling */
618 int nvarsincouplings, /**< Index of varsincouplings array */
619 SCIP_Real* aggrobjcoef /**< Array of aggregated objective coefficients. */
620 )
621{
624 SCIP_VAR** vars;
625 int i;
626
629
630 for( i = 0; i < nvars; ++i )
631 {
632 objval = getAggrObjCoef(vars[i], nlinkedvars, nvarsincouplings, aggrobjcoef);
633 if( !SCIPisZero(scip, objval-((int)objval)) )
634 {
635 return FALSE;
636 }
637 }
638 return TRUE;
639}
640
641/** Scale the objective coefficients of the variables maximally s.t. they become integral and the sum of values does not exceed INT_MAX */
642static
644 SCIP* scip, /**< The problem instance */
645 SCIP_VAR** linkedvars, /**< Array of variables that are linked by eq-constraints */
646 int nlinkedvars, /**< Index of linkedvars array */
647 SCIP_VAR** varsincouplings, /**< Array of variables that are involved in coupling */
648 int nvarsincouplings, /**< Index of varsincouplings array */
649 SCIP_Real* aggrobjcoef /**< Array of aggregated objective coefficients. */
650 )
651{
653 SCIP_Real varval;
654 SCIP_Real biggestobj;
656 SCIP_VAR** vars;
657 int i;
658
661
662 scalingfactor = (INT_MAX / nvars) - nvars;
663
664 /* Check for the biggest objective value to safely adjust the scalingfactor */
665 biggestobj = 0.0;
666 for( i = 0; i < nvars; ++i )
667 {
668 varval = getAggrObjCoef(vars[i], nlinkedvars, nvarsincouplings, aggrobjcoef);
669 if( SCIPisLT(scip, varval, biggestobj) )
670 {
671 biggestobj = varval;
672 }
673 }
674 if( SCIPisLT(scip, biggestobj, -1.0) )
675 {
676 /* Ensure that INT_MAX is never reached by the sum of all scaled weights */
677 scalingfactor = fabs(scalingfactor / biggestobj);
678 }
679 return scalingfactor;
680}
681
682/** Set isnotapplicable to true for given problem number if solver is applied at root node and no cuts are applied. */
683static
685 GCG* gcg, /**< master problem SCIP data structure */
686 int probnr, /**< pricing problem number */
687 SCIP_Bool* isnotapplicable /**< array storing if solver is applicable to problems */
688 )
689{
691 isnotapplicable[probnr] = TRUE;
692}
693
694/** Returns index in adjacency matrix of coupling digraph (after inserting it if not already contained). */
695static INLINE
697 SCIP* scip, /**< The problem instance */
698 SCIP_VAR** varsincouplings, /**< Array of variables that are involved in coupling */
699 int* nvarsincouplings, /**< Index of varsincouplings array */
700 SCIP_VAR* var, /**< Variable whose membership in the varsincouplings array is to be checked */
701 SCIP_VAR** linkedvars, /**< Array of variables that are linked by eq-constraints */
702 int nlinkedvars, /**< Index of linkedvars array */
703 int** linkmatrix /**< Matrix indicating which variables are linked by eq-constraints */
704 )
705{
706 int i;
707
708 /* If var is linked, we map all linked vars to one representative digraph node and return its index. */
709 if( isVarLinked(linkedvars, nlinkedvars, var) )
710 var = getLinkedNodeVar(scip, var, linkmatrix, linkedvars, nlinkedvars);
711
712 for( i = 0; i < *nvarsincouplings; ++i )
713 {
714 if( varsincouplings[i] == var )
715 return i;
716 }
717
718 varsincouplings[*nvarsincouplings] = var;
719 return (*nvarsincouplings)++;
720}
721
722/** Update coupling digraph for a given coupling(like) constraint, i.e., the coupling and constraint vars.
723 * This is done by assuring all variables have a corresponding index in the graph.
724 * Then, directed edges from coupling var to each other var involved in the constraint are inserted. */
725static INLINE
727 SCIP* scip, /**< The problem instance */
728 SCIP_VAR** consvars, /**< Array of variables in constraint for which to update the graph */
729 int nconsvars, /**< Index of consvars array */
730 SCIP_VAR* var, /**< Coupling / vbd variable for which to update graph */
731 int** couplingmatrix, /**< Matrix indicating which variables are involved in couplings */
732 SCIP_VAR** varsincouplings, /**< Array of variables that are involved in couplings */
733 int* nvarsincouplings, /**< Index of varsincouplings array */
734 SCIP_VAR** linkedvars, /**< Array of variables that are linked by eq-constraints */
735 int nlinkedvars, /**< Index of linkedvars array */
736 int** linkmatrix /**< Matrix indicating which variables are linked by eq-constraints */
737 )
738{
739 int i;
740 int couplingvarind;
741 int consvarind;
742
743 couplingvarind = assureInCouplingGraph(scip, varsincouplings, nvarsincouplings, var, linkedvars, nlinkedvars,
744 linkmatrix);
745
746 /* Insert (increment) edges for all non-coupling variables in the constraint. */
747 for( i = 0; i < nconsvars; i++ )
748 {
749 if( consvars[i] == var )
750 continue;
751
752 consvarind = assureInCouplingGraph(scip, varsincouplings, nvarsincouplings, consvars[i], linkedvars, nlinkedvars,
753 linkmatrix);
754 if( !couplingmatrix[couplingvarind][consvarind] )
755 couplingmatrix[couplingvarind][consvarind] = 1;
756 }
757}
758
759/** Recursive function - should be called through isCouplingRelevant() or other non-recursive methods.
760 * Checks if a variable for a given index in the coupling digraph is relevant for distributing the coefficients. */
761static
763 SCIP* scip, /**< The problem instance */
764 int varind, /**< Variable index for which to check if it has a successor */
765 int** couplingmatrix, /**< Matrix indicating which variables are involved in couplings */
766 SCIP_VAR** varsincouplings, /**< Array of variables that are involved in couplings */
767 int nvarsincouplings, /**< Index of varsincouplings array */
768 int nlinkedvars, /**< Index of linkedvars array */
769 SCIP_Real* aggrobjcoef, /**< Array of aggregated objective coefficients. */
770 int maxdepth /**< Integer limiting recursion to finite depth in case of a cycle. */
771)
772{
773 int i;
774
775 if( SCIPisLT(scip, getAggrObjCoef(varsincouplings[varind], nlinkedvars, nvarsincouplings, aggrobjcoef), 0) )
776 return TRUE;
777
778 if( maxdepth <= 0 )
779 return FALSE;
780
781 for( i = 0; i < nvarsincouplings; i++ )
782 {
783 if( couplingmatrix[varind][i] > 0 &&
784 isCouplingRelevantRec(scip, i, couplingmatrix, varsincouplings, nvarsincouplings, nlinkedvars, aggrobjcoef,
785 maxdepth - 1))
786 {
787 return TRUE;
788 }
789 }
790 return FALSE;
791}
792
793/** Checks if a variable for a given index in the coupling digraph is relevant for distributing the coefficients.
794 * A variable is said to be relevant iff
795 * - it has a negative objective coefficient or
796 * - in the digraph a node corresponding to a variable with negative obj. coef. is reachable in the digraph. */
797static INLINE
799 SCIP* scip, /**< The problem instance */
800 int varind, /**< Variable index for which to check if it has a successor */
801 int** couplingmatrix, /**< Matrix indicating which variables are involved in couplings */
802 SCIP_VAR** varsincouplings, /**< Array of variables that are involved in couplings */
803 int nvarsincouplings, /**< Index of varsincouplings array */
804 int nlinkedvars, /**< Index of linkedvars array */
805 SCIP_Real* aggrobjcoef /**< Array of aggregated objective coefficients. */
806 )
807{
808 return isCouplingRelevantRec(scip, varind, couplingmatrix, varsincouplings, nvarsincouplings, nlinkedvars,
809 aggrobjcoef, nvarsincouplings);
810}
811
812/** Same as isCouplingRelevant(), but takes a SCIP_VAR pointer instead of the digraph index. */
813static INLINE
815 SCIP* scip, /**< The problem instance */
816 SCIP_VAR* var, /**< Variable for which to check if it has a successor */
817 int** couplingmatrix, /**< Matrix indicating which variables are involved in couplings */
818 SCIP_VAR** varsincouplings, /**< Array of variables that are involved in couplings */
819 int nvarsincouplings, /**< Index of varsincouplings array */
820 int** linkmatrix, /**< Matrix indicating which variables are linked by eq-constraints */
821 SCIP_VAR** linkedvars, /**< Array of variables that are linked by eq-constraints */
822 int nlinkedvars, /**< Index of linkedvars array */
823 SCIP_Real* aggrobjcoef /**< Array of aggregated objective coefficients. */
824)
825{
826 int varind;
827
828 varind = getNodeIndexCouplDigraph(scip, var, linkmatrix, linkedvars, nlinkedvars, varsincouplings, nvarsincouplings);
829 assert(varind > -1);
830
831 return isCouplingRelevantRec(scip, varind, couplingmatrix, varsincouplings, nvarsincouplings, nlinkedvars,
832 aggrobjcoef, nvarsincouplings);
833}
834
835/** Checks in the coupling digraph if a var with a given index has a coupling relevant successor. */
836static INLINE
838 SCIP* scip, /**< The problem instance */
839 int varind, /**< Variable index for which to check if it has a successor */
840 int** couplingmatrix, /**< Matrix indicating which variables are involved in couplings */
841 SCIP_VAR** varsincouplings, /**< Array of variables that are involved in couplings */
842 int nvarsincouplings, /**< Index of varsincouplings array */
843 int nlinkedvars, /**< Index of linkedvars array */
844 SCIP_Real* aggrobjcoef /**< Array of aggregated objective coefficients. */
845 )
846{
847 int i;
848
849 for( i = 0; i < nvarsincouplings; i++ )
850 {
851 if( couplingmatrix[varind][i] > 0 &&
852 isCouplingRelevantRec(scip, i, couplingmatrix, varsincouplings, nvarsincouplings, nlinkedvars, aggrobjcoef,
853 nvarsincouplings) )
854 {
855 return TRUE;
856 }
857 }
858 return FALSE;
859}
860
861/** Get the number of coupling-relevant successors in the Coupling DiGraph. */
862static INLINE
864 SCIP* scip, /**< The problem instance */
865 int varind, /**< Variable index for which to count the successors */
866 int** couplingmatrix, /**< Matrix indicating which variables are involved in couplings */
867 SCIP_VAR** varsincouplings, /**< Array of variables that are involved in couplings */
868 int nvarsincouplings, /**< Index of varsincouplings array */
869 int nlinkedvars, /**< Index of linkedvars array */
870 SCIP_Real* aggrobjcoef, /**< Array of aggregated objective coefficients. */
871 int* varmultiplicities, /**< Array holding number of vars represented by digraph node */
872 SCIP_Bool usemultiplicities /**< Wether to use the given multiplicities */
873)
874{
875 int i;
876 int nsuccessors;
877
878 nsuccessors = 0;
879 for( i = 0; i < nvarsincouplings; i++ )
880 {
881 if( couplingmatrix[varind][i] > 0 &&
882 isCouplingRelevantRec(scip, i, couplingmatrix, varsincouplings, nvarsincouplings, nlinkedvars, aggrobjcoef,
883 nvarsincouplings) )
884 {
885 nsuccessors += usemultiplicities ? varmultiplicities[i] : 1;
886 }
887 }
888 return nsuccessors;
889}
890
891/** Compute entries for varmultiplicities array holding counts of represented variables per digraph node */
892static INLINE
894 SCIP* scip, /**< The problem instance */
895 int** linkmatrix, /**< Matrix indicating which variables are linked */
896 SCIP_VAR** linkedvars, /**< Array of variables that are linked by eq-constraints */
897 int nlinkedvars, /**< Number of linked variables */
898 int** couplingmatrix, /**< Matrix indicating which variables are involved in couplings */
899 SCIP_VAR** varsincouplings, /**< Array of variables that are involved in couplings */
900 int nvarsincouplings, /**< Index of varsincouplings array */
901 int* varmultiplicities /**< Array holding number of vars represented by digraph node */
902 )
903{
904 int i;
905
906 for( i = 0; i < nvarsincouplings; i++ )
907 {
908 if( isVarLinked(linkedvars, nlinkedvars, varsincouplings[i]) )
909 varmultiplicities[i] = countReachableVars(scip, linkmatrix, varsincouplings[i], linkedvars, nlinkedvars);
910 else
911 varmultiplicities[i] = 1;
912 }
913}
914
915/*
916 * Idea - Distribution Strategy 1: Natural Coefficient Share Distribution.
917 *
918 * Distributes a variable's objective coefficient among its coupled successors using a structured
919 * closed-form approximation, ensuring no feasible assignment overestimates the original objective function.
920 *
921 * **Step 1: Distribute the Objective Coefficient Among Constraints**
922 * Given m constraints of the form x_{i,1} + ... + x_{i,n_i} ≤ c_i * y, each constraint i receives:
923 *
924 * w_i = w * (c_i / sum(c_j for all j in constraints))
925 *
926 * **Step 2: Distribute w_i Among Relevant Variables**
927 * Each relevant x_{i,j} variable in constraint i gets:
928 *
929 * w_ij = w_i * (1 / n_rel_cons_vars)
930 *
931 * **Implementation:**
932 * - Iterate over constraints, identify relevant variables, and accumulate their coefficient shares (`coefshares[j]`).
933 * - Normalize using `denominator`:
934 *
935 * aggrobjcoef[j] += actvarcoef * (coefshares[j] / denominator)
936 *
937 * **Special Cases:**
938 * - **Varbound Standard & Clique Constraints**: Each relevant variable gets **1**.
939 * - **Decorative Coupling Constraints** (x_1 + ... + x_n ≤ c * y, c ≥ n): Each variable gets **1 / n_rel_cons_vars**.
940 *
941 * This method ensures the total assigned weight remains ≤ w and that feasible selections of x_ij never exceed w.
942 */
943
944/** Coupling(-like) Variable Objective Distribution Strategy 1: Natural Coefficient Share Distribution. */
945static INLINE
947 SCIP* scip, /**< The problem instance */
948 int actvarind, /**< Index of actual variable */
949 int** couplingmatrix, /**< Matrix indicating which variables are involved in couplings */
950 SCIP_VAR** varsincouplings, /**< Array of variables that are involved in couplings */
951 int nvarsincouplings, /**< Index of varsincouplings array */
952 int* varmultiplicities, /**< Array holding number of vars represented by digraph node */
953 SCIP_Bool usemultipl, /**< Wether varmultiplicities should be used for weighting */
954 SCIP_VAR** linkedvars, /**< Array of variables that are linked by eq-constraints */
955 int nlinkedvars, /**< Index of linkedvars array */
956 int** linkmatrix, /**< Matrix indicating which variables are linked by eq-constraints */
957 SCIP_Real* aggrobjcoef, /**< Array of aggregated objective coefficients. */
958 SCIP_CONS** constraints, /**< Array containing pointers to SCIP constraints of pricing problem */
959 int nconss, /**< Index of constraints array */
960 int* couplingcoefindices,/**< Array for coupling coefficient of each constraint (if coupling) */
961 CLIQUER_CONSTYPE* cliquerconstypes /**< Array holding constraint types (specific to this solver) */
962 )
963{
964 int i;
965 int j;
966 int denominator;
967 int nrelconsvars;
968 int nsuccessors;
969 int nlconsvars;
970 int couplingindex;
971 int mappedindex;
973 SCIP_Real coeftodistr;
974 SCIP_Real actvarcoef;
975 SCIP_Real* coefshares; /* array storing the fraction of the actvar coefficient they receive */
976 SCIP_HASHMAP* vartocoefsharemap; /* hash storing relevant var index; image is index for coefshares array */
977 SCIP_VAR** lconsvars;
979
980 denominator = 0;
981
982 nsuccessors = getNSuccessorsRelevant(scip, actvarind, couplingmatrix, varsincouplings, nvarsincouplings,
983 nlinkedvars, aggrobjcoef, varmultiplicities, FALSE);
984 SCIP_CALL_ABORT( SCIPallocClearBufferArray(scip, &coefshares, nsuccessors) );
985 SCIP_CALL_ABORT( SCIPhashmapCreate(&vartocoefsharemap, SCIPblkmem(scip), nvarsincouplings) );
986
987 /* Setup mapping to coefficient share array */
988 j = 0;
989 for( i = 0; i < nvarsincouplings; i++ )
990 {
991 if( couplingmatrix[actvarind][i] > 0 &&
992 isCouplingRelevant(scip, i, couplingmatrix, varsincouplings, nvarsincouplings, nlinkedvars, aggrobjcoef) )
993 {
994 SCIPhashmapSetImageInt(vartocoefsharemap, (void*)(size_t)i, j);
995 j++;
996 }
997 }
998
999 assert(j == nsuccessors);
1000
1001 /* Calculate coefficient shares */
1002 for( i = 0; i < nconss; i++ )
1003 {
1004 nrelconsvars = 0;
1005 switch( cliquerconstypes[i] )
1006 {
1007 case VARBND_STD:
1008 if( SCIPgetVbdvarVarbound(scip, constraints[i]) == varsincouplings[actvarind] &&
1009 isCouplingRelevantVar(scip, SCIPgetVarVarbound(scip, constraints[i]), couplingmatrix, varsincouplings,
1010 nvarsincouplings, linkmatrix, linkedvars, nlinkedvars, aggrobjcoef) )
1011 {
1012 couplingindex = getNodeIndexCouplDigraph(scip, SCIPgetVarVarbound(scip, constraints[i]), linkmatrix,
1013 linkedvars, nlinkedvars, varsincouplings, nvarsincouplings);
1014 mappedindex = SCIPhashmapGetImageInt(vartocoefsharemap, (void*)(size_t)couplingindex);
1015 nrelconsvars += usemultipl ? varmultiplicities[couplingindex] : 1;
1016 coefshares[mappedindex] += usemultipl ? varmultiplicities[couplingindex] : 1;
1017 }
1018 break;
1021 lconsvars = SCIPgetVarsLinear(scip, constraints[i]);
1022 if( lconsvars[couplingcoefindices[i]] == varsincouplings[actvarind] )
1023 {
1024 /* Get # of relevant variables in constraint */
1025 SCIPgetConsNVars(scip, constraints[i], &nlconsvars, &retcode);
1026 for( j = 0; j < nlconsvars; j++ )
1027 {
1028 if( j == couplingcoefindices[i] )
1029 continue;
1030 if( isCouplingRelevantVar(scip, lconsvars[j], couplingmatrix, varsincouplings, nvarsincouplings,
1031 linkmatrix, linkedvars, nlinkedvars, aggrobjcoef))
1032 {
1033 couplingindex = getNodeIndexCouplDigraph(scip, lconsvars[j], linkmatrix, linkedvars,
1034 nlinkedvars, varsincouplings, nvarsincouplings);
1035 nrelconsvars += usemultipl ? varmultiplicities[couplingindex] : 1;
1036 }
1037 }
1038 /* Add values to coefshares of variables in constraint */
1039 if( nrelconsvars > 0 )
1040 {
1041 frac = cliquerconstypes[i] == LINEAR_COUPLING_CLIQUE ? 1 : (1 / nrelconsvars);
1042 for( j = 0; j < nlconsvars; j++ )
1043 {
1044 if( j == couplingcoefindices[i] )
1045 continue;
1046 if( isCouplingRelevantVar(scip, lconsvars[j], couplingmatrix, varsincouplings, nvarsincouplings,
1047 linkmatrix, linkedvars, nlinkedvars, aggrobjcoef) )
1048 {
1049 couplingindex = getNodeIndexCouplDigraph(scip, lconsvars[j], linkmatrix, linkedvars,
1050 nlinkedvars, varsincouplings, nvarsincouplings);
1051 mappedindex = SCIPhashmapGetImageInt(vartocoefsharemap, (void*)(size_t)couplingindex);
1052
1053 nrelconsvars += usemultipl ? varmultiplicities[couplingindex] : 1;
1054 coefshares[mappedindex] += (usemultipl ? varmultiplicities[couplingindex] : 1) * frac;
1055 }
1056 }
1057 }
1058 }
1059 break;
1060 default:
1061 break;
1062 }
1063 denominator += nrelconsvars;
1064 }
1065
1066 /* Distribute coeff. of act. var to all successor variables. */
1067 coeftodistr = getAggrObjCoef(varsincouplings[actvarind], nlinkedvars, nvarsincouplings, aggrobjcoef);
1068 for( i = 0; i < nvarsincouplings; i++ )
1069 {
1070 if( couplingmatrix[actvarind][i] > 0 &&
1071 isCouplingRelevant(scip, i, couplingmatrix, varsincouplings, nvarsincouplings, nlinkedvars, aggrobjcoef) )
1072 {
1073 frac = coefshares[SCIPhashmapGetImageInt(vartocoefsharemap, (void *) (size_t) i)];
1074 actvarcoef = getAggrObjCoef(varsincouplings[i], nlinkedvars, nvarsincouplings, aggrobjcoef);
1075 setAggrObjCoef(scip, varsincouplings[i], actvarcoef + coeftodistr * (frac / denominator),
1076 linkedvars, nlinkedvars, linkmatrix, aggrobjcoef);
1077 }
1078 }
1079
1080 SCIPhashmapFree(&vartocoefsharemap);
1081 SCIPfreeBufferArray(scip, &coefshares);
1082}
1083
1084/*
1085 * Idea - Distribution Strategy 2: Independent set (IS)-based share distribution.
1086 *
1087 * This heuristic distributes the objective coefficient of a coupled variable among its relevant successor variables
1088 * by leveraging **maximum independent sets** in the coupling graph. The goal is to ensure a balanced coefficient
1089 * distribution while preventing overestimation of the objective function.
1090 *
1091 * **Core Idea:**
1092 * - Construct a **graph representation** where nodes correspond to relevant successor variables.
1093 * - Create edges between all pairs of successor variables initially.
1094 * - Remove edges based on constraints of type `LINEAR_COUPLING_CLIQUE`, ensuring that only truly independent
1095 * variables remain connected.
1096 * - Compute a **maximum independent set (MIS)** in this reduced graph using the **cliquer** library.
1097 * - Distribute the objective coefficient **equally** among the variables in this MIS.
1098 *
1099 * This ensures no overestimation of the redistributed objective coefficient.
1100 *
1101 * Attention: If the coupling graph is too large, the cliquer library might not solve the problem in acceptable time.
1102 * Therefore, a hard limit of 200 nodes is implemented. Otherwise, no distribution is done.
1103 */
1104
1105/** Coupling(-like) Variable Objective Distribution Strategy 2: Independent Set-based share distribution. */
1106static INLINE
1108 SCIP* scip, /**< The problem instance */
1109 int actvarind, /**< Index of actual variable */
1110 int** couplingmatrix, /**< Matrix indicating which variables are involved in couplings */
1111 SCIP_VAR** varsincouplings, /**< Array of variables that are involved in couplings */
1112 int nvarsincouplings, /**< Index of varsincouplings array */
1113 int* varmultiplicities, /**< Array holding number of vars represented by digraph node */
1114 SCIP_Bool usemultipl, /**< Wether varmultiplicities should be used for weighting */
1115 SCIP_VAR** linkedvars, /**< Array of variables that are linked by eq-constraints */
1116 int nlinkedvars, /**< Index of linkedvars array */
1117 int** linkmatrix, /**< Matrix indicating which variables are linked by eq-constraints */
1118 SCIP_Real* aggrobjcoef, /**< Array of aggregated objective coefficients. */
1119 SCIP_CONS** constraints, /**< Array containing pointers to SCIP constraints of pricing problem */
1120 int nconss, /**< Index of constraints array */
1121 int* couplingcoefindices,/**< Array for coupling coefficient of each constraint (if coupling) */
1122 CLIQUER_CONSTYPE* cliquerconstypes /**< Array holding constraint types (specific to this solver) */
1123)
1124{
1125 int i;
1126 int j;
1127 int k;
1128 int couplind1;
1129 int couplind2;
1130 int denominator;
1131 int nsuccessors;
1132 int nlconsvars;
1133 SCIP_Real actvarcoef;
1134 SCIP_Real coeftodistr;
1135 SCIP_HASHMAP* vartosuccmap; /* hash storing relevant var index; image is index for corresponding graph node */
1136 SCIP_VAR** lconsvars;
1138 set_t clique;
1139 graph_t* g;
1140 clique_options cl_opts;
1141
1142 nsuccessors = getNSuccessorsRelevant(scip, actvarind, couplingmatrix, varsincouplings, nvarsincouplings,
1143 nlinkedvars, aggrobjcoef, varmultiplicities, FALSE);
1144
1145 if( nsuccessors > 200 || nsuccessors == 0)
1146 return;
1147
1148 g = graph_new(nsuccessors);
1149 for( i = 0; i < nsuccessors; ++i )
1150 {
1151 for( j = i + 1; j < nsuccessors; ++j )
1152 {
1153 GRAPH_ADD_EDGE(g, i, j);
1154 }
1155 }
1156
1157 /* Setup mapping to coefficient share array */
1158 j = 0;
1159 SCIP_CALL_ABORT( SCIPhashmapCreate(&vartosuccmap, SCIPblkmem(scip), nvarsincouplings) );
1160 for( i = 0; i < nvarsincouplings; i++ )
1161 {
1162 if( couplingmatrix[actvarind][i] > 0 &&
1163 isCouplingRelevant(scip, i, couplingmatrix, varsincouplings, nvarsincouplings, nlinkedvars, aggrobjcoef) )
1164 {
1165 SCIPhashmapSetImageInt(vartosuccmap, (void*)(size_t)i, j);
1166 if( usemultipl )
1167 g->weights[j] = varmultiplicities[i];
1168 j++;
1169 }
1170 }
1171 assert(j == nsuccessors);
1172
1173 /* Create IS problem to determine coefficient share */
1174 for( i = 0; i < nconss; i++ )
1175 {
1176 if( LINEAR_COUPLING_CLIQUE == cliquerconstypes[i] &&
1177 SCIPgetVarsLinear(scip, constraints[i])[couplingcoefindices[i]] == varsincouplings[actvarind] )
1178 {
1179 /* Delete edges between nodes of relevant variables in constraint */
1180 lconsvars = SCIPgetVarsLinear(scip, constraints[i]);
1181 SCIPgetConsNVars(scip, constraints[i], &nlconsvars, &retcode);
1182 for( j = 0; j < nlconsvars; j++ )
1183 {
1184 if( j == couplingcoefindices[i] )
1185 continue;
1186 if( isCouplingRelevantVar(scip, lconsvars[j], couplingmatrix, varsincouplings, nvarsincouplings,
1187 linkmatrix, linkedvars, nlinkedvars, aggrobjcoef) )
1188 {
1189 for( k = j + 1; k < nlconsvars; k++ )
1190 {
1191 if( k == couplingcoefindices[i] )
1192 continue;
1193 if( isCouplingRelevantVar(scip, lconsvars[k], couplingmatrix, varsincouplings, nvarsincouplings,
1194 linkmatrix, linkedvars, nlinkedvars, aggrobjcoef) )
1195 {
1196 couplind1 = getNodeIndexCouplDigraph(scip, lconsvars[j], linkmatrix, linkedvars, nlinkedvars,
1197 varsincouplings, nvarsincouplings);
1198 couplind2 = getNodeIndexCouplDigraph(scip, lconsvars[k], linkmatrix, linkedvars, nlinkedvars,
1199 varsincouplings, nvarsincouplings);
1200 if( couplind1 != couplind2)
1201 GRAPH_DEL_EDGE(g, SCIPhashmapGetImageInt(vartosuccmap, (void*)(size_t)couplind1),
1202 SCIPhashmapGetImageInt(vartosuccmap, (void*)(size_t)couplind2));
1203 }
1204 }
1205 }
1206 }
1207 }
1208 }
1209
1210 /* Calculate max variables set to 1 at once as the max independent set cardinality */
1211
1212 /* Set cliquer options */
1213 cl_opts.reorder_function = reorder_by_default; /* default: reorder_by_default */
1214 cl_opts.reorder_map = NULL;
1215 cl_opts.time_function = NULL; /* default: clique_print_time */
1216 cl_opts.output = NULL;
1217 cl_opts.user_function = NULL;
1218 cl_opts.user_data = NULL;
1219 cl_opts.clique_list = NULL;
1220 cl_opts.clique_list_length = 0;
1221
1222 /* Find maximum weight clique using the cliquer library */
1223 clique = clique_find_single(g, 0, 0, FALSE, &cl_opts);
1224
1225 if( !usemultipl )
1226 denominator = set_size(clique);
1227 else if( !graph_weighted(g) )
1228 denominator = set_size(clique) * g->weights[0];
1229 else
1230 {
1231 i = -1;
1232 denominator = 0;
1233 while( (i = set_return_next(clique, i)) >= 0 )
1234 denominator += g->weights[i];
1235 }
1236
1237 /* Distribute coeff. of act. var to all successor variables. */
1238 coeftodistr = getAggrObjCoef(varsincouplings[actvarind], nlinkedvars, nvarsincouplings, aggrobjcoef);
1239 for( i = 0; i < nvarsincouplings; i++ )
1240 {
1241 if( couplingmatrix[actvarind][i] > 0 &&
1242 isCouplingRelevant(scip, i, couplingmatrix, varsincouplings, nvarsincouplings, nlinkedvars, aggrobjcoef) )
1243 {
1244 actvarcoef = getAggrObjCoef(varsincouplings[i], nlinkedvars, nvarsincouplings, aggrobjcoef);
1245 setAggrObjCoef(scip, varsincouplings[i],
1246 actvarcoef + coeftodistr * ((SCIP_Real)(usemultipl ? varmultiplicities[i] : 1.0) / denominator),
1247 linkedvars, nlinkedvars, linkmatrix, aggrobjcoef);
1248 }
1249 }
1250
1251 /* Free memory */
1252 set_free(clique);
1253 graph_free(g);
1254 SCIPhashmapFree(&vartosuccmap);
1255}
1256
1257/*
1258 * Idea - Distribution Strategy 3: Uniform Coefficient Share Distribution. (Fastest heuristic implemented)
1259 *
1260 * Uniformly distributes the objective coefficient of a variable among all its relevant coupled successor variables.
1261 * Each successor receives an equal share, ensuring no overestimation of the redistributed objective coefficient.
1262 */
1263
1264/** Coupling(-like) Variable Objective Distribution Strategy 3: Uniform Coefficient Share Distribution. */
1265static INLINE
1267 SCIP* scip, /**< The problem instance */
1268 int actvarind, /**< Index of actual variable */
1269 int** couplingmatrix, /**< Matrix indicating which variables are involved in couplings */
1270 SCIP_VAR** varsincouplings, /**< Array of variables that are involved in couplings */
1271 int nvarsincouplings, /**< Index of varsincouplings array */
1272 int* varmultiplicities, /**< Array holding number of vars represented by digraph node */
1273 SCIP_Bool usemultipl, /**< Wether varmultiplicities should be used for weighting */
1274 SCIP_VAR** linkedvars, /**< Array of variables that are linked by eq-constraints */
1275 int nlinkedvars, /**< Index of linkedvars array */
1276 int** linkmatrix, /**< Matrix indicating which variables are linked by eq-constraints */
1277 SCIP_Real* aggrobjcoef /**< Array of aggregated objective coefficients. */
1278)
1279{
1280 int i;
1281 int nsuccessors;
1282 SCIP_Real actvarcoef;
1283 SCIP_Real coeftodistr;
1284
1285 nsuccessors = getNSuccessorsRelevant(scip, actvarind, couplingmatrix, varsincouplings, nvarsincouplings,
1286 nlinkedvars, aggrobjcoef, varmultiplicities, usemultipl);
1287
1288 /* Distribute coeff. of act. var to all successor variables. */
1289 coeftodistr = getAggrObjCoef(varsincouplings[actvarind], nlinkedvars, nvarsincouplings, aggrobjcoef);
1290 for( i = 0; i < nvarsincouplings; i++ )
1291 {
1292 if( couplingmatrix[actvarind][i] > 0 &&
1293 isCouplingRelevant(scip, i, couplingmatrix, varsincouplings, nvarsincouplings, nlinkedvars, aggrobjcoef) )
1294 {
1295 actvarcoef = getAggrObjCoef(varsincouplings[i], nlinkedvars, nvarsincouplings, aggrobjcoef);
1296 setAggrObjCoef(scip, varsincouplings[i],
1297 actvarcoef + coeftodistr * ((SCIP_Real)(usemultipl ? varmultiplicities[i] : 1.0) / nsuccessors),
1298 linkedvars, nlinkedvars, linkmatrix, aggrobjcoef);
1299 }
1300 }
1301}
1302
1303
1304/** Distributes the objective coefficient of coupling(-like) vars to all other vars occurring in those constraints.
1305 * -> Recursive function: Should be called through non-recursive wrapper function 'distributeObjCoef()'. */
1306static
1308 SCIP* scip, /**< The problem instance */
1309 int actvarind, /**< Index of actual variable */
1310 SCIP_Bool* isdistributed, /**< Array storing if a coupled variable was visited */
1311 int** couplingmatrix, /**< Matrix indicating which variables are involved in couplings */
1312 SCIP_VAR** varsincouplings, /**< Array of variables that are involved in couplings */
1313 int nvarsincouplings, /**< Index of varsincouplings array */
1314 int* varmultiplicities, /**< Array holding number of vars represented by digraph node */
1315 SCIP_Bool usemultipl, /**< Wether varmultiplicities should be used for weighting */
1316 SCIP_VAR** linkedvars, /**< Array of variables that are linked by eq-constraints */
1317 int nlinkedvars, /**< Index of linkedvars array */
1318 int** linkmatrix, /**< Matrix indicating which variables are linked by eq-constraints */
1319 SCIP_Real* aggrobjcoef, /**< Array of aggregated objective coefficients. */
1320 SCIP_CONS** constraints, /**< Array containing pointers to SCIP constraints of pricing problem */
1321 int nconss, /**< Index of constraints array */
1322 int* couplingcoefindices,/**< Array for coupling coefficient of each constraint (if coupling) */
1323 CLIQUER_CONSTYPE* cliquerconstypes, /**< Array holding constraint types (specific to this solver) */
1324 int selecteddistrheur /**< Number of selected obj coef distribution heuristic. */
1325 )
1326{
1327 int i;
1328
1329 if( isdistributed[actvarind] )
1330 {
1331 /* Cycle in digraph detected. Could improve handling, but because very unlikely we just end recursion here.
1332 * Cyle of form: x <= y, y <= z, z <= x
1333 * (-> i.e. it follows x = y = z; aggegated coef. could be distributed equally among other coupled vars.) */
1334 return;
1335 }
1336
1337 isdistributed[actvarind] = TRUE; /* mark actual variable visited. */
1338
1339 /* Recursive case : if var has predecessor(s) - visit unvisited predecessor(s) first. */
1340 for( i = 0; i < nvarsincouplings; i++ )
1341 {
1342 if( actvarind == i )
1343 continue;
1344 if( couplingmatrix[i][actvarind] > 0 && !isdistributed[i] )
1345 distributeObjCoefRec(scip, i, isdistributed, couplingmatrix, varsincouplings, nvarsincouplings,
1346 varmultiplicities, usemultipl, linkedvars, nlinkedvars, linkmatrix, aggrobjcoef,
1347 constraints, nconss, couplingcoefindices, cliquerconstypes, selecteddistrheur);
1348 }
1349
1350 /* Base case: All predecessors are distributed. */
1351 /* If now has positive (aggr.) obj. coeff.: Distribute coeff. of act. var to all successor variables. */
1352 if( SCIPisGT(scip, getAggrObjCoef(varsincouplings[actvarind], nlinkedvars, nvarsincouplings, aggrobjcoef), 0))
1353 {
1354 switch( selecteddistrheur )
1355 {
1356 case 1:
1357 objCoefDistrHeurNatural(scip, actvarind, couplingmatrix, varsincouplings, nvarsincouplings,
1358 varmultiplicities, usemultipl, linkedvars, nlinkedvars, linkmatrix, aggrobjcoef,
1359 constraints, nconss, couplingcoefindices, cliquerconstypes);
1360 break;
1361 case 2:
1362 objCoefDistrHeurIS(scip, actvarind, couplingmatrix, varsincouplings, nvarsincouplings, varmultiplicities,
1363 usemultipl, linkedvars, nlinkedvars, linkmatrix, aggrobjcoef, constraints, nconss,
1364 couplingcoefindices, cliquerconstypes);
1365 break;
1366 case 3:
1367 objCoefDistrHeurUniform(scip, actvarind, couplingmatrix, varsincouplings, nvarsincouplings,
1368 varmultiplicities, usemultipl, linkedvars, nlinkedvars, linkmatrix, aggrobjcoef);
1369 break;
1370 default:
1371 break;
1372 }
1373 }
1374}
1375
1376/*
1377 * Idea - Objective Coefficient Distribution of Coupling Variables Coefficient:
1378 *
1379 * ** Problem: **
1380 * As the cliquer solver can only handle non-negative integer weights, the objective coefficients are (besides
1381 * scaled) inverted and all negative coefficients are just set to 1 (heuristically!).
1382 * Thus, after the independent set problem is transformed (heuristically) to a clique problem, the objective
1383 * coefficients of coupling variables worsening the solutions objective value are not properly reflected in the
1384 * weights of the max weighted clique problem.
1385 *
1386 * ** Correction Attempt: **
1387 * The objective coefficient w of a coupling variable y (constraints of form: x_1 + ... + x_n <= c*y) can be distributed
1388 * among all other variables x_1, ..., x_n in the constraint(s) to get an objective that is closer to the actual one.
1389 *
1390 * ** Implementation: **
1391 * We implement this by building and utilizing a digraph to process the distribution hierarchically. I.e., if there
1392 * exist constraints of the form z_1 + z_2 <= z_3 and z_3 + z_4 <= z_5, we first want to distribute the coefficient of
1393 * z_5 to the ones of z_3 and z_4 and only then distribute the (aggregated) objective coefficient of z_3 to the ones of
1394 * z_1 and z_2.
1395 *
1396 * Furthermore, we only distribute coefficients that worsen the solution (negative ones after inversion). Also, we only
1397 * distribute to relevant variables, as the others should already be never chosen because there objective coefficient
1398 * suggests so.
1399 */
1400
1401/** Distributes the objective coefficient of coupling(-like) vars to all other vars occurring in those constraints. */
1402static
1404 SCIP* scip, /**< The problem instance */
1405 SCIP_CONS** constraints, /**< Array containing pointers to SCIP constraints of pricing problem */
1406 int nconss, /**< Index of constraints array */
1407 int* couplingcoefindices,/**< Array for coupling coefficient of each constraint (if coupling) */
1408 CLIQUER_CONSTYPE* cliquerconstypes, /**< Array holding constraint types (specific to this solver) */
1409 int** couplingmatrix, /**< Matrix indicating which variables are linked by a node */
1410 SCIP_VAR** varsincouplings, /**< Array of variables that are involved in couplings */
1411 int nvarsincouplings, /**< Index of varsincouplings array */
1412 SCIP_VAR** linkedvars, /**< Array of variables that are linked by eq-constraints */
1413 int nlinkedvars, /**< Index of linkedvars array */
1414 int** linkmatrix, /**< Matrix indicating which variables are linked by eq-constraints */
1415 SCIP_Real* aggrobjcoef, /**< Array of aggregated objective coefficients. */
1416 int selecteddistrheur, /**< Number of selected obj coef distribution heuristic. */
1417 SCIP_Bool usemultipl /**< Wether varmultiplicities should be used for weighting */
1418 )
1419{
1420 int i;
1421 SCIP_Bool* isdistributed; /* array storing if a coupled variable was visited */
1422 int* varmultiplicities; /* array holding the number of linked (represented) vars per node */
1423
1424 /* Local memory allocation */
1425 varmultiplicities = NULL;
1426 SCIP_CALL_ABORT( SCIPallocClearBufferArray(scip, &isdistributed, nvarsincouplings) );
1427 if( usemultipl )
1428 {
1429 SCIP_CALL_ABORT( SCIPallocBufferArray(scip, &varmultiplicities, nvarsincouplings) );
1430 initVarMultiplicities(scip, linkmatrix, linkedvars, nlinkedvars, couplingmatrix, varsincouplings,
1431 nvarsincouplings, varmultiplicities);
1432 }
1433
1434 for( i = 0; i < nvarsincouplings; i++ )
1435 {
1436 if( !isdistributed[i] &&
1437 hasSuccessorRel(scip, i, couplingmatrix, varsincouplings, nvarsincouplings, nlinkedvars, aggrobjcoef) )
1438 {
1439 distributeObjCoefRec(scip, i, isdistributed, couplingmatrix, varsincouplings, nvarsincouplings,
1440 varmultiplicities, usemultipl, linkedvars, nlinkedvars, linkmatrix, aggrobjcoef,
1441 constraints, nconss, couplingcoefindices, cliquerconstypes, selecteddistrheur);
1442 continue;
1443 }
1444 isdistributed[i] = TRUE; /* mark actual variable visited. */
1445 }
1446
1447 /* Free local memory */
1448 if( usemultipl )
1449 SCIPfreeBufferArray(scip, &varmultiplicities);
1450 SCIPfreeBufferArray(scip, &isdistributed);
1451}
1452
1453/**
1454 * Determine cliquer constraint type and save it in the cliquerconstype array.
1455 * Also, build same-constraint equality graph and coupling digraph.
1456 * @return SCIP bool that is false in case a constraint is encountered that cannot be handled,
1457 * true if propagation was successful.
1458 */
1459static
1461 SCIP* pricingprob, /**< pricing problem SCIP data structure */
1462 SCIP_CONS** constraints, /**< Array containing pointers to SCIP constraints of pricing problem */
1463 SCIP_VAR** linkedvars, /**< Array of variables that are linked by eq-constraints */
1464 SCIP_VAR** vconsvars, /**< Array to store variables of a varbound constraint. */
1465 int* markedconsindices, /**< Array containing pointers to SCIP constraints to mark them */
1466 int** linkmatrix, /**< Matrix indicating which variables are linked by a node */
1467 int* couplingcoefindices,/**< Array for coupling coefficient of each constraint (if coupling) */
1468 int* nlinkedvars, /**< Index of linkedvars array */
1469 int nconss, /**< Index of constraints array */
1470 int* markedcount, /**< Index of markedconstraints array */
1471 CLIQUER_CONSTYPE* cliquerconstypes /**< Array holding constraint types (specific to this solver) */
1472 )
1473{
1474 /* Local variables. */
1475 SCIP_CONSHDLR* conshdlr;
1476 SCIP_Real* consvals;
1478 int nvars;
1479
1480 int i;
1481 int j;
1482
1483 /* Loop for checking and saving the constraint types. This is done to ease the handling of the cases later on. */
1484 /* Also the case of the occurrence of constraints that can not be handled by the solver is covered. */
1485 /* Also, the equality graph is built through updating the linkmatrix every time a "same"-constraint is encountered. */
1486 for( i = 0; i < nconss; ++i )
1487 {
1488 assert(constraints[i] != NULL);
1489 conshdlr = SCIPconsGetHdlr(constraints[i]);
1490 assert(conshdlr != NULL);
1491
1492 /* The constraint may be of type 'linear' */
1493 if( strcmp(SCIPconshdlrGetName(conshdlr), "linear") == 0 )
1494 {
1495 consvals = SCIPgetValsLinear(pricingprob, constraints[i]);
1496 if( !SCIPisEQ(pricingprob, SCIPgetLhsLinear(pricingprob, constraints[i]), SCIPgetRhsLinear(pricingprob, constraints[i])) )
1497 {
1498 /* Check if we have an IS constraint */
1499 if( SCIPgetNVarsLinear(pricingprob, constraints[i]) == 2 && SCIPisEQ(pricingprob, SCIPgetRhsLinear(pricingprob, constraints[i]), 1) )
1500 {
1501 cliquerconstypes[i] = LINEAR_IS;
1502 }
1503 /* Handle other constraints that behave like IS constraints, i.e. cx+dy<=rhs with c+d>rhs, c>0, d>0 */
1504 else if( SCIPgetNVarsLinear(pricingprob, constraints[i]) == 2 && consvals[0] > 0 && consvals[1] > 0 &&
1505 SCIPisLT(pricingprob, SCIPgetRhsLinear(pricingprob, constraints[i]), consvals[0] + consvals[1]) &&
1506 !SCIPisLT(pricingprob, SCIPgetRhsLinear(pricingprob, constraints[i]), consvals[0]) &&
1507 !SCIPisLT(pricingprob, SCIPgetRhsLinear(pricingprob, constraints[i]), consvals[1]) )
1508 {
1509 cliquerconstypes[i] = LINEAR_IS_LIKE;
1510 }
1511 else
1512 {
1513 /* The current constraint is no linear IS constraint */
1514 SCIPgetConsNVars(pricingprob, constraints[i], &nvars, &retcode);
1515
1516 /* Check the coefficients of the variables in the constraint */
1517 for( j = 0; j < nvars; ++j )
1518 {
1519 if( consvals[j] != 1 && (couplingcoefindices[i] == -1) )
1520 {
1521 couplingcoefindices[i] = j;
1522 }
1523 else if( consvals[j] != 1 && couplingcoefindices[i] != -1 )
1524 {
1525 /* More than one variable has a coefficient unequal to 1 */
1526 SCIPdebugMessage("Exit: More than one coefficient unequal 1 in linear non-IS constraint.\n");
1527 return FALSE;
1528
1529 /*
1530 * Could handle other types of constraints similar to coupling constraints.
1531 * -> E.g.: One var. coeff. < 0 and this var is fixed to 0: Others must also be fixed to 0.
1532 * Otherwise, cannot handle!
1533 * -> To handle those, they must be identified and marked somehow to check if the coeff. is fixed
1534 * to 0 after propagation.
1535 * If not, the constraint cannot be handled. -> TERMINATE with GCG_PRICINGSTATUS_NOTAPPLICABLE
1536 */
1537 }
1538 }
1539 /* Check if we have a clique constraint (rhs 1 and coefficients 1) */
1540 if( (couplingcoefindices[i] == -1) && SCIPisEQ(pricingprob, SCIPgetRhsLinear(pricingprob, constraints[i]), 1) )
1541 {
1542 cliquerconstypes[i] = LINEAR_CLIQUE;
1543 }
1544 /* Check if we have a coupling constraint (rhs 0) */
1545 else if( (couplingcoefindices[i] != -1) && SCIPisEQ(pricingprob, SCIPgetRhsLinear(pricingprob, constraints[i]), 0.0) )
1546 {
1547 /* Special case: The coupling constraint is purely decorative (coefficient + 1 of coupling var >= #vars)*/
1548 if( abs(consvals[couplingcoefindices[i]]) + 1 >= nvars )
1549 {
1550 cliquerconstypes[i] = LINEAR_COUPLING_DECORATIVE;
1551 }
1552 /* Special case: The coefficient is -1, we treat the case like a clique constraint. */
1553 else if( abs(consvals[couplingcoefindices[i]]) == 1 )
1554 {
1555 cliquerconstypes[i] = LINEAR_COUPLING_CLIQUE;
1556 }
1557 else
1558 {
1559 /* Coupling coefficient is between 1 and npricingprobvars. */
1560 SCIPdebugMessage("Exit: Coupling coefficient unhandled, coef: %g.\n", consvals[couplingcoefindices[i]]);
1561 return FALSE;
1562 }
1563 }
1564 else
1565 {
1566 /* Constraint is neither a coupling nor a clique constraint */
1567 SCIPdebugMessage("Exit: Unhandled linear constraint.\n");
1568 return FALSE;
1569 }
1570 }
1571 }
1572 else
1573 {
1574 /* Constraint is a linear equality constraint */
1575 SCIPdebugMessage("Exit: Unhandled linear constraint: Equality constraint.\n");
1576 return FALSE;
1577 }
1578 }
1579 /* Constraint may be of type varbound: lhs <= x + c*y <= rhs */
1580 else if( strcmp(SCIPconshdlrGetName(conshdlr), "varbound") == 0 )
1581 {
1582 vconsvars[0] = SCIPgetVarVarbound(pricingprob, constraints[i]);
1583 vconsvars[1] = SCIPgetVbdvarVarbound(pricingprob, constraints[i]);
1584
1585 /* Check for "same"-constraints present in Ryan-Foster-Branching and save the links between the variables. */
1586 /* These are constraints of type: constraint of type x = y (lhs = rhs = 0 and c = -1)*/
1587 if( SCIPisEQ(pricingprob, SCIPgetLhsVarbound(pricingprob, constraints[i]), SCIPgetRhsVarbound(pricingprob, constraints[i])) )
1588 {
1589 /* c == -1, thus variables have to become both 0 or both 1 */
1590 if( (SCIPgetRhsVarbound(pricingprob, constraints[i]) == 0) && (SCIPgetVbdcoefVarbound(pricingprob, constraints[i]) == -1) )
1591 {
1592 cliquerconstypes[i] = VARBND_SAME;
1593
1594 /* Build the equality graph through updating the linkmatrix. */
1595 updateVarLinks(pricingprob, linkmatrix, vconsvars[0], vconsvars[1], linkedvars, nlinkedvars);
1596 /* Since the vars may not be part of the graph, we have to be able to set their solval later, thus we save the constraint index */
1597 markedconsindices[*markedcount] = i;
1598 ++(*markedcount);
1599 }
1600 else
1601 {
1602 /* RHS is unequal 0 and unequal 1 */
1603 SCIPdebugMessage("Exit: Unhandled equality constraint, c: %g, rhs: %g.\n",
1604 SCIPgetVbdcoefVarbound(pricingprob, constraints[i]), SCIPgetRhsVarbound(pricingprob, constraints[i]));
1605 return FALSE;
1606 }
1607 }
1608
1609 /* Check value of rhs to be 0 and of c to be <= -1 */
1610 if( SCIPisInfinity(pricingprob, -SCIPgetLhsVarbound(pricingprob, constraints[i])) )
1611 {
1612 if( SCIPisEQ(pricingprob, SCIPgetRhsVarbound(pricingprob, constraints[i]), 0) )
1613 {
1614 if( SCIPisLT(pricingprob, SCIPgetVbdcoefVarbound(pricingprob, constraints[i]), -1) ||
1615 SCIPisEQ(pricingprob, SCIPgetVbdcoefVarbound(pricingprob, constraints[i]), -1) )
1616 {
1617 cliquerconstypes[i] = VARBND_STD;
1618 }
1619 else
1620 {
1621 /* Coefficient c of varbound is > -1 and we do not have an IS constraint*/
1622 SCIPdebugMessage("Exit: Coefficient of Varbound unhandled Rhs: %g, Coeff: %g.\n",
1623 SCIPgetRhsVarbound(pricingprob, constraints[i]), SCIPgetVbdcoefVarbound(pricingprob, constraints[i]));
1624 return FALSE;
1625 }
1626 }
1627 /*
1628 * Rhs of varbound unequal to 0.
1629 * It may still be the case that we have an IS constraint with a non-linear handler.
1630 * The constraint may also be of the form c + 1 > rhs and c < rhs, i.e. a non-standard IS-constraint.
1631 * We treat these cases like a regular IS constraint.
1632 */
1633 else if( (SCIPisEQ(pricingprob, SCIPgetRhsVarbound(pricingprob, constraints[i]), 1) &&
1634 SCIPisEQ(pricingprob, SCIPgetVbdcoefVarbound(pricingprob, constraints[i]), 1)) ||
1635 (SCIPisLT(pricingprob, SCIPgetRhsVarbound(pricingprob, constraints[i]), SCIPgetVbdcoefVarbound(pricingprob, constraints[i]) + 1) &&
1636 SCIPisLT(pricingprob, SCIPgetVbdcoefVarbound(pricingprob, constraints[i]), SCIPgetRhsVarbound(pricingprob, constraints[i]))) )
1637 {
1638 cliquerconstypes[i] = VARBND_IS;
1639 }
1640 else
1641 {
1642 /* Rhs of varbound unequal to 0 and no IS constraint*/
1643 SCIPdebugMessage("Exit: Rhs of Varbound unhandled, Rhs: %g, Coeff:%g.\n",
1644 SCIPgetRhsVarbound(pricingprob, constraints[i]), SCIPgetVbdcoefVarbound(pricingprob, constraints[i]));
1645 return FALSE;
1646 }
1647 }
1648 /* We may have a varbound constraint of type x + cy == rhs */
1649 else if( SCIPisEQ(pricingprob, SCIPgetLhsVarbound(pricingprob, constraints[i]), SCIPgetRhsVarbound(pricingprob, constraints[i])) )
1650 {
1651 /* If the rhs is 0 and c == -1, both variables have to be set to 0 or to 1 */
1652 if( !((SCIPgetRhsVarbound(pricingprob, constraints[i]) == 0) && (SCIPgetVbdcoefVarbound(pricingprob, constraints[i]) == -1)) )
1653 {
1654 /* RHS is unequal 0 and unequal 1 */
1655 SCIPdebugMessage("Exit: Unhandled equality constraint, c: %g, rhs: %g.\n",
1656 SCIPgetVbdcoefVarbound(pricingprob, constraints[i]), SCIPgetRhsVarbound(pricingprob, constraints[i]));
1657 return FALSE;
1658 }
1659 }
1660 else
1661 {
1662 /* We have a varbound of type lhs <= x + c*y */
1663 SCIPdebugMessage("Exit: Varbound of type lhs <= x+c*y, c: %g, rhs: %g.\n",
1664 SCIPgetVbdcoefVarbound(pricingprob, constraints[i]), SCIPgetRhsVarbound(pricingprob, constraints[i]));
1665 SCIPdebugMessage("Constraint handler: %s\n", SCIPconshdlrGetName(conshdlr));
1666 return FALSE;
1667 }
1668 }
1669 else
1670 {
1671 /* Constraint handler neither linear nor varbound */
1672 SCIPdebugMessage("Exit: Unhandled constraint handler: %s \n", SCIPconshdlrGetName(conshdlr));
1673 return FALSE;
1674 }
1675 }
1676
1677#ifdef SCIP_DEBUG
1678 SCIPdebugMessage("Overview over instances constraint types:\n");
1679 const char* typeNames[] = {
1680 "LINEAR_IS", "LINEAR_IS_LIKE", "LINEAR_CLIQUE", "LINEAR_COUPLING_DECORATIVE",
1681 "LINEAR_COUPLING_CLIQUE", "VARBND_SAME", "VARBND_STD", "VARBND_IS"
1682 };
1683 int typeCount[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
1684 for( i = 0; i < nconss; i++ )
1685 typeCount[cliquerconstypes[i]]++;
1686 for( i = LINEAR_IS; i <= VARBND_IS; i++ )
1687 {
1688 SCIPdebugMessage(" Type '%s' : %i \n", typeNames[i], typeCount[i]);
1689 }
1690#endif
1691
1692 /* Has no invalid constraint. */
1693 return TRUE;
1694}
1695
1696/**
1697 * Propagate fixings of variables through constraints until the set of fixed variables is stable.
1698 * @return SCIP bool that is false in case the problem is infeasible, true if propagation was successful.
1699 */
1700static
1702 SCIP* pricingprob, /**< pricing problem SCIP data structure */
1703 SCIP_CONS** constraints, /**< Array containing pointers to SCIP constraints of pricing problem */
1704 SCIP_VAR** linkedvars, /**< Array of variables that are linked by eq-constraints */
1705 SCIP_VAR** vconsvars, /**< Array to store variables of a varbound constraint. */
1706 SCIP_VAR** varsincouplings, /**< Array of variables that are involved in couplings */
1707 SCIP_Real* solvals, /**< Array holding the current solution values of all problem variables */
1708 int** couplingmatrix, /**< Matrix indicating which variables are involved in couplings */
1709 int** linkmatrix, /**< Matrix indicating which variables are linked by a node */
1710 int* nvarsincouplings, /**< Index of varsincouplings array */
1711 int* couplingcoefindices,/**< Array for coupling coefficient of each constraint (if coupling) */
1712 int* consvarsfixedcount, /**< Array for counting how many variables are fixed per constraint */
1713 int nlinkedvars, /**< Index of linkedvars array */
1714 int nconss, /**< Index of constraints array */
1715 int* nfixedvars, /**< Integer counting the number of currently fixed problem variables */
1716 CLIQUER_CONSTYPE* cliquerconstypes /**< Array holding constraint types (specific to this solver) */
1717 )
1718{
1719 /* Local variables. */
1720 SCIP_CONSHDLR* conshdlr;
1721 SCIP_VAR** lconsvars;
1723 int nvars;
1724 int nvarsfixedtoone;
1725 int vartoset;
1726
1727 int i;
1728 int j;
1729 int prevfixed;
1730
1731 /* Compute implied variable fixings. */
1732 /* This is done by propagating the fixings already found over the constraints. */
1733 /* It is stopped once the set of fixed variables becomes stable across one iteration. */
1734 prevfixed = -1; /* Need at least one iteration (because it is checked if linked variables appear in IS-constraint, i.e., x = y and x + y <= 1). */
1735 while( prevfixed < *nfixedvars ) {
1736
1737 /* We still have a fixed variable to be processed. Iterate through constraints. */
1738 prevfixed = *nfixedvars;
1739 for( i = 0; i < nconss; i++ )
1740 {
1741 assert(constraints[i] != NULL);
1742 conshdlr = SCIPconsGetHdlr(constraints[i]);
1743 assert(conshdlr != NULL);
1744
1745 /* Variables do not know in which constraints they appear. */
1746 /* Therefore, we count how many variables are fixed per constraint to skip constraints which have only fixed variables. */
1747 /* The constraint is checked if it is consistent with the fixings. Afterwards, the counter is updated. */
1748 /* This ensures every constraint is checked for consistency once before we skip it. */
1749
1750 /* Check nature of the constraint */
1751
1752 /* The constraint may be of type 'linear' */
1753 if( strcmp(SCIPconshdlrGetName(conshdlr), "linear") == 0 )
1754 {
1755 lconsvars = SCIPgetVarsLinear(pricingprob, constraints[i]);
1756
1757 /* Add coupling cons vars to coupling digraph. */
1758 if( cliquerconstypes[i] == LINEAR_COUPLING_CLIQUE || cliquerconstypes[i] == LINEAR_COUPLING_DECORATIVE )
1759 {
1760 SCIPgetConsNVars(pricingprob, constraints[i], &nvars, &retcode);
1761 updateCouplingDiGraph(pricingprob, lconsvars, nvars, lconsvars[couplingcoefindices[i]], couplingmatrix,
1762 varsincouplings, nvarsincouplings, linkedvars, nlinkedvars, linkmatrix);
1763 }
1764
1765 /* If all variables are fixed, constraint can be skipped */
1766 if( consvarsfixedcount[i] == SCIPgetNVarsLinear(pricingprob, constraints[i]) )
1767 continue;
1768
1769 if( cliquerconstypes[i] == LINEAR_IS || cliquerconstypes[i] == LINEAR_IS_LIKE )
1770 {
1771 /* Propagate variable fixings through IS-constraint. */
1772 if( solvals[SCIPvarGetProbindex(lconsvars[0])] == 1 && solvals[SCIPvarGetProbindex(lconsvars[1])] == 1 )
1773 {
1774 /* Both variables are fixed to 1 which contradicts the IS constraint. -> Infeasible. */
1775 SCIPdebugMessage("Exit: Both variables in IS-constraint fixed to 1.\n");
1776 return FALSE;
1777 }
1778 else if( solvals[SCIPvarGetProbindex(lconsvars[0])] == 1 && solvals[SCIPvarGetProbindex(lconsvars[1])] == -1 )
1779 {
1780 /* One variable0 is fixed to 1 -> fix variable1 to 0. */
1781 solvals[SCIPvarGetProbindex(lconsvars[1])] = 0;
1782 (*nfixedvars)++;
1783 consvarsfixedcount[i] = 2;
1784 }
1785 else if( solvals[SCIPvarGetProbindex(lconsvars[0])] == -1 && solvals[SCIPvarGetProbindex(lconsvars[1])] == 1 )
1786 {
1787 /* One variable1 is fixed to 1 -> fix variable0 to 0. */
1788 solvals[SCIPvarGetProbindex(lconsvars[0])] = 0;
1789 (*nfixedvars)++;
1790 consvarsfixedcount[i] = 2;
1791 }
1792 else if( solvals[SCIPvarGetProbindex(lconsvars[0])] == -1 &&
1793 solvals[SCIPvarGetProbindex(lconsvars[1])] == -1 &&
1794 areVarsLinked(pricingprob, linkmatrix, lconsvars[0], lconsvars[1], linkedvars, nlinkedvars) )
1795 {
1796 /* The two variables are linked and appear in an IS-constraint, i.e., x = y and x + y <= 1.
1797 * -> Both variables must be fixed to 0. Thus calling the setter for one is sufficient */
1798 setLinkedSolvals(pricingprob, solvals, linkmatrix, linkedvars, nlinkedvars, lconsvars[0], 0.0);
1799 *nfixedvars += 2;
1800 consvarsfixedcount[i] = 2;
1801 }
1802 }
1803 else
1804 {
1805 /* The current constraint is no linear IS constraint */
1806 SCIPgetConsNVars(pricingprob, constraints[i], &nvars, &retcode);
1807 nvarsfixedtoone = 0;
1808
1809 /* Count the number of variables with a fixed value of 1. */
1810 for( j = 0; j < nvars; ++j )
1811 {
1812 if( solvals[SCIPvarGetProbindex(lconsvars[j])] == 1 )
1813 nvarsfixedtoone++;
1814 }
1815
1816 if( cliquerconstypes[i] == LINEAR_CLIQUE && nvarsfixedtoone > 1 )
1817 {
1818 /* More than one variable has a value fixed to 1 */
1819 SCIPdebugMessage("Exit: More than one variable with value fixed to 1 in clique constraint.\n");
1820 return FALSE;
1821 }
1822 else if( cliquerconstypes[i] == LINEAR_COUPLING_CLIQUE && nvarsfixedtoone > 2 )
1823 {
1824 SCIPdebugMessage("Exit: To many variable values fixed to 1 in coupling constraint with coupling variable value fixed to 1.\n");
1825 return FALSE;
1826 }
1827 else if( (cliquerconstypes[i] == LINEAR_COUPLING_CLIQUE || cliquerconstypes[i] == LINEAR_COUPLING_DECORATIVE) &&
1828 solvals[SCIPvarGetProbindex(lconsvars[couplingcoefindices[i]])] == 0 &&
1829 nvarsfixedtoone >= 1 )
1830 {
1831 SCIPdebugMessage("Exit: To many variable values fixed to 1 in coupling constraint with coupling variable value fixed to 0.\n");
1832 return FALSE;
1833 }
1834 else if( (cliquerconstypes[i] == LINEAR_CLIQUE && nvarsfixedtoone == 1) ||
1835 (cliquerconstypes[i] == LINEAR_COUPLING_CLIQUE &&
1836 nvarsfixedtoone == 2 &&
1837 solvals[SCIPvarGetProbindex(lconsvars[couplingcoefindices[i]])] == 1) ||
1838 ((cliquerconstypes[i] == LINEAR_COUPLING_CLIQUE || cliquerconstypes[i] == LINEAR_COUPLING_DECORATIVE) &&
1839 solvals[SCIPvarGetProbindex(lconsvars[couplingcoefindices[i]])] == 0) )
1840 {
1841 /* We have a clique constraint with exactly one variables value fixed to 1. */
1842 /* Or a coupling constraint that can be handled like a clique constraint with exactly one variable value fixed to 1. */
1843 /* Or a coupling constraint (clique or decorative) that has the coupling variable fixed to 0. */
1844
1845 /* In all these cases: All other involved variables need to be fixed to 0. */
1846 for( j = 0; j < nvars; j++ )
1847 {
1848 /* The solvals of the other variables are either 0 or -1 */
1849 /* Only fix to 0 and add to fixed variable array if value is -1 */
1850 if( solvals[SCIPvarGetProbindex(lconsvars[j])] == -1 )
1851 {
1852 solvals[SCIPvarGetProbindex(lconsvars[j])] = 0;
1853 (*nfixedvars)++;
1854 }
1855 }
1856 consvarsfixedcount[i] = nvars; /* All variables of this constraint are fixed now. */
1857 }
1858 else if( (cliquerconstypes[i] == LINEAR_COUPLING_CLIQUE || cliquerconstypes[i] == LINEAR_COUPLING_DECORATIVE) &&
1859 nvarsfixedtoone == 1 &&
1860 solvals[SCIPvarGetProbindex(lconsvars[couplingcoefindices[i]])] == -1 )
1861 {
1862 /* We have a coupling constraint with one variable (different from the coupling variable!) fixed to 1.
1863 * And the coupling variable is unfixed. Then the coupling variable needs to be fixed to 1 too. */
1864 solvals[SCIPvarGetProbindex(lconsvars[couplingcoefindices[i]])] = 1;
1865 (*nfixedvars)++;
1866
1867 /* In case of a clique constraint, we can fix all other variables than the (now 2) fixed ones to 0. */
1868 if( cliquerconstypes[i] == LINEAR_COUPLING_CLIQUE )
1869 {
1870 for( j = 0; j < nvars; j++ )
1871 {
1872 /* The solvals of the other variables are either 0 or -1 */
1873 /* Only fix to 0 and add to fixed variable array if value is -1 */
1874 if( solvals[SCIPvarGetProbindex(lconsvars[j])] == -1 )
1875 {
1876 solvals[SCIPvarGetProbindex(lconsvars[j])] = 0;
1877 (*nfixedvars)++;
1878 }
1879 }
1880 consvarsfixedcount[i] = nvars; /* All variables of this constraint are fixed now. */
1881 }
1882 }
1883 }
1884 }
1885 /* Constraint may be of type varbound: lhs <= x + c*y <= rhs */
1886 else if( strcmp(SCIPconshdlrGetName(conshdlr), "varbound") == 0 )
1887 {
1888 vconsvars[0] = SCIPgetVarVarbound(pricingprob, constraints[i]);
1889 vconsvars[1] = SCIPgetVbdvarVarbound(pricingprob, constraints[i]);
1890
1891 /* Add coupling-like varbound cons vars to coupling digraph. */
1892 if( cliquerconstypes[i] == VARBND_STD )
1893 updateCouplingDiGraph(pricingprob, vconsvars, 2, vconsvars[1], couplingmatrix, varsincouplings,
1894 nvarsincouplings, linkedvars, nlinkedvars, linkmatrix);
1895
1896 if( consvarsfixedcount[i] == 2 )
1897 continue; /* If all variables are fixed, constraint can be skipped */
1898
1899 if( cliquerconstypes[i] == VARBND_SAME )
1900 {
1901 /* Propagate variable fixings through same-constraint. */
1902 if( solvals[SCIPvarGetProbindex(vconsvars[0])] >= 0 && solvals[SCIPvarGetProbindex(vconsvars[1])] >= 0 &&
1903 solvals[SCIPvarGetProbindex(vconsvars[0])] != solvals[SCIPvarGetProbindex(vconsvars[1])] )
1904 {
1905 /* One variable is fixed to 1, the other to 0. -> Infeasible. */
1906 SCIPdebugMessage("Exit: Variables in same-constraint are fixed to different values.\n");
1907 return FALSE;
1908 }
1909 else if( solvals[SCIPvarGetProbindex(vconsvars[0])] >= 0 && solvals[SCIPvarGetProbindex(vconsvars[1])] == -1 )
1910 {
1911 /* Fix (the unfixed) variable1 to the value of variable0 */
1912 solvals[SCIPvarGetProbindex(vconsvars[1])] = solvals[SCIPvarGetProbindex(vconsvars[0])];
1913 (*nfixedvars)++;
1914 consvarsfixedcount[i] = 2; /* All variables of this constraint are fixed now. */
1915 }
1916 else if( solvals[SCIPvarGetProbindex(vconsvars[0])] == -1 && solvals[SCIPvarGetProbindex(vconsvars[1])] >= 0 )
1917 {
1918 /* Fix (the unfixed) variable0 to the value of variable1 */
1919 solvals[SCIPvarGetProbindex(vconsvars[0])] = solvals[SCIPvarGetProbindex(vconsvars[1])];
1920 (*nfixedvars)++;
1921 consvarsfixedcount[i] = 2; /* All variables of this constraint are fixed now. */
1922 }
1923 }
1924 /* From here on we may have a varbound constraint with x + c*y <= b. */
1925 else
1926 {
1927 if( solvals[SCIPvarGetProbindex(vconsvars[0])] == 1 &&
1928 ((cliquerconstypes[i] == VARBND_STD && solvals[SCIPvarGetProbindex(vconsvars[1])] == 0) ||
1929 (cliquerconstypes[i] == VARBND_IS && solvals[SCIPvarGetProbindex(vconsvars[1])] == 1)) )
1930 {
1931 if( solvals[SCIPvarGetProbindex(vconsvars[1])] == 0 )
1932 SCIPdebugMessage("Exit: x fixed to 1, y fixed to 0 in varbound constraint.\n");
1933 if( solvals[SCIPvarGetProbindex(vconsvars[1])] == 1 )
1934 SCIPdebugMessage("Exit: Both variables fixed to 1 in non-linear handler IS-constraint.\n");
1935 return FALSE;
1936 }
1937 else if( cliquerconstypes[i] == VARBND_STD &&
1938 ((solvals[SCIPvarGetProbindex(vconsvars[0])] == 1 && solvals[SCIPvarGetProbindex(vconsvars[1])] == -1) ||
1939 (solvals[SCIPvarGetProbindex(vconsvars[0])] == -1 && solvals[SCIPvarGetProbindex(vconsvars[1])] == 0)) )
1940 {
1941 /* Constraint behaving like x <= c*y, c >= 1 - and one variable is already fixed to 1. */
1942 /* Variable to set and value to set the variable to. */
1943 if( solvals[SCIPvarGetProbindex(vconsvars[0])] == 1 && solvals[SCIPvarGetProbindex(vconsvars[1])] == -1 )
1944 vartoset = 1; /* x is fixed to 1 and y is unset -> set y to 1. */
1945 else
1946 vartoset = 0; /* y is fixed to 0 and x is unset -> set x to 0. */
1947
1948 solvals[SCIPvarGetProbindex(vconsvars[vartoset])] = vartoset;
1949 (*nfixedvars)++;
1950 consvarsfixedcount[i] = 2; /* All variables of this constraint are fixed now. */
1951 }
1952 else if( cliquerconstypes[i] == VARBND_IS &&
1953 ((solvals[SCIPvarGetProbindex(vconsvars[0])] == 1 && solvals[SCIPvarGetProbindex(vconsvars[1])] == -1) ||
1954 (solvals[SCIPvarGetProbindex(vconsvars[0])] == -1 && solvals[SCIPvarGetProbindex(vconsvars[1])] == 1)) )
1955 {
1956 /* Constraint behaving like x + y <= 1 - and one variable is already fixed to 1. */
1957 /* Variable to set and value to set the variable to. */
1958 if( solvals[SCIPvarGetProbindex(vconsvars[0])] == 1 && solvals[SCIPvarGetProbindex(vconsvars[1])] == -1 )
1959 vartoset = 1; /* x is fixed to 1 and y is unset -> set y to 0. */
1960 else
1961 vartoset = 0; /* y is fixed to 1 and x is unset -> set x to 0. */
1962
1963 solvals[SCIPvarGetProbindex(vconsvars[vartoset])] = 0;
1964 (*nfixedvars)++;
1965 consvarsfixedcount[i] = 2; /* All variables of this constraint are fixed now. */
1966 }
1967 else if( cliquerconstypes[i] == VARBND_IS &&
1968 solvals[SCIPvarGetProbindex(vconsvars[0])] == -1 &&
1969 solvals[SCIPvarGetProbindex(vconsvars[1])] == -1 &&
1970 areVarsLinked(pricingprob, linkmatrix, vconsvars[0], vconsvars[1], linkedvars, nlinkedvars) )
1971 {
1972 /* The two variables are linked and appear in an IS-constraint, i.e., x = y and x + y <= 1.
1973 * -> Both variables must be fixed to 0. Thus calling the setter for one is sufficient */
1974 setLinkedSolvals(pricingprob, solvals, linkmatrix, linkedvars, nlinkedvars, vconsvars[0], 0.0);
1975 *nfixedvars += 2;
1976 consvarsfixedcount[i] = 2; /* All variables of this constraint are fixed now. */
1977 }
1978 }
1979 }
1980 }
1981 }
1982 /* No conflicting variable fixings encountered. */
1983 return TRUE;
1984}
1985
1986/* Basic idea of the heuristic solver: The biggest independent set in a graph corresponds to the biggest clique
1987 * of the complement graph, for which we use the cliquer library to find it. We therefore transform the variables
1988 * into graph nodes and delete the edge between two nodes if there is an independent set constraint involving both.
1989 * By doing this, they cannot both be part of the maximum clique and thus not be both part of the independent set.
1990 * The correspondence between variables and graph nodes is done by a bijection using the indsetvars array:
1991 * The variable indsetvars[i] is the i-th node of the graph, indexcount keeps track of the next unmapped graph node.
1992 * There is also the possibility that two variables x and y are linked with an equality constraint x-y = 0 due to
1993 * Ryan-Foster-Branching. In this case, all linked variables are mapped to the same node. There are functions
1994 * to get the corresponding node index.
1995 *
1996 * Since we want to add a column with the best reduced cost, we take the objective coefficient of variables into
1997 * account by giving their graph nodes corresponding weights and searching for a weight-maximal clique.
1998 *
1999 * If you would like to add the handling of more types of constraints, please note that the current code
2000 * assumes that at no point edges are added to the graph, except during initialisation.
2001 *
2002 * This solver is currently able to handle the following type of constraints:
2003 * IS-Constraints, i.e. c*x + d*y <= 1*e
2004 * Coupling-Constraints, i.e. v + w + x -c*y <= 0
2005 * Clique-Constraints, i.e. v + w + x + y <= 1
2006 * Same-Constraints, i.e. x - y = 0 for varbound-constraints.
2007 * Vbd-constraints of type x - c*y <= 0 for c <= -1
2008 */
2009
2010/** Solve the pricing problem as an independent set problem, in an approximate way. */
2011static
2013 SCIP_Bool exactly, /**< should the pricing problem be solved to optimality or heuristically? */
2014 GCG* gcg, /**< GCG data structure */
2015 SCIP* pricingprob, /**< pricing problem SCIP data structure */
2016 GCG_SOLVERDATA* solver, /**< solver data structure */
2017 int probnr, /**< problem number */
2018 SCIP_Real* lowerbound, /**< pointer to store lower bound */
2019 GCG_PRICINGSTATUS* status /**< pointer to store pricing problem status */
2020 )
2021{ /*lint -e715 */
2022 SCIP_CONS** constraints;
2023 SCIP_CONSHDLR* conshdlr;
2024 SCIP_VAR** lconsvars;
2025 SCIP_VAR** vconsvars;
2026 SCIP_VAR** indsetvars;
2027 SCIP_VAR** pricingprobvars;
2028 SCIP_VAR** linkedvars;
2029 SCIP_VAR** couplvars;
2030 SCIP_Real* solvals;
2031 SCIP_Real* aggrobjcoef;
2032 SCIP_Real density;
2035 SCIP_Bool ismemgraphallocated;
2036 set_t clique;
2037 graph_t* g;
2038 clique_options cl_opts;
2039 int** linkmatrix;
2040 int** couplingmatrix;
2041 int* couplingcoefindices;
2042 int* consvarsfixedcount;
2043 int* consvarsfixedtozerocount;
2044 int* markedconsindices;
2045 int nlinkedvars;
2046 int ncouplvars;
2047 int npricingprobvars;
2048 int nvars;
2049 int nconss;
2050 int nedges;
2051 int markedcount;
2052 int indexcount;
2053 int nfixedvars;
2054 int nodeindex0;
2055 int nodeindex1;
2056 int cliqueconscount;
2057 CLIQUER_CONSTYPE* cliquerconstypes;
2058 GCG_COL* col;
2059
2060 int i;
2061 int j;
2062 int k;
2063
2064 assert(gcg != NULL);
2065 assert(pricingprob != NULL);
2066 assert(solver != NULL);
2067 assert(lowerbound != NULL);
2068 assert(status != NULL);
2069
2070 /* Check if solver already found itself to be not applicable to actual problem. */
2071 if( solver->isnotapplicable[probnr] )
2072 {
2073 SCIPdebugMessage("Exit: Solver already found to be not applicable to pricing problem %i.\n", probnr);
2075 return SCIP_OKAY;
2076 }
2077
2078 pricingprobvars = SCIPgetVars(pricingprob);
2079 npricingprobvars = SCIPgetNVars(pricingprob);
2080
2081 constraints = SCIPgetConss(pricingprob);
2082 nconss = SCIPgetNConss(pricingprob);
2083
2084 /* All variables of the problem are expected to be binary */
2085 if( SCIPgetNBinVars(pricingprob) < npricingprobvars )
2086 {
2087 SCIPdebugMessage("Exit: Nonbinary variables.\n");
2090 return SCIP_OKAY;
2091 }
2092
2093 SCIP_CALL( SCIPallocBufferArray(pricingprob, &markedconsindices, nconss) );
2094 SCIP_CALL( SCIPallocBufferArray(pricingprob, &solvals, npricingprobvars) );
2095 SCIP_CALL( SCIPallocBufferArray(pricingprob, &linkedvars, npricingprobvars) );
2096 SCIP_CALL( SCIPallocBufferArray(pricingprob, &linkmatrix, npricingprobvars) );
2097 for( i = 0; i < npricingprobvars; ++i )
2098 {
2099 SCIP_CALL( SCIPallocBufferArray(pricingprob, &linkmatrix[i], npricingprobvars) );
2100 }
2101 SCIP_CALL( SCIPallocBufferArray(pricingprob, &cliquerconstypes, nconss) );
2102 SCIP_CALL( SCIPallocBufferArray(pricingprob, &consvarsfixedcount, nconss) );
2103 SCIP_CALL( SCIPallocBufferArray(pricingprob, &couplingcoefindices, nconss) );
2104 SCIP_CALL( SCIPallocBufferArray(pricingprob, &vconsvars, 2) );
2105 SCIP_CALL( SCIPallocBufferArray(pricingprob, &couplvars, npricingprobvars) );
2106 SCIP_CALL( SCIPallocBufferArray(pricingprob, &couplingmatrix, npricingprobvars) );
2107 for( i = 0; i < npricingprobvars; ++i )
2108 {
2109 SCIP_CALL( SCIPallocClearBufferArray(pricingprob, &couplingmatrix[i], npricingprobvars) );
2110 }
2111
2112
2113 /* Boolean variables to keep track of what was allocated. */
2114 ismemgraphallocated = FALSE;
2115
2116 /* Used to keep track of node indizes for bijection while building the graph */
2117 indexcount = 0;
2118
2119 /* Use to handle a rare combination of IS and varbound constraints */
2120 markedcount = 0;
2121
2122 /* Used to keep track of the index of the linkedvars array */
2123 nlinkedvars = 0;
2124
2125 /* Used to keep track of the number of variables that have a fixed value */
2126 nfixedvars = 0;
2127
2128 /* Used to keep track of the number of variables that are involved in coupling constraints (or std varbnd) */
2129 ncouplvars = 0;
2130
2131 /* Build complementary graph by first creating a complete graph and then deleting edges of IS constraints. */
2132 /* Size is first chosen to be maximal and then later cropped down to the actual number of nodes. */
2133 /* Initialize the linkmatrix array. */
2134 /* Initialize the solvals array. */
2135 g = graph_new(npricingprobvars);
2136 for( i = 0; i < npricingprobvars; ++i )
2137 {
2138 for( j = 0; j < npricingprobvars; ++j )
2139 {
2140 if( i < j )
2141 {
2142 GRAPH_ADD_EDGE(g, i, j);
2143 }
2144 linkmatrix[i][j] = 0;
2145 }
2146 /* If bounds fix variables to some value, initialize solvals with this value. */
2147 if( SCIPisLT(pricingprob, SCIPvarGetUbLocal(pricingprobvars[i]), 1.0) )
2148 {
2149 solvals[i] = 0.0;
2150 nfixedvars++;
2151 }
2152 else if( SCIPisGT(pricingprob, SCIPvarGetLbLocal(pricingprobvars[i]), 0.0) )
2153 {
2154 solvals[i] = 1.0;
2155 nfixedvars++;
2156 }
2157 else
2158 solvals[i] = -1.0; /* To later determine whether a variable was constrained */
2159 }
2160
2161 SCIPdebugMessage( "Number of variables fixed by bound (before propagation): %d (of %d).\n", nfixedvars, npricingprobvars );
2162
2163 for( i = 0; i < nconss; i++ )
2164 {
2165 consvarsfixedcount[i] = 0; /* Initialize array to count the number of fixed vars per constraint. */
2166 couplingcoefindices[i] = -1; /* Initialize array to save coupling coefficient if constraint is a coupling constraint. */
2167 }
2168
2169
2170 /* Determine constraint types for easier handling later on.
2171 * Also, it is checked for constraints that cannot be handled by this solver. */
2172 if( !determineCliquerConsTypes(pricingprob, constraints, linkedvars, vconsvars, markedconsindices, linkmatrix,
2173 couplingcoefindices, &nlinkedvars, nconss, &markedcount, cliquerconstypes) )
2174 {
2175 /* Encountered constraint that can not be handled. */
2178 goto TERMINATE;
2179 }
2180
2181 /* Cliquer may perform worse than other solvers (e.g. SCIP) on problems containing many clique inequalities:
2182 * -> Thus, we do not apply the solver if the percentage of clique constraints exceeds a limit parameter. */
2183 if( SCIPisLT(pricingprob, solver->maxcliqueconsperc, 1.0) )
2184 {
2185 cliqueconscount = 0;
2186 for( i = 0; i < nconss; i++ )
2187 {
2188 if( cliquerconstypes[i] == LINEAR_CLIQUE )
2189 cliqueconscount++;
2190 }
2191
2192 if( SCIPisGT(pricingprob, ((SCIP_Real)cliqueconscount / nconss), solver->maxcliqueconsperc) )
2193 {
2194 SCIPdebugMessage("Exit: Clique-constraint percentage limit exceeded, clique-cons perc.: %3.f\n",
2195 ((SCIP_Real)cliqueconscount / nconss));
2197 goto TERMINATE;
2198 }
2199 }
2200
2201 /* Propagate the already fixed variables to (potentially) get more fixed variables.
2202 * Also, builds coupling digraph to distribute objective coefficients of coupling variables. */
2203 if( (nlinkedvars > 0 || nfixedvars > 0 || solver->objcoefdistr > 0) &&
2204 !propagateVariablefixings(pricingprob, constraints, linkedvars, vconsvars, couplvars, solvals, couplingmatrix,
2205 linkmatrix, &ncouplvars, couplingcoefindices, consvarsfixedcount, nlinkedvars,
2206 nconss, &nfixedvars, cliquerconstypes) )
2207 {
2208 /* Variables are fixed in a conflicting way. -> problem is infeasible. */
2210 goto TERMINATE;
2211 }
2212
2213 SCIPdebugMessage( "Number of variables fixed before building the graph (after propagation): %d (of %d).\n",
2214 nfixedvars, npricingprobvars );
2215
2216 /* Check if all variables of the pricing problem are fixed. In this case, it is the only feasible solution. */
2217 /* No graph needs to be built, we just can build the corresponding column. */
2218 if( nfixedvars == npricingprobvars )
2219 goto CREATECOLUMN;
2220
2221 /* Allocate memory needed for building the graph and creating a column. */
2222 SCIP_CALL( SCIPallocBufferArray(pricingprob, &indsetvars, npricingprobvars) );
2223 SCIP_CALL( SCIPallocBufferArray(pricingprob, &consvarsfixedtozerocount, nconss) );
2224 SCIP_CALL( SCIPallocBufferArray(pricingprob, &aggrobjcoef, npricingprobvars) );
2225 ismemgraphallocated = TRUE;
2226
2227 SCIPdebugMessage("nlinkedvars = %i , ncouplvars = %i , coefdistrheur = %i\n", nlinkedvars, ncouplvars, solver->objcoefdistr);
2228
2229 /* If any variable is linked or coupled, aggrobjcoef array needs to be initialized. */
2230 if( nlinkedvars > 0 || ncouplvars > 0 )
2231 {
2232 for( i = 0; i < npricingprobvars; ++i )
2233 aggrobjcoef[SCIPvarGetProbindex(pricingprobvars[i])] = SCIPvarGetObj(pricingprobvars[i]);
2234 }
2235
2236 /* Before adding nodes to the graph, aggregating the objective coefficients may be necessary if "same"-constraints exist. */
2237 if( nlinkedvars > 0 )
2238 aggregateObjCoef(pricingprob, linkmatrix, linkedvars, nlinkedvars, aggrobjcoef);
2239
2240 /* If there are coupling or standard varbound constraints, it may be necessary to distribute objective coefficients. */
2241 if( solver->objcoefdistr > 0 && ncouplvars > 0 )
2242 distributeObjCoef(pricingprob, constraints, nconss, couplingcoefindices, cliquerconstypes, couplingmatrix,
2243 couplvars, ncouplvars, linkedvars, nlinkedvars, linkmatrix, aggrobjcoef, solver->objcoefdistr,
2244 solver->usemultiplicity);
2245
2246 /* Now calculate scaling factor based on maximum aggregated objective coefficient value. */
2247
2248 /* Cliquer library explicitly demands the node weights to be positive integers.
2249 * Additionally, the sum of node weights needs to be smaller than INT_MAX.
2250 * We restrict our scaling factor to always honor this constraint.
2251 */
2252 if( !areObjectivesIntegral(pricingprob, linkedvars, nlinkedvars, couplvars, ncouplvars, aggrobjcoef) )
2253 scalingfactor = scaleRelativeToMax(pricingprob, linkedvars, nlinkedvars, couplvars, ncouplvars, aggrobjcoef);
2254 else
2255 scalingfactor = 1.0;
2256
2257
2258 /* Count number of fixed variables and fixed-to-0 variables per constraint. */
2259 for( i = 0; i < nconss; i++ )
2260 {
2261 consvarsfixedtozerocount[i] = 0;
2262
2263 /* Skip if there are no fixed variables. */
2264 if( nfixedvars <= 0)
2265 continue;
2266
2267 /* Get variables of the constraint in dependence of the constraint handler */
2268 switch( cliquerconstypes[i] )
2269 {
2270 case LINEAR_IS:
2271 case LINEAR_IS_LIKE:
2272 case LINEAR_CLIQUE:
2275 lconsvars = SCIPgetVarsLinear(pricingprob, constraints[i]);
2276 SCIPgetConsNVars(pricingprob, constraints[i], &nvars, &retcode);
2277 break;
2278 case VARBND_SAME:
2279 case VARBND_STD:
2280 case VARBND_IS:
2281 vconsvars[0] = SCIPgetVarVarbound(pricingprob, constraints[i]);
2282 vconsvars[1] = SCIPgetVbdvarVarbound(pricingprob, constraints[i]);
2283 lconsvars = vconsvars;
2284 nvars = 2;
2285 break;
2286 }
2287
2288 /* Count variables fixed to 0. */
2289 for( j = 0; j < nvars; j++ )
2290 {
2291 if( solvals[SCIPvarGetProbindex(lconsvars[j])] == 0 )
2292 consvarsfixedtozerocount[i]++;
2293 }
2294
2295 if( consvarsfixedtozerocount[i] == 0 )
2296 {
2297 /* Count of fixed variables is still correct. */
2298 continue;
2299 }
2300 if( consvarsfixedcount[i] < nvars && consvarsfixedtozerocount[i] == nvars )
2301 {
2302 /* All variables fixed to 0. */
2303 consvarsfixedcount[i] = consvarsfixedtozerocount[i];
2304 }
2305 else if( consvarsfixedcount[i] < nvars )
2306 {
2307 /* Need to recount the overall number of fixed variables. */
2308 consvarsfixedcount[i] = 0;
2309 for( j = 0; j < nvars; j++ )
2310 {
2311 if( solvals[SCIPvarGetProbindex(lconsvars[j])] >= 0 )
2312 consvarsfixedcount[i]++;
2313 }
2314 }
2315 }
2316
2317 /* All links have to be established first before we can add nodes to the graph, else pairs (a,b) and (c,d) would be mapped to different nodes */
2318 /* if link (b,c) is present but later in the list. We have to run through the constraints again as the linked variables need to be assigned to nodes */
2319 /* in order for the rest of the logic to work out (node indices are fetched during runtime) */
2320 for( i = 0; i < markedcount; ++i )
2321 {
2322 /* Since we know that all marked constraints at this point are same constraints, we can just add them to the graph. */
2323 vconsvars[0] = SCIPgetVarVarbound(pricingprob, constraints[markedconsindices[i]]);
2324 if( SCIPisLT(pricingprob, getAggrObjCoef(vconsvars[0], nlinkedvars, ncouplvars, aggrobjcoef), 0) )
2325 {
2326 nodeindex0 = addVarToGraph(pricingprob, g, vconsvars[0], &indexcount, scalingfactor, indsetvars, linkmatrix,
2327 linkedvars, nlinkedvars, ncouplvars, aggrobjcoef);
2328 }
2329 }
2330
2331 /* Main loop to check the nature of each constraint and manipulate the graph accordingly (add nodes, remove edges). */
2332 for( i = 0; i < nconss; ++i )
2333 {
2334 assert(constraints[i] != NULL);
2335 conshdlr = SCIPconsGetHdlr(constraints[i]);
2336 assert(conshdlr != NULL);
2337
2338 SCIPgetConsNVars(pricingprob, constraints[i], &nvars, &retcode);
2339
2340 /* The constraint may not be of type 'linear' */
2341 if( strcmp(SCIPconshdlrGetName(conshdlr), "linear") == 0 )
2342 {
2343 /* If all variables are fixed, constraint can be skipped. */
2344 if( consvarsfixedcount[i] == nvars )
2345 continue;
2346
2347 lconsvars = SCIPgetVarsLinear(pricingprob, constraints[i]);
2348
2349 if((cliquerconstypes[i] == LINEAR_IS &&
2350 (SCIPisLT(pricingprob, getAggrObjCoef(lconsvars[0], nlinkedvars, ncouplvars, aggrobjcoef), 0) ||
2351 SCIPisLT(pricingprob, getAggrObjCoef(lconsvars[1], nlinkedvars, ncouplvars, aggrobjcoef), 0))) ||
2352 cliquerconstypes[i] == LINEAR_IS_LIKE )
2353 {
2354 /* One variable fixed to 0 (the other is not fixed): constraint is relaxed -> continue. */
2355 if( consvarsfixedcount[i] == 1 && consvarsfixedtozerocount[i] == 1 )
2356 continue;
2357
2358 /* Add variables nodes to graph if they have a negative (aggregated) objective coefficient. */
2359 nodeindex0 = -1;
2360 if( SCIPisLT(pricingprob, getAggrObjCoef(lconsvars[0], nlinkedvars, ncouplvars, aggrobjcoef), 0) )
2361 nodeindex0 = addVarToGraph(pricingprob, g, lconsvars[0], &indexcount, scalingfactor, indsetvars, linkmatrix,
2362 linkedvars, nlinkedvars, ncouplvars, aggrobjcoef);
2363
2364 nodeindex1 = -1;
2365 if( SCIPisLT(pricingprob, getAggrObjCoef(lconsvars[1], nlinkedvars, ncouplvars, aggrobjcoef), 0) )
2366 nodeindex1 = addVarToGraph(pricingprob, g, lconsvars[1], &indexcount, scalingfactor, indsetvars, linkmatrix,
2367 linkedvars, nlinkedvars, ncouplvars, aggrobjcoef);
2368
2369 /* If both vairables nodes are added and an edge exists between the two in the graph: delete this edge. */
2370 if( nodeindex0 >= 0 && nodeindex1 >= 0 && GRAPH_IS_EDGE(g, nodeindex0, nodeindex1) )
2371 {
2372 GRAPH_DEL_EDGE(g, nodeindex0, nodeindex1);
2373 }
2374 }
2375 else
2376 {
2377 /* Cases in which constraint is relaxed through fixings. -> continue. */
2378 if( (cliquerconstypes[i] == LINEAR_CLIQUE && consvarsfixedcount[i] == nvars - 1 && consvarsfixedtozerocount[i] == nvars - 1) ||
2379 (cliquerconstypes[i] == LINEAR_COUPLING_CLIQUE &&
2380 consvarsfixedcount[i] == nvars - 1 &&
2381 consvarsfixedtozerocount[i] == nvars - 2 &&
2382 solvals[SCIPvarGetProbindex(lconsvars[couplingcoefindices[i]])] == 1.0) )
2383 continue;
2384
2385 /* If coupling constraint, add coupling var to graph and mark it in the solvals array. */
2386 if( (cliquerconstypes[i] == LINEAR_COUPLING_DECORATIVE && solvals[SCIPvarGetProbindex(lconsvars[couplingcoefindices[i]])] != 1.0) ||
2387 cliquerconstypes[i] == LINEAR_COUPLING_CLIQUE )
2388 {
2389 /* We cannot guarantee that there is no constraint of the form x+CouplingVar <= 1 */
2390 /* If the node is part of the maximum clique, it is safe to set it to one, so we simply add it to the graph */
2391 nodeindex0 = addVarToGraph(pricingprob, g, lconsvars[couplingcoefindices[i]], &indexcount, scalingfactor, indsetvars,
2392 linkmatrix, linkedvars, nlinkedvars, ncouplvars, aggrobjcoef);
2393
2394 /* We additionally have to mark the variable to later set it to one */
2395 if( solvals[SCIPvarGetProbindex(lconsvars[couplingcoefindices[i]])] < 0.0 )
2396 solvals[SCIPvarGetProbindex(lconsvars[couplingcoefindices[i]])] = -2.0;
2397 }
2398
2399 /*
2400 * If (coupling-)clique constraint, try to add all (non-coupling) variables corresponding nodes to the graph
2401 * if the objective coefficient is < 0 and remove edges between these nodes (if added).
2402 */
2403 if( cliquerconstypes[i] == LINEAR_CLIQUE || cliquerconstypes[i] == LINEAR_COUPLING_CLIQUE )
2404 {
2405 /* Delete the edges between all the variables of the constraint (that are not the coupling variable).
2406 This way, at most one can be part of the maximum clique */
2407 for( j = 0; j < nvars; ++j )
2408 {
2409 /* We are only interested in vars potentially relevant for pricing (obj < 0) */
2410 if((cliquerconstypes[i] != LINEAR_COUPLING_CLIQUE || j != couplingcoefindices[i]) &&
2411 SCIPisLT(pricingprob, getAggrObjCoef(lconsvars[j], nlinkedvars, ncouplvars, aggrobjcoef), 0) &&
2412 solvals[SCIPvarGetProbindex(lconsvars[j])] != 0.0 )
2413 {
2414 /* Determine nodeindex0 */
2415 nodeindex0 = addVarToGraph(pricingprob, g, lconsvars[j], &indexcount, scalingfactor, indsetvars, linkmatrix,
2416 linkedvars, nlinkedvars, ncouplvars, aggrobjcoef);
2417
2418 /* Determine nodeindex1 */
2419 for( k = j + 1; k < nvars; ++k )
2420 {
2421 if((cliquerconstypes[i] != LINEAR_COUPLING_CLIQUE || k != couplingcoefindices[i]) &&
2422 SCIPisLT(pricingprob, getAggrObjCoef(lconsvars[k], nlinkedvars, ncouplvars, aggrobjcoef), 0) &&
2423 solvals[SCIPvarGetProbindex(lconsvars[k])] != 0.0 )
2424 {
2425 nodeindex1 = addVarToGraph(pricingprob, g, lconsvars[k], &indexcount, scalingfactor, indsetvars, linkmatrix,
2426 linkedvars, nlinkedvars, ncouplvars, aggrobjcoef);
2427
2428 if( (nodeindex0 != nodeindex1) && GRAPH_IS_EDGE(g, nodeindex0, nodeindex1) )
2429 {
2430 GRAPH_DEL_EDGE(g, nodeindex0, nodeindex1);
2431 }
2432 }
2433 }
2434 }
2435 }
2436 }
2437 }
2438 }
2439 /* Constraint may be of type varbound: lhs <= x + c*y <= rhs */
2440 else if( strcmp(SCIPconshdlrGetName(conshdlr), "varbound") == 0 )
2441 {
2442 /* If all variables are fixed, constraint can be skipped */
2443 if( consvarsfixedcount[i] == 2 )
2444 continue;
2445
2446 vconsvars[0] = SCIPgetVarVarbound(pricingprob, constraints[i]);
2447 vconsvars[1] = SCIPgetVbdvarVarbound(pricingprob, constraints[i]);
2448
2449 /* Form: x <= d*y with d >= 1 */
2450 if( cliquerconstypes[i] == VARBND_STD )
2451 {
2452 /* If x fixed to 0 or y fixed to 1 (and other variable not fixed): constraint relaxed -> continue. */
2453 if( consvarsfixedcount[i] == 1 &&
2454 (solvals[SCIPvarGetProbindex(vconsvars[0])] == 0.0 || solvals[SCIPvarGetProbindex(vconsvars[1])] == 1.0) )
2455 continue;
2456
2457 /* if x may be relevant, add both x and y to graph */
2458 if( SCIPisLT(pricingprob, getAggrObjCoef(vconsvars[0], nlinkedvars, ncouplvars, aggrobjcoef), 0) )
2459 {
2460 nodeindex0 = addVarToGraph(pricingprob, g, vconsvars[0], &indexcount, scalingfactor, indsetvars, linkmatrix,
2461 linkedvars, nlinkedvars, ncouplvars, aggrobjcoef);
2462 nodeindex1 = addVarToGraph(pricingprob, g, vconsvars[1], &indexcount, scalingfactor, indsetvars, linkmatrix,
2463 linkedvars, nlinkedvars, ncouplvars, aggrobjcoef);
2464 /* It may be the case, that both the constraints x - y <= 0 and x + y <= 1 are part of the problem */
2465 /* Although rare, we later ensure that we do not set x to 1 while y is set to 0 */
2466 markedconsindices[markedcount] = i;
2467 ++markedcount;
2468 }
2469 /* If only y may be relevant, add only y to the graph */
2470 else if( SCIPisLT(pricingprob, getAggrObjCoef(vconsvars[1], nlinkedvars, ncouplvars, aggrobjcoef), 0) )
2471 {
2472 nodeindex1 = addVarToGraph(pricingprob, g, vconsvars[1], &indexcount, scalingfactor, indsetvars, linkmatrix,
2473 linkedvars, nlinkedvars, ncouplvars, aggrobjcoef);
2474 }
2475 /* If none of the nodes are relevant, force x to be zero, since the constraint would be violated if x = 1 and y = 0 */
2476 else
2477 {
2478 /* This logic might not always be correct. These vairables might be set to 1 in an optimal solution if, e.g.,
2479 * they appear as coupling variables in other constraints. Even if they are both not "relevant".
2480 */
2481 setLinkedSolvals(pricingprob, solvals, linkmatrix, linkedvars, nlinkedvars, vconsvars[0], 0.0);
2482 }
2483 }
2484
2485 /* Form: x + y <= 1 */
2486 if( cliquerconstypes[i] == VARBND_IS )
2487 {
2488 /* If x fixed to 0 or y fixed to 0 (and other variable unfixed): constraint relaxed -> continue. */
2489 if( consvarsfixedcount[i] == 1 && consvarsfixedtozerocount[i] == 1 )
2490 continue;
2491
2492 /* Preprocessing: Constraint is only relevant for pricing if one of the variables has an objective value < 0 */
2493 if( SCIPisLT(pricingprob, getAggrObjCoef(vconsvars[0], nlinkedvars, ncouplvars, aggrobjcoef), 0) ||
2494 SCIPisLT(pricingprob, getAggrObjCoef(vconsvars[1], nlinkedvars, ncouplvars, aggrobjcoef), 0) )
2495 {
2496 nodeindex0 = -1;
2497 if( SCIPisLT(pricingprob, getAggrObjCoef(vconsvars[0], nlinkedvars, ncouplvars, aggrobjcoef), 0) )
2498 nodeindex0 = addVarToGraph(pricingprob, g, vconsvars[0], &indexcount, scalingfactor, indsetvars, linkmatrix,
2499 linkedvars, nlinkedvars, ncouplvars, aggrobjcoef);
2500
2501 nodeindex1 = -1;
2502 if( SCIPisLT(pricingprob, getAggrObjCoef(vconsvars[1], nlinkedvars, ncouplvars, aggrobjcoef), 0) )
2503 nodeindex1 = addVarToGraph(pricingprob, g, vconsvars[1], &indexcount, scalingfactor, indsetvars, linkmatrix,
2504 linkedvars, nlinkedvars, ncouplvars, aggrobjcoef);
2505
2506 if( nodeindex0 >= 0 && nodeindex1 >= 0 && GRAPH_IS_EDGE(g, nodeindex0, nodeindex1) )
2507 {
2508 GRAPH_DEL_EDGE(g, nodeindex0, nodeindex1);
2509 }
2510 }
2511 }
2512 }
2513 }
2514
2515
2516 /* Assert that the graph was built in a proper way */
2517 assert(graph_test(g, NULL));
2518
2519 /* Determine number of edges for graph density calculation */
2520 nedges = 0;
2521 for( i = 0; i < g->n; i++ )
2522 {
2523 for( j = 0; j < g->n; j++ )
2524 {
2525 if( SET_CONTAINS_FAST(g->edges[i], j) )
2526 {
2527 nedges++;
2528 }
2529 }
2530 }
2531 nedges /= 2;
2532
2533 density = (SCIP_Real)nedges / ((SCIP_Real)(g->n - 1) * (g->n) / 2);
2534
2535 SCIPdebugMessage("Problem number: %i ; Tree depth: %i ; Graph size: %d ; Graph density: %g\n",
2536 probnr, SCIPgetDepth(GCGgetMasterprob(gcg)), indexcount, density);
2537
2538 /* Test if the node threshold is respected */
2539 if( SCIPisGT(pricingprob, indexcount, solver->maxnodes) )
2540 {
2541 SCIPdebugMessage("Exit: Node threshold exceeded, number of nodes: %i.\n", indexcount);
2543 goto TERMINATE;
2544 }
2545
2546 /* Only apply density / linear cutoff if limit is exceeded. */
2547 if( SCIPisGT(pricingprob, indexcount, solver->skipchecksnodelimit) )
2548 {
2549 /* Test if the density criteria is met */
2550 if( SCIPisGT(pricingprob, density, solver->maxdensity) )
2551 {
2552 SCIPdebugMessage("Exit: Density criteria not met, density: %g.\n", density);
2554 goto TERMINATE;
2555 }
2556
2557 /* Next, check if linear cutoff is activated, If yes, check if linear cutoff equation is met.
2558 * If (n)odes and (d)ensity have values n > m*d + b (with slope m and intercept b), solver is not applied.
2559 * Default values currently are: m = -1980, b = 1900
2560 */
2561 if( solver->uselincutoff &&
2562 SCIPisGT(pricingprob, indexcount, solver->lincutoffslope * density + solver->lincutoffintercept) )
2563 {
2564 SCIPdebugMessage("Exit: Linear threshold n <= m*d + b exceeded (i.e.: %i > %.1f * %.2f + %.1f).\n",
2565 indexcount, solver->lincutoffslope, density, solver->lincutoffintercept);
2567 goto TERMINATE;
2568 }
2569 }
2570
2571 ASSERT( indexcount <= npricingprobvars );
2572
2573 /* indexcount now holds the actual number of unique IS variables, thus we truncate the graph */
2574 if( indexcount > 0 )
2575 {
2576 graph_resize(g, indexcount);
2577 }
2578
2579 /* Clean up the graph. If a variable's solval has been set to 0, it should not be part of the max clique */
2580 /* We enforce this by isolating the node and setting its weight to 1 as nodes cannot be deleted */
2581 for( i = 0; i < npricingprobvars; ++i )
2582 {
2583 if( solvals[SCIPvarGetProbindex(pricingprobvars[i])] == 0 )
2584 {
2585 nodeindex0 = getLinkedNodeIndex(pricingprob, pricingprobvars[i], indsetvars, indexcount, linkmatrix, linkedvars, nlinkedvars);
2586 /* The var is part of the graph if its index is unequal to -1 */
2587 if( nodeindex0 != -1 )
2588 {
2589 for( j = 0; j < indexcount; ++j )
2590 {
2591 if( GRAPH_IS_EDGE(g, nodeindex0, j) )
2592 {
2593 GRAPH_DEL_EDGE(g, nodeindex0, j);
2594 }
2595 }
2596 g->weights[nodeindex0] = 1;
2597 }
2598 }
2599 }
2600
2601 /* Set cliquer options */
2602 cl_opts.reorder_function = reorder_by_default; /* default: reorder_by_default */
2603 cl_opts.reorder_map = NULL;
2604 cl_opts.time_function = NULL; /* default: clique_print_time */
2605 cl_opts.output = NULL;
2606 cl_opts.user_function = NULL;
2607 cl_opts.user_data = NULL;
2608 cl_opts.clique_list = NULL;
2609 cl_opts.clique_list_length = 0;
2610
2611 /* Find maximum weight clique using the cliquer library */
2612 clique = clique_find_single(g, 0, 0, FALSE, &cl_opts);
2613
2614 /* Set all members of the maximum clique with objective coefficient < 0 to 1 */
2615 for( i = 0; i < indexcount; ++i )
2616 {
2617 /* Coupling variables were pre-set to -2.0, if they are part of the maximum clique, we enable them.
2618 * If we have already set a variable to 0, this was intended and should not be reverted.
2619 *
2620 * NOTE: As long as coupling variables may have positive cost but have cost of 1 in graph, the solver is of heuristic nature.
2621 * The '-2.0'-marked coupling variables are set to 1, even if they render the solution be of non-negative reduced cost.
2622 * The max-weighted-clique solver would need to support also negative costs to heal this.
2623 */
2624 if( SET_CONTAINS(clique, i) &&
2625 (SCIPisLT(pricingprob, getAggrObjCoef(indsetvars[i], nlinkedvars, ncouplvars, aggrobjcoef), 0) ||
2626 solvals[SCIPvarGetProbindex(indsetvars[i])] == -2.0) &&
2627 solvals[SCIPvarGetProbindex(indsetvars[i])] != 0.0 )
2628 {
2629 /* Set all linked variables, if any */
2630 setLinkedSolvals(pricingprob, solvals, linkmatrix, linkedvars, nlinkedvars, indsetvars[i], 1.0);
2631 }
2632 else
2633 {
2634 /* We may have set some variables manually already, e.g. coupling variables */
2635 if( solvals[SCIPvarGetProbindex(indsetvars[i])] != 1.0)
2636 {
2637 setLinkedSolvals(pricingprob, solvals, linkmatrix, linkedvars, nlinkedvars, indsetvars[i], 0.0);
2638 }
2639 }
2640 }
2641
2642 for( i = 0; i < markedcount; ++i )
2643 {
2644 vconsvars[0] = SCIPgetVarVarbound(pricingprob, constraints[markedconsindices[i]]);
2645 vconsvars[1] = SCIPgetVbdvarVarbound(pricingprob, constraints[markedconsindices[i]]);
2646
2647 /* Handle the case of marked inequality constraints of type x - y <= 0 in combination with x + y <= 1 -Constraints */
2648 if( cliquerconstypes[markedconsindices[i]] == VARBND_STD )
2649 {
2650 /* Check if a violating assignment was made and correct it */
2651 if( (solvals[SCIPvarGetProbindex(vconsvars[0])] == 1) && (solvals[SCIPvarGetProbindex(vconsvars[1])] == 0) )
2652 {
2653 setLinkedSolvals(pricingprob, solvals, linkmatrix, linkedvars, nlinkedvars, vconsvars[0], 0.0);
2654 }
2655 }
2656
2657 /* Handle the case that there are still solvals of equality constraints that do not agree.
2658 * This may occur if one is unset (solval:-1) and the other one is already set (solval 0 or 1)
2659 */
2660 if( solvals[SCIPvarGetProbindex(vconsvars[0])] != solvals[SCIPvarGetProbindex(vconsvars[1])] &&
2661 cliquerconstypes[markedconsindices[i]] == VARBND_SAME )
2662 {
2663 if( solvals[SCIPvarGetProbindex(vconsvars[0])] == 0 || solvals[SCIPvarGetProbindex(vconsvars[1])] == 0 )
2664 {
2665 setLinkedSolvals(pricingprob, solvals, linkmatrix, linkedvars, nlinkedvars, vconsvars[0], 0.0);
2666 }
2667 else
2668 {
2669 /* One or both of the vars are unset and the other one, if not -1, is forced to be 1, thus we can set both to 1 */
2670 setLinkedSolvals(pricingprob, solvals, linkmatrix, linkedvars, nlinkedvars, vconsvars[0], 1.0);
2671 }
2672 }
2673 }
2674
2675 /* There may be variables left which are unconstrained. We set these to 1 manually if they have an objective value < 0*/
2676 for( i = 0; i < npricingprobvars; ++i )
2677 {
2678 if( solvals[i] == -1.0 )
2679 {
2680 if( SCIPisLT(pricingprob, getAggrObjCoef(pricingprobvars[i], nlinkedvars, ncouplvars, aggrobjcoef), 0) )
2681 {
2682 solvals[i] = 1.0;
2683 }
2684 else
2685 {
2686 solvals[i] = 0.0;
2687 }
2688 }
2689 }
2690
2691 /* Create a column corresponding to our clique result */
2692 CREATECOLUMN:
2693 SCIP_CALL( GCGcreateGcgCol(gcg, pricingprob, &col, probnr, pricingprobvars, solvals, npricingprobvars, FALSE, SCIPinfinity(pricingprob)) );
2694 SCIP_CALL( GCGpricerAddCol(gcg, col) );
2695 *status = GCG_PRICINGSTATUS_UNKNOWN;
2696 if( indexcount > 0 )
2697 set_free(clique); /* clique can only be freed if non-empty */
2698
2699 TERMINATE:
2700 if( ismemgraphallocated )
2701 {
2702 SCIPfreeBufferArray(pricingprob, &indsetvars);
2703 SCIPfreeBufferArray(pricingprob, &consvarsfixedtozerocount);
2704 SCIPfreeBufferArray(pricingprob, &aggrobjcoef);
2705 }
2706 SCIPfreeBufferArray(pricingprob, &couplvars);
2707 for( i = 0; i < npricingprobvars; ++i )
2708 {
2709 SCIPfreeBufferArray(pricingprob, &couplingmatrix[i]);
2710 }
2711 SCIPfreeBufferArray(pricingprob, &couplingmatrix);
2712 SCIPfreeBufferArray(pricingprob, &vconsvars);
2713 SCIPfreeBufferArray(pricingprob, &consvarsfixedcount);
2714 SCIPfreeBufferArray(pricingprob, &couplingcoefindices);
2715 for( i = 0; i < npricingprobvars; ++i )
2716 {
2717 SCIPfreeBufferArray(pricingprob, &linkmatrix[i]);
2718 }
2719 SCIPfreeBufferArray(pricingprob, &linkmatrix);
2720 SCIPfreeBufferArray(pricingprob, &linkedvars);
2721 SCIPfreeBufferArray(pricingprob, &solvals);
2722 SCIPfreeBufferArray(pricingprob, &markedconsindices);
2723 SCIPfreeBufferArray(pricingprob, &cliquerconstypes);
2724 graph_free(g);
2725
2726 return SCIP_OKAY;
2727}
2728
2729/*
2730 * Callback methods for pricing problem solver
2731 */
2732
2733/** destructor of pricing solver to free user data (called when SCIP is exiting) */
2734static
2735GCG_DECL_SOLVERFREE(solverFreeCliquer)
2736{
2737 GCG_SOLVERDATA* solverdata;
2738
2739 assert(gcg != NULL);
2740 assert(solver != NULL);
2741
2742 solverdata = GCGsolverGetData(solver);
2743 assert(solverdata != NULL);
2744
2745 SCIPfreeMemory(GCGgetDwMasterprob(gcg), &solverdata);
2746
2747 GCGsolverSetData(solver, NULL);
2748
2749 return SCIP_OKAY;
2750}
2751
2752/** solving process initialization method of pricing solver (called when branch and bound process is about to begin) */
2753static
2754GCG_DECL_SOLVERINITSOL(solverInitsolCliquer)
2755{
2757 GCG_SOLVERDATA* solverdata;
2758 int npricingprobs;
2759
2760 assert(gcg != NULL);
2761 assert(solver != NULL);
2762
2765
2766 // Solver can only be applied in case of Dantzig-Wolfe master problem.
2768
2769 solverdata = GCGsolverGetData(solver);
2770 assert(solverdata != NULL);
2771
2772 /* allocate and initialize isnotapplicable array */
2773 npricingprobs = GCGgetNPricingprobs(gcg);
2774 SCIP_CALL( SCIPallocClearBlockMemoryArray(masterprob, &solverdata->isnotapplicable, npricingprobs) );
2775
2776 return SCIP_OKAY;
2777}
2778
2779/** solving process deinitialization method of pricing solver (called before branch and bound process data is freed) */
2780static
2781GCG_DECL_SOLVEREXITSOL(solverExitsolCliquer)
2782{
2784 GCG_SOLVERDATA* solverdata;
2785 int npricingprobs;
2786
2787 assert(gcg != NULL);
2788 assert(solver != NULL);
2789
2792
2793 solverdata = GCGsolverGetData(solver);
2794 assert(solverdata != NULL);
2795
2796 /* free isnotapplicable array */
2797 npricingprobs = GCGgetNPricingprobs(gcg);
2798 SCIPfreeBlockMemoryArray(masterprob, &solverdata->isnotapplicable, npricingprobs);
2799
2800 return SCIP_OKAY;
2801}
2802
2803#define solverInitCliquer NULL
2804#define solverExitCliquer NULL
2805#define solverUpdateCliquer NULL
2806#define solverSolveCliquer NULL
2807
2808/** heuristic solving method of independent set solver */
2809static
2810GCG_DECL_SOLVERSOLVEHEUR(solverSolveHeurCliquer)
2811{ /*lint --e{715}*/
2812 GCG_SOLVERDATA* solverdata;
2813
2814 solverdata = GCGsolverGetData(solver);
2815 assert(solverdata != NULL);
2816
2817 /* solve the independent set problem approximately */
2818 SCIP_CALL( solveCliquer(FALSE, gcg, pricingprob, solverdata, probnr, lowerbound, status) );
2819
2820 return SCIP_OKAY;
2821}
2822
2823/** creates the cliquer solver for pricing problems and includes it in GCG */
2825 GCG* gcg /**< GCG data structure */
2826 )
2827{
2828 GCG_SOLVERDATA* solverdata;
2829 SCIP* origprob;
2830
2832
2834
2837 solverUpdateCliquer, solverSolveCliquer, solverSolveHeurCliquer,
2838 solverFreeCliquer, solverInitCliquer, solverExitCliquer,
2839 solverInitsolCliquer, solverExitsolCliquer, solverdata) );
2840
2841 SCIP_CALL( SCIPaddRealParam(origprob, "pricingsolver/cliquer/maxdensity",
2842 "maximum graph density the solver should run on",
2843 &solverdata->maxdensity, TRUE, DEFAULT_MAXDENSITY, 0.0, 1.0, NULL, NULL) );
2844
2845 SCIP_CALL( SCIPaddIntParam(origprob, "pricingsolver/cliquer/skipchecksnodelimit",
2846 "maximum number of graph nodes for which additional checks (density threshold / linear cutoff) are skipped",
2847 &solverdata->skipchecksnodelimit, TRUE, DEFAULT_SKIPCHECKSNODELIMIT, 0, INT_MAX, NULL, NULL) );
2848
2849 SCIP_CALL( SCIPaddRealParam(origprob, "pricingsolver/cliquer/maxcliqueconsperc",
2850 "maximum percentage share of clique constraints the solver should run on (disabled = 1.0)",
2851 &solverdata->maxcliqueconsperc, TRUE, DEFAULT_MAXCLIQUECONSPERC, 0.0, 1.0, NULL, NULL) );
2852
2853 SCIP_CALL( SCIPaddIntParam(origprob, "pricingsolver/cliquer/maxnodes",
2854 "maximum number of graph nodes the solver should run on",
2855 &solverdata->maxnodes, TRUE, DEFAULT_MAXNODES, 0, INT_MAX, NULL, NULL) );
2856
2857 SCIP_CALL( SCIPaddIntParam(origprob, "pricingsolver/cliquer/objcoefdistr",
2858 "distribution of objective coefficients of coupling variables (disabled = 0, natural share = 1, "
2859 "MIS-based = 2, uniform = 3)",
2860 &solverdata->objcoefdistr, TRUE, DEFAULT_OBJCOEFDISTR, 0, 3, NULL, NULL) );
2861
2862 SCIP_CALL( SCIPaddBoolParam(origprob, "pricingsolver/cliquer/usemultiplicity",
2863 "should the usage of multiplicity of linked variables be used to weight distributed coefficients be enabled? "
2864 "(only useful with objcoefdistr != 0)",
2865 &solverdata->usemultiplicity, TRUE, DEFAULT_USEMULTIPL, NULL, NULL) );
2866
2867 SCIP_CALL( SCIPaddBoolParam(origprob, "pricingsolver/cliquer/lincutoff/enable",
2868 "should linear cutoff (n > m*d + b) for usage of solver <cliquer>, based on graph (d)ensity and (n)odes, "
2869 "be enabled?",
2870 &solverdata->uselincutoff, FALSE, DEFAULT_USELINCUTOFF, NULL, NULL) );
2871
2872 SCIP_CALL( SCIPaddRealParam(origprob, "pricingsolver/cliquer/lincutoff/slope",
2873 "slope m in the linear cutoff formula (n > m*d + b), with (d)ensity and (n)odes",
2875
2876 SCIP_CALL( SCIPaddRealParam(origprob, "pricingsolver/cliquer/lincutoff/intercept",
2877 "intercept b in the linear cutoff formula (n > m*d + b), with (d)ensity and (n)odes",
2879
2880 SCIP_CALL( SCIPincludeExternalCodeInformation(origprob, "Cliquer", "C routines for finding cliques in an arbitrary weighted graph by S. Niskanen and P. Ostergard (https://users.aalto.fi/~pat/cliquer.html)") );
2881
2882 return SCIP_OKAY;
2883}
#define INLINE
#define SCIP_REAL_MAX
#define SCIP_Bool
#define SCIP_Real
#define SCIP_CALL_ABORT(x)
#define SCIP_REAL_MIN
#define TRUE
#define FALSE
GCG interface methods.
SCIP_Real SCIPgetVbdcoefVarbound(SCIP *scip, SCIP_CONS *cons)
SCIP_Real SCIPgetRhsLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_VAR ** SCIPgetVarsLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_Real SCIPgetLhsLinear(SCIP *scip, SCIP_CONS *cons)
int SCIPgetNVarsLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_Real * SCIPgetValsLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_VAR * SCIPgetVbdvarVarbound(SCIP *scip, SCIP_CONS *cons)
SCIP_VAR * SCIPgetVarVarbound(SCIP *scip, SCIP_CONS *cons)
SCIP_Real SCIPgetLhsVarbound(SCIP *scip, SCIP_CONS *cons)
SCIP_Real SCIPgetRhsVarbound(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE GCGpricerAddCol(GCG *gcg, GCG_COL *col)
SCIP_RETCODE GCGcreateGcgCol(GCG *gcg, SCIP *pricingprob, GCG_COL **gcgcol, int probnr, SCIP_VAR **vars, SCIP_Real *vals, int nvars, SCIP_Bool isray, SCIP_Real redcost)
Definition gcgcol.c:53
SCIP * GCGgetDwMasterprob(GCG *gcg)
Definition gcg.cpp:123
SCIP * GCGgetOrigprob(GCG *gcg)
Definition gcg.cpp:87
GCG_EXPORT int GCGgetNPricingprobs(GCG *gcg)
Definition relax_gcg.c:4113
SCIP * GCGgetMasterprob(GCG *gcg)
Definition gcg.cpp:99
SCIP_CONS ** SCIPgetConss(SCIP *scip)
int SCIPgetNVars(SCIP *scip)
int SCIPgetNConss(SCIP *scip)
SCIP_VAR ** SCIPgetVars(SCIP *scip)
int SCIPgetNBinVars(SCIP *scip)
void SCIPhashmapFree(SCIP_HASHMAP **hashmap)
int SCIPhashmapGetImageInt(SCIP_HASHMAP *hashmap, void *origin)
SCIP_RETCODE SCIPhashmapCreate(SCIP_HASHMAP **hashmap, BMS_BLKMEM *blkmem, int mapsize)
SCIP_RETCODE SCIPhashmapSetImageInt(SCIP_HASHMAP *hashmap, void *origin, int image)
SCIP_Bool GCGisRootNode(GCG *gcg)
Definition scip_misc.c:918
GCG_EXPORT GCG_SOLVERDATA * GCGsolverGetData(GCG_SOLVER *solver)
Definition solver.c:400
GCG_EXPORT void GCGsolverSetData(GCG_SOLVER *solver, GCG_SOLVERDATA *solverdata)
Definition solver.c:410
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 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)
const char * SCIPconshdlrGetName(SCIP_CONSHDLR *conshdlr)
SCIP_RETCODE SCIPgetConsNVars(SCIP *scip, SCIP_CONS *cons, int *nvars, SCIP_Bool *success)
SCIP_CONSHDLR * SCIPconsGetHdlr(SCIP_CONS *cons)
SCIP_RETCODE SCIPincludeExternalCodeInformation(SCIP *scip, const char *name, const char *description)
#define SCIPallocCleanBufferArray(scip, ptr, num)
#define SCIPfreeBlockMemoryArray(scip, ptr, num)
BMS_BLKMEM * SCIPblkmem(SCIP *scip)
#define SCIPallocClearBlockMemoryArray(scip, ptr, num)
#define SCIPallocClearBufferArray(scip, ptr, num)
#define SCIPallocBufferArray(scip, ptr, num)
#define SCIPallocMemory(scip, ptr)
int SCIPgetNCutsApplied(SCIP *scip)
SCIP_Real SCIPinfinity(SCIP *scip)
SCIP_Bool SCIPisGE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisLE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisGT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisZero(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisLT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
int SCIPgetDepth(SCIP *scip)
SCIP_Real SCIPvarGetUbLocal(SCIP_VAR *var)
SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
int SCIPvarGetProbindex(SCIP_VAR *var)
SCIP_Real SCIPvarGetLbLocal(SCIP_VAR *var)
SCIPfreeMemory(GCGgetOrigprob(gcg), &divingdata)
static assert(heur !=NULL)
SCIP_CALL(SCIPgetExternBranchCands(origprob, &lpcands, &lpcandssol, NULL, &nlpcands, NULL, NULL, NULL, NULL))
SCIP * origprob
#define DEFAULT_MAXNODES
SCIP_VAR * var
SCIP_VAR ** vars
int j
SCIP_Real scalingfactor
SCIP_Real frac
SCIPdebugMessage("feasibility pump finished [%d iterations done].\n", nloops)
SCIP_RETCODE retcode
int i
int nvars
SCIPfreeBufferArray(scip, &cycles)
int maxdepth
SCIP_Real objval
#define NULL
INLINE Rational & abs(Rational &r)
INLINE SCIP_Longint denominator(Rational &r)
SCIP_RETCODE GCGpricerIncludeSolver(GCG *gcg, const char *name, const char *desc, int priority, SCIP_Bool heurenabled, SCIP_Bool exactenabled, GCG_DECL_SOLVERUPDATE((*solverupdate)), GCG_DECL_SOLVERSOLVE((*solversolve)), GCG_DECL_SOLVERSOLVEHEUR((*solversolveheur)), GCG_DECL_SOLVERFREE((*solverfree)), GCG_DECL_SOLVERINIT((*solverinit)), GCG_DECL_SOLVEREXIT((*solverexit)), GCG_DECL_SOLVERINITSOL((*solverinitsol)), GCG_DECL_SOLVEREXITSOL((*solverexitsol)), GCG_SOLVERDATA *solverdata)
GCG variable pricer.
public methods for working with gcg columns
public methods for GCG variables
GCG relaxator.
various SCIP helper methods
static INLINE void objCoefDistrHeurUniform(SCIP *scip, int actvarind, int **couplingmatrix, SCIP_VAR **varsincouplings, int nvarsincouplings, int *varmultiplicities, SCIP_Bool usemultipl, SCIP_VAR **linkedvars, int nlinkedvars, int **linkmatrix, SCIP_Real *aggrobjcoef)
static INLINE int countReachableVars(SCIP *scip, int **linkmatrix, SCIP_VAR *var, SCIP_VAR **linkedvars, int nlinkedvars)
#define DEFAULT_MAXDENSITY
static void setLinkedSolvals(SCIP *scip, SCIP_Real *solvals, int **linkmatrix, SCIP_VAR **linkedvars, int nlinkedvars, SCIP_VAR *var, SCIP_Real val)
static SCIP_RETCODE solveCliquer(SCIP_Bool exactly, GCG *gcg, SCIP *pricingprob, GCG_SOLVERDATA *solver, int probnr, SCIP_Real *lowerbound, GCG_PRICINGSTATUS *status)
#define DEFAULT_MAXCLIQUECONSPERC
static void aggregateObjCoef(SCIP *scip, int **linkmatrix, SCIP_VAR **linkedvars, int nlinkedvars, SCIP_Real *aggrobjcoef)
#define DEFAULT_SKIPCHECKSNODELIMIT
static INLINE int getNodeIndexCouplDigraph(SCIP *scip, SCIP_VAR *var, int **linkmatrix, SCIP_VAR **linkedvars, int nlinkedvars, SCIP_VAR **varsincouplings, int nvarsincouplings)
enum cliquerConsType CLIQUER_CONSTYPE
#define solverExitCliquer
#define solverUpdateCliquer
static INLINE SCIP_Real getAggrObjCoef(SCIP_VAR *var, int nlinkedvars, int nvarsincouplings, SCIP_Real *aggrobjcoef)
static INLINE int getNSuccessorsRelevant(SCIP *scip, int varind, int **couplingmatrix, SCIP_VAR **varsincouplings, int nvarsincouplings, int nlinkedvars, SCIP_Real *aggrobjcoef, int *varmultiplicities, SCIP_Bool usemultiplicities)
static void distributeObjCoefRec(SCIP *scip, int actvarind, SCIP_Bool *isdistributed, int **couplingmatrix, SCIP_VAR **varsincouplings, int nvarsincouplings, int *varmultiplicities, SCIP_Bool usemultipl, SCIP_VAR **linkedvars, int nlinkedvars, int **linkmatrix, SCIP_Real *aggrobjcoef, SCIP_CONS **constraints, int nconss, int *couplingcoefindices, CLIQUER_CONSTYPE *cliquerconstypes, int selecteddistrheur)
static void setProblemNotApplicable(GCG *gcg, int probnr, SCIP_Bool *isnotapplicable)
static SCIP_Bool isCouplingRelevantRec(SCIP *scip, int varind, int **couplingmatrix, SCIP_VAR **varsincouplings, int nvarsincouplings, int nlinkedvars, SCIP_Real *aggrobjcoef, int maxdepth)
static INLINE SCIP_Bool hasSuccessorRel(SCIP *scip, int varind, int **couplingmatrix, SCIP_VAR **varsincouplings, int nvarsincouplings, int nlinkedvars, SCIP_Real *aggrobjcoef)
static INLINE int assureInCouplingGraph(SCIP *scip, SCIP_VAR **varsincouplings, int *nvarsincouplings, SCIP_VAR *var, SCIP_VAR **linkedvars, int nlinkedvars, int **linkmatrix)
static SCIP_Bool areVarsLinkedRec(int **linkmatrix, int vindex1, int vindex2, int *vartrace, int *traceindex, SCIP_VAR **linkedvars, int nlinkedvars)
#define solverInitCliquer
static int addVarToGraph(SCIP *scip, graph_t *g, SCIP_VAR *consvar, int *indexcount, SCIP_Real scalingfactor, SCIP_VAR **indsetvars, int **linkmatrix, SCIP_VAR **linkedvars, int nlinkedvars, int nvarsincouplings, SCIP_Real *aggrobjcoef)
static SCIP_Bool propagateVariablefixings(SCIP *pricingprob, SCIP_CONS **constraints, SCIP_VAR **linkedvars, SCIP_VAR **vconsvars, SCIP_VAR **varsincouplings, SCIP_Real *solvals, int **couplingmatrix, int **linkmatrix, int *nvarsincouplings, int *couplingcoefindices, int *consvarsfixedcount, int nlinkedvars, int nconss, int *nfixedvars, CLIQUER_CONSTYPE *cliquerconstypes)
static INLINE void initVarMultiplicities(SCIP *scip, int **linkmatrix, SCIP_VAR **linkedvars, int nlinkedvars, int **couplingmatrix, SCIP_VAR **varsincouplings, int nvarsincouplings, int *varmultiplicities)
#define DEFAULT_OBJCOEFDISTR
static int getLinkedNodeIndex(SCIP *scip, SCIP_VAR *var, SCIP_VAR **indsetvars, int indexcount, int **linkmatrix, SCIP_VAR **linkedvars, int nlinkedvars)
static INLINE int getNodeIndex(SCIP_VAR *var, SCIP_VAR **vararray, int indexcount)
static void distributeObjCoef(SCIP *scip, SCIP_CONS **constraints, int nconss, int *couplingcoefindices, CLIQUER_CONSTYPE *cliquerconstypes, int **couplingmatrix, SCIP_VAR **varsincouplings, int nvarsincouplings, SCIP_VAR **linkedvars, int nlinkedvars, int **linkmatrix, SCIP_Real *aggrobjcoef, int selecteddistrheur, SCIP_Bool usemultipl)
#define SOLVER_HEURENABLED
static INLINE SCIP_Bool isCouplingRelevantVar(SCIP *scip, SCIP_VAR *var, int **couplingmatrix, SCIP_VAR **varsincouplings, int nvarsincouplings, int **linkmatrix, SCIP_VAR **linkedvars, int nlinkedvars, SCIP_Real *aggrobjcoef)
static INLINE void objCoefDistrHeurIS(SCIP *scip, int actvarind, int **couplingmatrix, SCIP_VAR **varsincouplings, int nvarsincouplings, int *varmultiplicities, SCIP_Bool usemultipl, SCIP_VAR **linkedvars, int nlinkedvars, int **linkmatrix, SCIP_Real *aggrobjcoef, SCIP_CONS **constraints, int nconss, int *couplingcoefindices, CLIQUER_CONSTYPE *cliquerconstypes)
#define DEFAULT_INTERCEPT
static SCIP_Bool areObjectivesIntegral(SCIP *scip, SCIP_VAR **linkedvars, int nlinkedvars, SCIP_VAR **varsincouplings, int nvarsincouplings, SCIP_Real *aggrobjcoef)
static INLINE void updateCouplingDiGraph(SCIP *scip, SCIP_VAR **consvars, int nconsvars, SCIP_VAR *var, int **couplingmatrix, SCIP_VAR **varsincouplings, int *nvarsincouplings, SCIP_VAR **linkedvars, int nlinkedvars, int **linkmatrix)
#define solverSolveCliquer
static INLINE void objCoefDistrHeurNatural(SCIP *scip, int actvarind, int **couplingmatrix, SCIP_VAR **varsincouplings, int nvarsincouplings, int *varmultiplicities, SCIP_Bool usemultipl, SCIP_VAR **linkedvars, int nlinkedvars, int **linkmatrix, SCIP_Real *aggrobjcoef, SCIP_CONS **constraints, int nconss, int *couplingcoefindices, CLIQUER_CONSTYPE *cliquerconstypes)
#define DEFAULT_USEMULTIPL
#define SOLVER_EXACTENABLED
#define DEFAULT_USELINCUTOFF
static INLINE void setAggrObjCoef(SCIP *scip, SCIP_VAR *var, SCIP_Real value, SCIP_VAR **linkedvars, int nlinkedvars, int **linkmatrix, SCIP_Real *aggrobjcoef)
static void updateVarLinks(SCIP *scip, int **linkmatrix, SCIP_VAR *var1, SCIP_VAR *var2, SCIP_VAR **linkedvars, int *nlinkedvars)
static INLINE SCIP_Bool isVarLinked(SCIP_VAR **linkedvars, int nlinkedvars, SCIP_VAR *var)
#define DEFAULT_SLOPE
SCIP_RETCODE GCGincludeSolverCliquer(GCG *gcg)
static INLINE SCIP_VAR * getLinkedNodeVar(SCIP *scip, SCIP_VAR *var, int **linkmatrix, SCIP_VAR **linkedvars, int nlinkedvars)
#define SOLVER_NAME
static SCIP_Bool determineCliquerConsTypes(SCIP *pricingprob, SCIP_CONS **constraints, SCIP_VAR **linkedvars, SCIP_VAR **vconsvars, int *markedconsindices, int **linkmatrix, int *couplingcoefindices, int *nlinkedvars, int nconss, int *markedcount, CLIQUER_CONSTYPE *cliquerconstypes)
static INLINE SCIP_Bool isCouplingRelevant(SCIP *scip, int varind, int **couplingmatrix, SCIP_VAR **varsincouplings, int nvarsincouplings, int nlinkedvars, SCIP_Real *aggrobjcoef)
#define SOLVER_DESC
static SCIP_Bool areVarsLinked(SCIP *scip, int **linkmatrix, SCIP_VAR *var1, SCIP_VAR *var2, SCIP_VAR **linkedvars, int nlinkedvars)
cliquerConsType
@ VARBND_IS
@ VARBND_STD
@ LINEAR_COUPLING_CLIQUE
@ LINEAR_IS_LIKE
@ LINEAR_COUPLING_DECORATIVE
@ LINEAR_IS
@ LINEAR_CLIQUE
@ VARBND_SAME
#define SOLVER_PRIORITY
static SCIP_Real scaleRelativeToMax(SCIP *scip, SCIP_VAR **linkedvars, int nlinkedvars, SCIP_VAR **varsincouplings, int nvarsincouplings, SCIP_Real *aggrobjcoef)
heuristic solver for pricing problems that solves independent set problems with cliquer
SCIP_Real lincutoffintercept
SCIP_Real lincutoffslope
SCIP_Bool usemultiplicity
SCIP_Bool * isnotapplicable
SCIP_Bool uselincutoff
SCIP_Real maxcliqueconsperc
SCIP_Real maxdensity
struct SCIP_Cons SCIP_CONS
struct SCIP_Conshdlr SCIP_CONSHDLR
struct Gcg GCG
Definition type_gcg.h:44
struct GCG_Col GCG_COL
Definition type_gcgcol.h:44
struct SCIP_HashMap SCIP_HASHMAP
enum GCG_PricingStatus GCG_PRICINGSTATUS
@ GCG_PRICINGSTATUS_NOTAPPLICABLE
@ GCG_PRICINGSTATUS_INFEASIBLE
@ GCG_PRICINGSTATUS_UNKNOWN
enum SCIP_Retcode SCIP_RETCODE
struct Scip SCIP
#define GCG_DECL_SOLVERFREE(x)
Definition type_solver.h:60
#define GCG_DECL_SOLVEREXITSOL(x)
Definition type_solver.h:98
#define GCG_DECL_SOLVERINITSOL(x)
Definition type_solver.h:87
#define GCG_DECL_SOLVERSOLVEHEUR(x)
struct GCG_SolverData GCG_SOLVERDATA
Definition type_solver.h:50
struct SCIP_Var SCIP_VAR