Scippy

SCIP

Solving Constraint Integer Programs

heur_clique.c
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the program and library */
4 /* SCIP --- Solving Constraint Integer Programs */
5 /* */
6 /* Copyright (C) 2002-2018 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SCIP is distributed under the terms of the ZIB Academic License. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SCIP; see the file COPYING. If not email to scip@zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file heur_clique.c
17  * @brief LNS heuristic using a clique partition to restrict the search neighborhood
18  * @brief clique primal heuristic
19  * @author Stefan Heinz
20  * @author Michael Winkler
21  * @author Gerald Gamrath
22  *
23  * @todo allow smaller fixing rate for probing LP?
24  * @todo allow smaller fixing rate after presolve if total number of variables is small (<= 1000)?
25  *
26  * More details about the heuristic can be found in@n
27  * Structure-Based Primal Heuristics for Mixed Integer Programming@n
28  * Gerald Gamrath, Timo Berthold, Stefan Heinz, and Michael Winkler@n
29  * Optimization in the Real World, Volume 13 of the series Mathematics for Industry, pp 37-53@n
30  * Preliminary version available as <a href="https://opus4.kobv.de/opus4-zib/frontdoor/index/index/docId/5551">ZIB-Report 15-26</a>.
31  */
32 
33 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
34 
35 #include <assert.h>
36 #include <string.h>
37 
38 #include "scip/scip.h"
39 #include "scip/pub_implics.h"
40 #include "scip/heur_clique.h"
41 #include "scip/heur_locks.h"
42 #include "scip/cons_logicor.h"
43 #include "scip/pub_misc.h"
44 
45 
46 #define HEUR_NAME "clique"
47 #define HEUR_DESC "LNS heuristic using a clique partition to restrict the search neighborhood"
48 #define HEUR_DISPCHAR 'Q'
49 #define HEUR_PRIORITY 5000
50 #define HEUR_FREQ 0
51 #define HEUR_FREQOFS 0
52 #define HEUR_MAXDEPTH -1
53 #define HEUR_TIMING SCIP_HEURTIMING_BEFORENODE
54 #define HEUR_USESSUBSCIP TRUE /**< does the heuristic use a secondary SCIP instance? */
55 
56 #define DEFAULT_MAXNODES 5000LL /**< maximum number of nodes to regard in the subproblem */
57 #define DEFAULT_MININTFIXINGRATE 0.65 /**< minimum percentage of integer variables that have to be fixed */
58 #define DEFAULT_MINMIPFIXINGRATE 0.65 /**< minimum percentage of variables that have to be fixed within sub-SCIP
59  * (integer and continuous) */
60 #define DEFAULT_MINIMPROVE 0.01 /**< factor by which clique heuristic should at least improve the
61  * incumbent
62  */
63 #define DEFAULT_MINNODES 500LL /**< minimum number of nodes to regard in the subproblem */
64 #define DEFAULT_NODESOFS 500LL /**< number of nodes added to the contingent of the total nodes */
65 #define DEFAULT_NODESQUOT 0.1 /**< subproblem nodes in relation to nodes of the original problem */
66 #define DEFAULT_MAXPROPROUNDS 2 /**< maximum number of propagation rounds during probing */
67 #define DEFAULT_MAXBACKTRACKS 10 /**< maximum number of backtracks during the fixing process */
68 #define DEFAULT_COPYCUTS TRUE /**< should all active cuts from the cutpool of the
69  * original scip be copied to constraints of the subscip
70  */
71 #define DEFAULT_USELOCKFIXINGS FALSE /**< should more variables be fixed based on variable locks if
72  * the fixing rate was not reached?
73  */
74 
75 
76 /*
77  * Data structures
78  */
79 
80 /** primal heuristic data */
81 struct SCIP_HeurData
82 {
83  SCIP_Longint maxnodes; /**< maximum number of nodes to regard in the subproblem */
84  SCIP_Longint minnodes; /**< minimum number of nodes to regard in the subproblem */
85  SCIP_Longint nodesofs; /**< number of nodes added to the contingent of the total nodes */
86  SCIP_Longint usednodes; /**< nodes already used by clique heuristic in earlier calls */
87  SCIP_Real minintfixingrate; /**< minimum percentage of integer variables that have to be fixed */
88  SCIP_Real minmipfixingrate; /**< minimum percentage of variables that have to be fixed within sub-SCIP
89  * (integer and continuous) */
90  SCIP_Real minimprove; /**< factor by which clique heuristic should at least improve the incumbent */
91  SCIP_Real nodesquot; /**< subproblem nodes in relation to nodes of the original problem */
92  int maxproprounds; /**< maximum number of propagation rounds during probing */
93  int maxbacktracks; /**< maximum number of backtracks during the fixing process */
94  SCIP_Bool copycuts; /**< should all active cuts from cutpool be copied to constraints in
95  * subproblem?
96  */
97  SCIP_Bool uselockfixings; /**< should more variables be fixed based on variable locks if
98  * the fixing rate was not reached?
99  */
100 };
101 
102 /*
103  * Local methods
104  */
105 
106 /** comparison method for sorting cliques by their size */
107 static
108 SCIP_DECL_SORTINDCOMP(compCliquesSize)
109 {
110  int* cliquesizes = (int*)dataptr;
111 
112  return cliquesizes[ind2] - cliquesizes[ind1];
113 }
114 
115 static
117  SCIP_CLIQUE* clique
118  )
119 {
120  SCIP_VAR** cliquevars;
121  SCIP_VAR* var;
122  int ncliquevars;
123  int nunfixed = 0;
124  int v;
125 
126  ncliquevars = SCIPcliqueGetNVars(clique);
127  cliquevars = SCIPcliqueGetVars(clique);
128 
129  for( v = 0; v < ncliquevars; ++v )
130  {
131  var = cliquevars[v];
132 
133  /* is variable unfixed? */
134  if( SCIPvarGetUbLocal(var) > SCIPvarGetLbLocal(var) + 0.5 )
135  ++nunfixed;
136  }
137 
138  return nunfixed;
139 }
140 
141 /** apply clique fixing using probing */
142 static
144  SCIP* scip, /**< original SCIP data structure */
145  SCIP_HEURDATA* heurdata, /**< structure containing heurdata */
146  SCIP_VAR** onefixvars, /**< array to store all variables which are fixed to one in the cliques */
147  SCIP_Shortbool* onefixvals, /**< array to store the values of all variables fixed to one in the cliques */
148  int* nonefixvars, /**< pointer to store the number of variables fixed to one */
149  SCIP_Bool* cutoff /**< pointer to store whether the propagation stopped with infeasibility */
150  )
151 {
152  SCIP_CLIQUE** cliques;
153  SCIP_CLIQUE* clique;
154  SCIP_VAR** cliquevars;
155  SCIP_VAR* var;
156  SCIP_Bool* cliquevals;
157  SCIP_Bool* propagated;
158  int* cliquesizes;
159  int* permutation;
160  SCIP_Real bestobj;
161  SCIP_Real obj;
162  SCIP_Bool alreadyone;
163  SCIP_Bool newnode;
164  int probingdepthofonefix;
165  int ncliquevars;
166  int ncliques;
167  int bestpos;
168  int firstclique;
169  int bestclique;
170  int cliquesize;
171  int bestcliquesize;
172  int nbacktracks = 0;
173  int v = 0;
174  int c;
175  int i;
176 
177  assert(scip != NULL);
178  assert(heurdata != NULL);
179  assert(onefixvars != NULL);
180  assert(nonefixvars != NULL);
181  assert(cutoff != NULL);
182 
183  cliques = SCIPgetCliques(scip);
184  ncliques = SCIPgetNCliques(scip);
185 
186  /* allocate memory */
187  SCIP_CALL( SCIPallocBufferArray(scip, &cliquesizes, ncliques) );
188  SCIP_CALL( SCIPallocBufferArray(scip, &permutation, ncliques) );
189  SCIP_CALL( SCIPallocClearBufferArray(scip, &propagated, ncliques) );
190 
191  for( c = ncliques - 1; c >= 0; --c )
192  {
193  cliquesizes[c] = SCIPcliqueGetNVars(cliques[c]);
194  }
195 
196  SCIPsort(permutation, compCliquesSize, (void*)cliquesizes, ncliques);
197 
198 #ifndef NDEBUG
199  for( c = ncliques - 1; c >= 1; --c )
200  {
201  assert(cliquesizes[permutation[c]] <= cliquesizes[permutation[c-1]]);
202  }
203 #endif
204 
205  *cutoff = FALSE;
206  probingdepthofonefix = 0;
207  firstclique = 0;
208 
209  SCIP_CALL( SCIPnewProbingNode(scip) );
210 
211  /* @todo maybe try to fix more than one variable to one in each probing node, to gain faster results */
212  for( c = 0; c < ncliques; ++c )
213  {
214  bestpos = -1;
215  bestobj = SCIPinfinity(scip);
216  alreadyone = FALSE;
217  newnode = FALSE;
218 
219  bestclique = firstclique;
220 
221  if( bestclique >= ncliques )
222  break;
223 
224  bestcliquesize = getCliqueUnfixedVars(cliques[permutation[bestclique]]);
225  assert(!propagated[permutation[bestclique]]);
226 
227  for( i = firstclique + 1; i < ncliques; ++i)
228  {
229  if( cliquesizes[permutation[i]] < bestcliquesize )
230  break;
231 
232  if( propagated[permutation[i]] )
233  continue;
234 
235  cliquesize = getCliqueUnfixedVars(cliques[permutation[i]]);
236 
237  if( cliquesize > bestcliquesize )
238  {
239  bestclique = i;
240  bestcliquesize = cliquesize;
241  }
242  else if( cliquesize == 0 )
243  {
244  propagated[permutation[i]] = TRUE;
245  }
246  }
247  clique = cliques[permutation[bestclique]];
248  propagated[permutation[bestclique]] = TRUE;
249 
250  while( firstclique < ncliques && propagated[permutation[firstclique]] )
251  ++firstclique;
252 
253  ncliquevars = SCIPcliqueGetNVars(clique);
254  cliquevars = SCIPcliqueGetVars(clique);
255  cliquevals = SCIPcliqueGetValues(clique);
256 
257  for( v = 0; v < ncliquevars; ++v )
258  {
259  var = cliquevars[v];
260 
261  /* variable is already fixed */
262  if( SCIPvarGetUbLocal(var) < SCIPvarGetLbLocal(var) + 0.5 )
263  {
264  SCIPdebugMessage("<%s> is already fixed to %g\n", SCIPvarGetName(var), SCIPvarGetUbLocal(var));
265 
266  /* clique variable is fixed to 1 */
267  if( cliquevals[v] == (SCIPvarGetLbLocal(var) > 0.5) )
268  {
269  assert(!alreadyone);
270  alreadyone = TRUE;
271  break;
272  }
273  continue;
274  }
275 
276  obj = cliquevals[v] ? SCIPvarGetObj(var) : -SCIPvarGetObj(var);
277 
278  /* @todo use a tiebreaker (locks?) */
279  if( obj < bestobj )
280  {
281  /* variable is not the best one in the clique anymore, fix it to 0 */
282  if( bestpos >= 0 )
283  {
284  if( cliquevals[bestpos] )
285  {
286  SCIP_CALL( SCIPfixVarProbing(scip, cliquevars[bestpos], 0.0) );
287  }
288  else
289  {
290  SCIP_CALL( SCIPfixVarProbing(scip, cliquevars[bestpos], 1.0) );
291  }
292  SCIPdebugMessage("fixed <%s> to %g\n", SCIPvarGetName(cliquevars[bestpos]), SCIPvarGetUbLocal(cliquevars[bestpos]));
293  newnode = TRUE;
294  }
295 
296  bestobj = obj;
297  bestpos = v;
298  }
299  /* variable is not the best one in the clique, fix it to 0 */
300  else
301  {
302  assert(bestpos >= 0);
303 
304  if( cliquevals[v] )
305  {
306  SCIP_CALL( SCIPfixVarProbing(scip, var, 0.0) );
307  }
308  else
309  {
310  SCIP_CALL( SCIPfixVarProbing(scip, var, 1.0) );
311  }
312  SCIPdebugMessage("fixed <%s> to %g\n", SCIPvarGetName(var), SCIPvarGetUbLocal(var));
313  newnode = TRUE;
314  }
315  }
316  /* we found a variable in the clique which is already fixed to 1 */
317  if( alreadyone )
318  {
319  /* fix (so far) best candidate to 0 */
320  if( bestpos >= 0 )
321  {
322  if( cliquevals[bestpos] )
323  {
324  SCIP_CALL( SCIPfixVarProbing(scip, cliquevars[bestpos], 0.0) );
325  }
326  else
327  {
328  SCIP_CALL( SCIPfixVarProbing(scip, cliquevars[bestpos], 1.0) );
329  }
330  SCIPdebugMessage("fixed <%s> to %g\n", SCIPvarGetName(cliquevars[bestpos]), SCIPvarGetUbLocal(cliquevars[bestpos]));
331  newnode = TRUE;
332  }
333 
334  /* fix all variables not yet processed to 0 */
335  for( ; v < ncliquevars; ++v )
336  {
337  var = cliquevars[v];
338 
339  if( SCIPvarGetUbLocal(var) < SCIPvarGetLbLocal(var) + 0.5 )
340  continue;
341 
342  if( cliquevals[v] )
343  {
344  SCIP_CALL( SCIPfixVarProbing(scip, var, 0.0) );
345  }
346  else
347  {
348  SCIP_CALL( SCIPfixVarProbing(scip, var, 1.0) );
349  }
350  SCIPdebugMessage("fixed <%s> to %g\n", SCIPvarGetName(var), SCIPvarGetUbLocal(var));
351  newnode = TRUE;
352  }
353  }
354  /* fix the best variable to 1 */
355  else if( bestpos >= 0 )
356  {
357  assert(bestpos <= ncliquevars);
358 
359  probingdepthofonefix = SCIPgetProbingDepth(scip);
360  onefixvars[(*nonefixvars)] = cliquevars[bestpos];
361 
362  /* @todo should we even fix the best candidate to 1? */
363  if( cliquevals[bestpos] )
364  {
365  SCIP_CALL( SCIPfixVarProbing(scip, cliquevars[bestpos], 1.0) );
366  onefixvals[(*nonefixvars)] = 1;
367  }
368  else
369  {
370  SCIP_CALL( SCIPfixVarProbing(scip, cliquevars[bestpos], 0.0) );
371  onefixvals[(*nonefixvars)] = 0;
372  }
373  SCIPdebugMessage("fixed <%s> to %g*\n", SCIPvarGetName(cliquevars[bestpos]), SCIPvarGetUbLocal(cliquevars[bestpos]));
374  ++(*nonefixvars);
375  newnode = TRUE;
376  }
377 
378  if( newnode )
379  {
380  /* propagate fixings */
381  SCIP_CALL( SCIPpropagateProbing(scip, heurdata->maxproprounds, cutoff, NULL) );
382 
383  SCIPdebugMessage("propagate fixings of clique %d: cutoff=%u\n", c, *cutoff);
384 
385  if( SCIPisStopped(scip) )
386  break;
387 
388  /* stop if we reached the depth limit */
389  if( SCIP_MAXTREEDEPTH <= SCIPgetDepth(scip) )
390  break;
391 
392  /* probing detected infeasibility: backtrack */
393  if( *cutoff )
394  {
395  if( *nonefixvars > 0 )
396  {
397  if( probingdepthofonefix > 0 )
398  {
399 
400  SCIP_CALL( SCIPbacktrackProbing(scip, probingdepthofonefix - 1) );
401  probingdepthofonefix = 0;
402  ++nbacktracks;
403 
404  /* because of the limited number of propagation rounds, it may happen that conflict analysis finds a
405  * valid global fixing for the last fixed variable that conflicts with applying the reverse fixing
406  * after backtracking; in that case, we ran into a deadend and stop
407  */
408  if( SCIPvarGetLbLocal(onefixvars[*nonefixvars - 1]) < 1.5 - onefixvals[*nonefixvars - 1]
409  && SCIPvarGetUbLocal(onefixvars[*nonefixvars - 1]) > 0.5 - onefixvals[*nonefixvars - 1] )
410  {
411  /* fix the last variable, which was fixed to 1 and led to the cutoff, to 0 */
412  SCIP_CALL( SCIPfixVarProbing(scip, onefixvars[*nonefixvars - 1], 1.0 - onefixvals[*nonefixvars - 1]) );
413  --(*nonefixvars);
414 
415  /* propagate fixings */
416  SCIP_CALL( SCIPpropagateProbing(scip, heurdata->maxproprounds, cutoff, NULL) );
417 
418  SCIPdebugMessage("backtrack %d was %sfeasible\n", nbacktracks, (*cutoff ? "in" : ""));
419  }
420 #ifndef NDEBUG
421  else
422  assert(*cutoff == TRUE);
423 #endif
424  }
425  if( *cutoff )
426  {
427 #ifndef NOCONFLICT
428  SCIP_CONS* conflictcons;
429  char consname[SCIP_MAXSTRLEN];
430 
431  /* create own conflict */
432  (void) SCIPsnprintf(consname, SCIP_MAXSTRLEN, "conf%" SCIP_LONGINT_FORMAT "", SCIPgetNNodes(scip));
433 
434  /* get variables for the conflict */
435  for( i = 0; i < *nonefixvars; ++i )
436  {
437  /* if the variable was fixed to 1 by the heuristic, get its negated variable */
438  if( onefixvals[i] )
439  {
440  SCIP_CALL( SCIPgetNegatedVar(scip, onefixvars[i], &onefixvars[i]) );
441  }
442  }
443 
444  SCIPdebugMsg(scip, "probing was infeasible after %d backtracks\n", nbacktracks);
445 
446  /* create conflict constraint */
447  SCIP_CALL( SCIPcreateConsLogicor(scip, &conflictcons, consname, *nonefixvars, onefixvars,
449  SCIP_CALL( SCIPaddConsNode(scip, SCIPgetFocusNode(scip), conflictcons, NULL) );
450  SCIPdebugPrintCons(scip, conflictcons, NULL);
451  SCIP_CALL( SCIPreleaseCons(scip, &conflictcons) );
452 #endif
453  break;
454  }
455  else if( nbacktracks > heurdata->maxbacktracks )
456  {
457  SCIPdebugMsg(scip, "interrupt probing after %d backtracks\n", nbacktracks);
458  break;
459  }
460  }
461  /* we had a cutoff without a single one-fixing, so the current problem seems to be infeasible already */
462  else
463  break;
464  }
465 
466  SCIP_CALL( SCIPnewProbingNode(scip) );
467  }
468  }
469  assert((*nonefixvars > 0) || probingdepthofonefix == 0 );
470 
471  SCIPfreeBufferArray(scip, &propagated);
472  SCIPfreeBufferArray(scip, &permutation);
473  SCIPfreeBufferArray(scip, &cliquesizes);
474 
475  SCIPdebugMsg(scip, "fixed %d of %d variables in probing\n", v, SCIPgetNBinVars(scip));
476  SCIPdebugMsg(scip, "applied %d of %d cliques in probing\n", c, ncliques);
477  SCIPdebugMsg(scip, "probing was %sfeasible\n", (*cutoff) ? "in" : "");
478 
479  return SCIP_OKAY;
480 }
481 
482 /** creates a new solution for the original problem by copying the solution of the subproblem */
483 static
485  SCIP* scip, /**< original SCIP data structure */
486  SCIP* subscip, /**< SCIP structure of the subproblem */
487  SCIP_VAR** subvars, /**< the variables of the subproblem */
488  SCIP_SOL* newsol, /**< working solution */
489  SCIP_SOL* subsol, /**< solution of the subproblem */
490  SCIP_Bool* success /**< used to store whether new solution was found or not */
491  )
492 {
493  SCIP_VAR** vars; /* the original problem's variables */
494  int nvars;
495  SCIP_Real* subsolvals; /* solution values of the subproblem */
496 
497  assert(scip != NULL);
498  assert(subscip != NULL);
499  assert(subvars != NULL);
500  assert(subsol != NULL);
501  assert(success != NULL);
502 
503  /* get variables' data */
504  SCIP_CALL( SCIPgetVarsData(scip, &vars, &nvars, NULL, NULL, NULL, NULL) );
505 
506  /* sub-SCIP may have more variables than the number of active (transformed) variables in the main SCIP
507  * since constraint copying may have required the copy of variables that are fixed in the main SCIP
508  */
509  assert(nvars <= SCIPgetNOrigVars(subscip));
510 
511  SCIP_CALL( SCIPallocBufferArray(scip, &subsolvals, nvars) );
512 
513  /* copy the solution */
514  SCIP_CALL( SCIPgetSolVals(subscip, subsol, nvars, subvars, subsolvals) );
515 
516  SCIP_CALL( SCIPsetSolVals(scip, newsol, nvars, vars, subsolvals) );
517 
518  /* try to add new solution to scip and free it immediately */
519  SCIP_CALL( SCIPtrySol(scip, newsol, FALSE, FALSE, TRUE, TRUE, TRUE, success) );
520 
521  SCIPfreeBufferArray(scip, &subsolvals);
522 
523  return SCIP_OKAY;
524 }
525 
526 /*
527  * Callback methods of primal heuristic
528  */
529 
530 /** copy method for primal heuristic plugins (called when SCIP copies plugins) */
531 static
532 SCIP_DECL_HEURCOPY(heurCopyClique)
533 { /*lint --e{715}*/
534  assert(scip != NULL);
535  assert(heur != NULL);
536  assert(strcmp(SCIPheurGetName(heur), HEUR_NAME) == 0);
537 
538  /* call inclusion method of primal heuristic */
540 
541  return SCIP_OKAY;
542 }
543 
544 /** destructor of primal heuristic to free user data (called when SCIP is exiting) */
545 static
546 SCIP_DECL_HEURFREE(heurFreeClique)
547 { /*lint --e{715}*/
548  SCIP_HEURDATA* heurdata;
549 
550  assert(heur != NULL);
551  assert(strcmp(SCIPheurGetName(heur), HEUR_NAME) == 0);
552  assert(scip != NULL);
554  /* free heuristic data */
555  heurdata = SCIPheurGetData(heur);
556  assert(heurdata != NULL);
557 
558  SCIPfreeBlockMemory(scip, &heurdata);
559  SCIPheurSetData(heur, NULL);
560 
561  return SCIP_OKAY;
562 }
563 
564 
565 /** initialization method of primal heuristic (called after problem was transformed) */
566 static
567 SCIP_DECL_HEURINIT(heurInitClique)
568 { /*lint --e{715}*/
569  SCIP_HEURDATA* heurdata;
570 
571  assert(heur != NULL);
572  assert(strcmp(SCIPheurGetName(heur), HEUR_NAME) == 0);
573  assert(scip != NULL);
575  /* reset heuristic data */
576  heurdata = SCIPheurGetData(heur);
577  assert(heurdata != NULL);
578 
579  heurdata->usednodes = 0;
580 
581  return SCIP_OKAY;
582 }
583 
584 /** execution method of primal heuristic */
585 static
586 SCIP_DECL_HEUREXEC(heurExecClique)
587 { /*lint --e{715}*/
588  SCIP_HEURDATA* heurdata;
589  SCIP_VAR** vars;
590  SCIP_Real lowerbound;
591  int nvars;
592  int nbinvars;
593  int oldnpscands;
594  int npscands;
595  int i;
596  SCIP_Bool cutoff;
597  SCIP_Bool lperror;
598 
599  SCIP_VAR** onefixvars;
600  SCIP_Shortbool* onefixvals;
601  int nonefixvars;
602  SCIP_Bool enabledconflicts;
603  SCIP_LPSOLSTAT lpstatus;
604  SCIP_CONS* conflictcons;
605  SCIP_Bool solvelp;
606  char consname[SCIP_MAXSTRLEN];
607 
608  SCIP_Longint nstallnodes;
609 
610  SCIP_SOL* sol;
611 
612  assert(heur != NULL);
613  assert(strcmp(SCIPheurGetName(heur), HEUR_NAME) == 0);
614  assert(scip != NULL);
615  assert(result != NULL);
616 
617  *result = SCIP_DIDNOTRUN;
618 
619  /* get heuristic's data */
620  heurdata = SCIPheurGetData(heur);
621  assert(heurdata != NULL);
622 
623  nbinvars = SCIPgetNBinVars(scip);
624 
625  if( nbinvars < 2 )
626  return SCIP_OKAY;
627 
628  /* check for necessary information to apply this heuristic */
629  if( SCIPgetNCliques(scip) == 0 )
630  return SCIP_OKAY;
631 
632  lowerbound = SCIPgetLowerbound(scip);
633 
634  /* calculate the maximal number of branching nodes until heuristic is aborted */
635  nstallnodes = (SCIP_Longint)(heurdata->nodesquot * SCIPgetNNodes(scip));
636 
637  /* reward clique heuristic if it succeeded often */
638  nstallnodes = (SCIP_Longint)(nstallnodes * 3.0 * (SCIPheurGetNBestSolsFound(heur)+1.0)/(SCIPheurGetNCalls(heur) + 1.0));
639  nstallnodes -= 100 * SCIPheurGetNCalls(heur); /* count the setup costs for the sub-MIP as 100 nodes */
640  nstallnodes += heurdata->nodesofs;
641 
642  /* determine the node limit for the current process */
643  nstallnodes -= heurdata->usednodes;
644  nstallnodes = MIN(nstallnodes, heurdata->maxnodes);
645 
646  /* check whether we have enough nodes left to call subproblem solving */
647  if( nstallnodes < heurdata->minnodes )
648  {
649  SCIPdebugMsg(scip, "skipping " HEUR_NAME ": nstallnodes=%" SCIP_LONGINT_FORMAT ", minnodes=%" SCIP_LONGINT_FORMAT "\n", nstallnodes, heurdata->minnodes);
650  return SCIP_OKAY;
651  }
652 
653  oldnpscands = SCIPgetNPseudoBranchCands(scip);
654  onefixvars = NULL;
655  onefixvals = NULL;
656  sol = NULL;
657 
658  /* disable conflict analysis, because we can it better than SCIP itself, cause we have more information */
659  SCIP_CALL( SCIPgetBoolParam(scip, "conflict/enable", &enabledconflicts) );
660 
661  if( !SCIPisParamFixed(scip, "conflict/enable") )
662  {
663  SCIP_CALL( SCIPsetBoolParam(scip, "conflict/enable", FALSE) );
664  }
665 
666  solvelp = SCIPhasCurrentNodeLP(scip);
667 
668  if( !SCIPisLPConstructed(scip) && solvelp )
669  {
670  SCIP_CALL( SCIPconstructLP(scip, &cutoff) );
671 
672  /* manually cut off the node if the LP construction detected infeasibility (heuristics cannot return such a result) */
673  if( cutoff )
674  {
676  goto TERMINATE;
677  }
678 
680  }
681 
682  *result = SCIP_DIDNOTFIND;
683 
684  /* start probing */
686 
687 #ifdef COLLECTSTATISTICS
689 #endif
690 
691  /* create a solution */
692  SCIP_CALL( SCIPcreateSol(scip, &sol, heur) );
693 
694  /* allocate memory for all variables which will be fixed to one during probing */
695  SCIP_CALL(SCIPallocBufferArray(scip, &onefixvars, nbinvars) );
696  SCIP_CALL(SCIPallocBufferArray(scip, &onefixvals, nbinvars) );
697  nonefixvars = 0;
698 
699  /* apply fixings due to clique information */
700  SCIP_CALL( applyCliqueFixings(scip, heurdata, onefixvars, onefixvals, &nonefixvars, &cutoff) );
701 
702  if( cutoff || SCIPisStopped(scip) )
703  goto TERMINATE;
704 
705  /* check that we had enough fixings */
706  npscands = SCIPgetNPseudoBranchCands(scip);
707 
708  SCIPdebugMsg(scip, "npscands=%d, oldnpscands=%d, heurdata->minintfixingrate=%g\n", npscands, oldnpscands, heurdata->minintfixingrate);
709 
710  if( npscands > oldnpscands * (1.0 - heurdata->minintfixingrate) )
711  {
712  if( heurdata->uselockfixings && npscands <= 2.0 * oldnpscands * (1.0 - heurdata->minintfixingrate) )
713  {
714  SCIP_Bool allrowsfulfilled = FALSE;
715 
716  SCIP_CALL( SCIPapplyLockFixings(scip, NULL, &cutoff, &allrowsfulfilled) );
717 
718  if( cutoff || SCIPisStopped(scip) )
719  {
720  SCIPdebugMsg(scip, "cutoff or timeout in locks fixing\n");
721  goto TERMINATE;
722  }
723 
724  npscands = SCIPgetNPseudoBranchCands(scip);
725 
726  SCIPdebugMsg(scip, "after lockfixings: npscands=%d, oldnpscands=%d, allrowsfulfilled=%u, heurdata->minintfixingrate=%g\n",
727  npscands, oldnpscands, allrowsfulfilled, heurdata->minintfixingrate);
728 
729  if( !allrowsfulfilled && npscands > oldnpscands * (1 - heurdata->minintfixingrate) )
730  {
731  SCIPdebugMsg(scip, "--> too few fixings\n");
732 
733  goto TERMINATE;
734  }
735  }
736  else
737  {
738  SCIPdebugMsg(scip, "--> too few fixings\n");
739 
740  goto TERMINATE;
741  }
742  }
743 
744  /*************************** Probing LP Solving ***************************/
745 
746  lpstatus = SCIP_LPSOLSTAT_ERROR;
747  lperror = FALSE;
748 
749  /* solve lp only if the problem is still feasible */
750  if( solvelp )
751  {
752  SCIPdebugMsg(scip, "starting solving clique-lp at time %g\n", SCIPgetSolvingTime(scip));
753 
754  /* solve LP; errors in the LP solver should not kill the overall solving process, if the LP is just needed for a
755  * heuristic. hence in optimized mode, the return code is caught and a warning is printed, only in debug mode,
756  * SCIP will stop.
757  */
758 #ifdef NDEBUG
759  {
760  SCIP_Bool retstat;
761  retstat = SCIPsolveProbingLP(scip, -1, &lperror, NULL);
762  if( retstat != SCIP_OKAY )
763  {
764  SCIPwarningMessage(scip, "Error while solving LP in clique heuristic; LP solve terminated with code <%d>\n",
765  retstat);
766  }
767  }
768 #else
769  SCIP_CALL( SCIPsolveProbingLP(scip, -1, &lperror, NULL) );
770 #endif
771  SCIPdebugMsg(scip, "ending solving clique-lp at time %g\n", SCIPgetSolvingTime(scip));
772 
773  lpstatus = SCIPgetLPSolstat(scip);
774 
775  SCIPdebugMsg(scip, " -> new LP iterations: %" SCIP_LONGINT_FORMAT "\n", SCIPgetNLPIterations(scip));
776  SCIPdebugMsg(scip, " -> error=%u, status=%d\n", lperror, lpstatus);
777  }
778 
779  /* check if this is a feasible solution */
780  if( lpstatus == SCIP_LPSOLSTAT_OPTIMAL && !lperror )
781  {
782  SCIP_Bool stored;
783  SCIP_Bool success;
784 
785  assert(!cutoff);
786 
787  lowerbound = SCIPgetLPObjval(scip);
788 
789  /* copy the current LP solution to the working solution */
790  SCIP_CALL( SCIPlinkLPSol(scip, sol) );
791 
792  SCIP_CALL( SCIProundSol(scip, sol, &success) );
793 
794  if( success )
795  {
796  SCIPdebugMsg(scip, "clique heuristic found roundable primal solution: obj=%g\n",
797  SCIPgetSolOrigObj(scip, sol));
798 
799  /* check solution for feasibility, and add it to solution store if possible.
800  * Neither integrality nor feasibility of LP rows have to be checked, because they
801  * are guaranteed by the heuristic at this stage.
802  */
803 #ifdef SCIP_DEBUG
804  SCIP_CALL( SCIPtrySol(scip, sol, TRUE, TRUE, TRUE, TRUE, TRUE, &stored) );
805 #else
806  SCIP_CALL( SCIPtrySol(scip, sol, FALSE, FALSE, TRUE, FALSE, FALSE, &stored) );
807 #endif
808 
809  if( stored )
810  {
811  SCIPdebugMsg(scip, "found feasible solution:\n");
812  SCIPdebug( SCIP_CALL( SCIPprintSol(scip, sol, NULL, FALSE) ) );
813  *result = SCIP_FOUNDSOL;
814  }
815 
816  /* we found a solution, so we are done */
817  goto TERMINATE;
818  }
819  }
820  /*************************** END Probing LP Solving ***************************/
821 
822 
823  /*************************** Create Conflict ***************************/
824  if( SCIPallColsInLP(scip) && (lpstatus == SCIP_LPSOLSTAT_INFEASIBLE || lpstatus == SCIP_LPSOLSTAT_OBJLIMIT) )
825  {
826 #ifndef NOCONFLICT
827  /* create own conflict */
828  (void) SCIPsnprintf(consname, SCIP_MAXSTRLEN, "conf%" SCIP_LONGINT_FORMAT "", SCIPgetNNodes(scip));
829 
830  /* get variables for the conflict */
831  for( i = 0; i < nonefixvars; ++i )
832  {
833  /* if the variable was fixed to 1 by the heuristic, get its negated variable */
834  if( onefixvals[i] )
835  {
836  SCIP_CALL( SCIPgetNegatedVar(scip, onefixvars[i], &onefixvars[i]) );
837  }
838  }
839 
840  /* create conflict constraint */
841  SCIP_CALL( SCIPcreateConsLogicor(scip, &conflictcons, consname, nonefixvars, onefixvars,
843  SCIP_CALL( SCIPaddConsNode(scip, SCIPgetFocusNode(scip), conflictcons, NULL) );
844  SCIPdebugPrintCons(scip, conflictcons, NULL);
845  SCIP_CALL( SCIPreleaseCons(scip, &conflictcons) );
846 #endif
847  goto TERMINATE;
848  }
849  /*************************** End Conflict ***************************/
850 
851  /*************************** Start Subscip Solving ***************************/
852  /* no solution has been found yet and the subproblem is still feasible --> fix all other variables by subscip if
853  * necessary
854  */
855  if( !lperror )
856  {
857  SCIP* subscip;
858  SCIP_VAR** subvars;
859  SCIP_HASHMAP* varmap;
860  SCIP_Bool valid;
861 
862  /* check whether there is enough time and memory left */
863  SCIP_CALL( SCIPcheckCopyLimits(scip, &valid) );
864 
865  if( !valid )
866  goto TERMINATE;
867 
868  /* get all variables */
869  SCIP_CALL( SCIPgetVarsData(scip, &vars, &nvars, NULL, NULL, NULL, NULL) );
870 
871  /* create subproblem */
872  SCIP_CALL( SCIPcreate(&subscip) );
873 
874  /* allocate temporary memory for subscip variables */
875  SCIP_CALL( SCIPallocBufferArray(scip, &subvars, nvars) );
876 
877  /* create the variable mapping hash map */
878  SCIP_CALL( SCIPhashmapCreate(&varmap, SCIPblkmem(subscip), nvars) );
879 
880  SCIP_CALL( SCIPcopyConsCompression(scip, subscip, varmap, NULL, "_clique", NULL, NULL, 0, FALSE, FALSE, TRUE, &valid) );
881 
882  if( heurdata->copycuts )
883  {
884  /* copies all active cuts from cutpool of sourcescip to linear constraints in targetscip */
885  SCIP_CALL( SCIPcopyCuts(scip, subscip, varmap, NULL, FALSE, NULL) );
886  }
887 
888  for( i = 0; i < nvars; i++ )
889  subvars[i] = (SCIP_VAR*) SCIPhashmapGetImage(varmap, vars[i]);
890 
891  /* free hash map */
892  SCIPhashmapFree(&varmap);
893 
894  /* do not abort subproblem on CTRL-C */
895  SCIP_CALL( SCIPsetBoolParam(subscip, "misc/catchctrlc", FALSE) );
896 
897 #ifdef SCIP_DEBUG
898  /* for debugging, enable full output */
899  SCIP_CALL( SCIPsetIntParam(subscip, "display/verblevel", 5) );
900  SCIP_CALL( SCIPsetIntParam(subscip, "display/freq", 100000000) );
901 #else
902  /* disable statistic timing inside sub SCIP and output to console */
903  SCIP_CALL( SCIPsetIntParam(subscip, "display/verblevel", 0) );
904  SCIP_CALL( SCIPsetBoolParam(subscip, "timing/statistictiming", FALSE) );
905 #endif
906 
907  /* set limits for the subproblem */
908  SCIP_CALL( SCIPcopyLimits(scip, subscip) );
909  SCIP_CALL( SCIPsetLongintParam(subscip, "limits/stallnodes", nstallnodes) );
910  SCIP_CALL( SCIPsetLongintParam(subscip, "limits/nodes", heurdata->maxnodes) );
911 
912  /* speed up sub-SCIP by not checking dual LP feasibility */
913  SCIP_CALL( SCIPsetBoolParam(subscip, "lp/checkdualfeas", FALSE) );
914 
915  /* forbid call of heuristics and separators solving sub-CIPs */
916  SCIP_CALL( SCIPsetSubscipsOff(subscip, TRUE) );
917 
918  /* disable cutting plane separation */
920 
921  /* disable expensive presolving */
923 
924  /* use inference branching */
925  if( SCIPfindBranchrule(subscip, "inference") != NULL && !SCIPisParamFixed(subscip, "branching/inference/priority") )
926  {
927  SCIP_CALL( SCIPsetIntParam(subscip, "branching/inference/priority", INT_MAX/4) );
928  }
929 
930  /* employ a limit on the number of enforcement rounds in the quadratic constraint handler; this fixes the issue that
931  * sometimes the quadratic constraint handler needs hundreds or thousands of enforcement rounds to determine the
932  * feasibility status of a single node without fractional branching candidates by separation (namely for uflquad
933  * instances); however, the solution status of the sub-SCIP might get corrupted by this; hence no deductions shall be
934  * made for the original SCIP
935  */
936  if( SCIPfindConshdlr(subscip, "quadratic") != NULL && !SCIPisParamFixed(subscip, "constraints/quadratic/enfolplimit") )
937  {
938  SCIP_CALL( SCIPsetIntParam(subscip, "constraints/quadratic/enfolplimit", 10) );
939  }
940 
941  /* if there is already a solution, add an objective cutoff */
942  if( SCIPgetNSols(scip) > 0 )
943  {
944  SCIP_Real upperbound;
945  SCIP_Real minimprove;
946  SCIP_Real cutoffbound;
947 
948  minimprove = heurdata->minimprove;
950 
951  upperbound = SCIPgetUpperbound(scip) - SCIPsumepsilon(scip);
952 
953  if( !SCIPisInfinity(scip, -1.0 * lowerbound) )
954  {
955  cutoffbound = (1-minimprove) * SCIPgetUpperbound(scip) + minimprove * lowerbound;
956  }
957  else
958  {
959  if( SCIPgetUpperbound ( scip ) >= 0 )
960  cutoffbound = (1 - minimprove) * SCIPgetUpperbound(scip);
961  else
962  cutoffbound = (1 + minimprove) * SCIPgetUpperbound(scip);
963  }
964  cutoffbound = MIN(upperbound, cutoffbound);
965  SCIP_CALL( SCIPsetObjlimit(subscip, cutoffbound) );
966  SCIPdebugMsg(scip, "setting objlimit for subscip to %g\n", cutoffbound);
967  }
968 
969  SCIPdebugMsg(scip, "starting solving clique-submip at time %g\n", SCIPgetSolvingTime(scip));
970 
971  /* solve the subproblem */
972  /* Errors in the LP solver should not kill the overall solving process, if the LP is just needed for a heuristic.
973  * Hence in optimized mode, the return code is caught and a warning is printed, only in debug mode, SCIP will stop.
974  */
975  SCIP_CALL_ABORT( SCIPpresolve(subscip) );
976 
977  SCIPdebugMsg(scip, "clique heuristic presolved subproblem at time %g : %d vars, %d cons; fixing value = %g\n", SCIPgetSolvingTime(scip), SCIPgetNVars(subscip), SCIPgetNConss(subscip), ((nvars - SCIPgetNVars(subscip)) / (SCIP_Real)nvars));
978 
979  /* after presolving, we should have at least reached a certain fixing rate over ALL variables (including continuous)
980  * to ensure that not only the MIP but also the LP relaxation is easy enough
981  */
982  if( ((nvars - SCIPgetNVars(subscip)) / (SCIP_Real)nvars) >= heurdata->minmipfixingrate )
983  {
984  SCIP_SOL** subsols;
985  SCIP_Bool success;
986  int nsubsols;
987 
988  SCIPdebugMsg(scip, "solving subproblem: nstallnodes=%" SCIP_LONGINT_FORMAT ", maxnodes=%" SCIP_LONGINT_FORMAT "\n", nstallnodes, heurdata->maxnodes);
989 
990  SCIP_CALL_ABORT( SCIPsolve(subscip) );
991 
992  SCIPdebugMsg(scip, "ending solving clique-submip at time %g, status = %d\n", SCIPgetSolvingTime(scip), SCIPgetStatus(subscip));
993 
994  /* check, whether a solution was found; due to numerics, it might happen that not all solutions are feasible ->
995  * try all solutions until one was accepted
996  */
997  nsubsols = SCIPgetNSols(subscip);
998  subsols = SCIPgetSols(subscip);
999  success = FALSE;
1000 
1001  for( i = 0; i < nsubsols && !success; ++i )
1002  {
1003  SCIP_CALL( createNewSol(scip, subscip, subvars, sol, subsols[i], &success) );
1004  }
1005  if( success )
1006  *result = SCIP_FOUNDSOL;
1007 #ifndef NOCONFLICT
1008  /* if subscip was infeasible, add a conflict */
1009  if( SCIPgetStatus(subscip) == SCIP_STATUS_INFEASIBLE )
1010  {
1011  /* create own conflict */
1012  (void) SCIPsnprintf(consname, SCIP_MAXSTRLEN, "conf%" SCIP_LONGINT_FORMAT "", SCIPgetNNodes(scip));
1013 
1014  /* get variables for the conflict */
1015  for( i = 0; i < nonefixvars; ++i )
1016  {
1017  /* if the variable was fixed to 1 by the heuristic, get its negated variable */
1018  if( onefixvals[i] )
1019  {
1020  SCIP_CALL( SCIPgetNegatedVar(scip, onefixvars[i], &onefixvars[i]) );
1021  }
1022  }
1023 
1024  /* create conflict constraint */
1025  SCIP_CALL( SCIPcreateConsLogicor(scip, &conflictcons, consname, nonefixvars, onefixvars,
1026  FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE) );
1027  SCIP_CALL( SCIPaddConsNode(scip, SCIPgetFocusNode(scip), conflictcons, NULL) );
1028  SCIPdebugPrintCons(scip, conflictcons, NULL);
1029  SCIP_CALL( SCIPreleaseCons(scip, &conflictcons) );
1030  }
1031 #endif
1032  }
1033 
1034 #ifdef SCIP_DEBUG
1035  SCIP_CALL( SCIPprintStatistics(subscip, NULL) );
1036 #endif
1037 
1038  /* free subproblem */
1039  SCIPfreeBufferArray(scip, &subvars);
1040  SCIP_CALL( SCIPfree(&subscip) );
1041  }
1042 
1043  /*************************** End Subscip Solving ***************************/
1044 
1045  TERMINATE:
1046 
1047  /* reset the conflict analysis */
1048  if( !SCIPisParamFixed(scip, "conflict/enable") )
1049  {
1050  SCIP_CALL( SCIPsetBoolParam(scip, "conflict/enable", enabledconflicts) );
1051  }
1052 
1053  /* free conflict variables */
1054  SCIPfreeBufferArrayNull(scip, &onefixvars);
1055  SCIPfreeBufferArrayNull(scip, &onefixvals);
1056 
1057  /* freeing solution */
1058  if( sol != NULL )
1059  {
1060  SCIP_CALL( SCIPfreeSol(scip, &sol) );
1061  }
1062 
1063  /* end probing */
1064  if( SCIPinProbing(scip) )
1065  {
1067  }
1068 
1069  return SCIP_OKAY;
1070 }
1071 
1072 /*
1073  * primal heuristic specific interface methods
1074  */
1075 
1076 /** creates the clique primal heuristic and includes it in SCIP */
1078  SCIP* scip /**< SCIP data structure */
1079  )
1080 {
1081  SCIP_HEURDATA* heurdata;
1082  SCIP_HEUR* heur;
1083 
1084  /* create clique primal heuristic data */
1085  SCIP_CALL( SCIPallocBlockMemory(scip, &heurdata) );
1086 
1087  /* include primal heuristic */
1088  SCIP_CALL( SCIPincludeHeurBasic(scip, &heur,
1090  HEUR_MAXDEPTH, HEUR_TIMING, HEUR_USESSUBSCIP, heurExecClique, heurdata) );
1091 
1092  assert(heur != NULL);
1093 
1094  /* set non-NULL pointers to callback methods */
1095  SCIP_CALL( SCIPsetHeurCopy(scip, heur, heurCopyClique) );
1096  SCIP_CALL( SCIPsetHeurFree(scip, heur, heurFreeClique) );
1097  SCIP_CALL( SCIPsetHeurInit(scip, heur, heurInitClique) );
1098 
1099  /* add clique primal heuristic parameters */
1100 
1101  SCIP_CALL( SCIPaddRealParam(scip, "heuristics/" HEUR_NAME "/minintfixingrate",
1102  "minimum percentage of integer variables that have to be fixable",
1103  &heurdata->minintfixingrate, FALSE, DEFAULT_MININTFIXINGRATE, 0.0, 1.0, NULL, NULL) );
1104 
1105  SCIP_CALL( SCIPaddRealParam(scip, "heuristics/" HEUR_NAME "/minmipfixingrate",
1106  "minimum percentage of fixed variables in the sub-MIP",
1107  &heurdata->minmipfixingrate, FALSE, DEFAULT_MINMIPFIXINGRATE, 0.0, 1.0, NULL, NULL) );
1108 
1109  SCIP_CALL( SCIPaddLongintParam(scip, "heuristics/" HEUR_NAME "/maxnodes",
1110  "maximum number of nodes to regard in the subproblem",
1111  &heurdata->maxnodes, TRUE, DEFAULT_MAXNODES, 0LL, SCIP_LONGINT_MAX, NULL, NULL) );
1112 
1113  SCIP_CALL( SCIPaddLongintParam(scip, "heuristics/" HEUR_NAME "/nodesofs",
1114  "number of nodes added to the contingent of the total nodes",
1115  &heurdata->nodesofs, FALSE, DEFAULT_NODESOFS, 0LL, SCIP_LONGINT_MAX, NULL, NULL) );
1116 
1117  SCIP_CALL( SCIPaddLongintParam(scip, "heuristics/" HEUR_NAME "/minnodes",
1118  "minimum number of nodes required to start the subproblem",
1119  &heurdata->minnodes, TRUE, DEFAULT_MINNODES, 0LL, SCIP_LONGINT_MAX, NULL, NULL) );
1120 
1121  SCIP_CALL( SCIPaddRealParam(scip, "heuristics/" HEUR_NAME "/nodesquot",
1122  "contingent of sub problem nodes in relation to the number of nodes of the original problem",
1123  &heurdata->nodesquot, FALSE, DEFAULT_NODESQUOT, 0.0, 1.0, NULL, NULL) );
1124 
1125  SCIP_CALL( SCIPaddRealParam(scip, "heuristics/" HEUR_NAME "/minimprove",
1126  "factor by which " HEUR_NAME " heuristic should at least improve the incumbent",
1127  &heurdata->minimprove, TRUE, DEFAULT_MINIMPROVE, 0.0, 1.0, NULL, NULL) );
1128 
1129  SCIP_CALL( SCIPaddIntParam(scip, "heuristics/" HEUR_NAME "/maxproprounds",
1130  "maximum number of propagation rounds during probing (-1 infinity)",
1131  &heurdata->maxproprounds, TRUE, DEFAULT_MAXPROPROUNDS, -1, INT_MAX/4, NULL, NULL) );
1132 
1133  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/" HEUR_NAME "/copycuts",
1134  "should all active cuts from cutpool be copied to constraints in subproblem?",
1135  &heurdata->copycuts, TRUE, DEFAULT_COPYCUTS, NULL, NULL) );
1136 
1137  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/" HEUR_NAME "/uselockfixings",
1138  "should more variables be fixed based on variable locks if the fixing rate was not reached?",
1139  &heurdata->uselockfixings, TRUE, DEFAULT_USELOCKFIXINGS, NULL, NULL) );
1140 
1141  SCIP_CALL( SCIPaddIntParam(scip, "heuristics/" HEUR_NAME "/maxbacktracks",
1142  "maximum number of backtracks during the fixing process",
1143  &heurdata->maxbacktracks, TRUE, DEFAULT_MAXBACKTRACKS, -1, INT_MAX/4, NULL, NULL) );
1144 
1145  return SCIP_OKAY;
1146 }
#define DEFAULT_MINMIPFIXINGRATE
Definition: heur_clique.c:58
#define DEFAULT_MININTFIXINGRATE
Definition: heur_clique.c:57
SCIP_RETCODE SCIPlinkLPSol(SCIP *scip, SCIP_SOL *sol)
Definition: scip.c:38576
SCIP_Real SCIPgetSolvingTime(SCIP *scip)
Definition: scip.c:46306
LNS heuristic using a clique partition to restrict the search neighborhood.
SCIP_RETCODE SCIPsetSeparating(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
Definition: scip.c:5158
#define HEUR_TIMING
Definition: heur_clique.c:53
#define DEFAULT_MAXNODES
Definition: heur_clique.c:56
SCIP_VAR ** SCIPcliqueGetVars(SCIP_CLIQUE *clique)
Definition: implics.c:3353
SCIP_NODE * SCIPgetCurrentNode(SCIP *scip)
Definition: scip.c:41404
SCIP_RETCODE SCIPbacktrackProbing(SCIP *scip, int probingdepth)
Definition: scip.c:35964
SCIP_Longint SCIPgetNLPIterations(SCIP *scip)
Definition: scip.c:42333
#define HEUR_FREQ
Definition: heur_clique.c:50
SCIP_CONSHDLR * SCIPfindConshdlr(SCIP *scip, const char *name)
Definition: scip.c:6604
int SCIPgetProbingDepth(SCIP *scip)
Definition: scip.c:35937
#define SCIPallocClearBufferArray(scip, ptr, num)
Definition: scip.h:22622
public methods for implications, variable bounds, and cliques
#define HEUR_MAXDEPTH
Definition: heur_clique.c:52
#define SCIP_MAXSTRLEN
Definition: def.h:259
static int getCliqueUnfixedVars(SCIP_CLIQUE *clique)
Definition: heur_clique.c:123
SCIP_Longint SCIPheurGetNBestSolsFound(SCIP_HEUR *heur)
Definition: heur.c:1344
static SCIP_DECL_HEURFREE(heurFreeClique)
Definition: heur_clique.c:553
static SCIP_DECL_HEUREXEC(heurExecClique)
Definition: heur_clique.c:593
int SCIPgetNOrigVars(SCIP *scip)
Definition: scip.c:12252
SCIP_Real SCIPvarGetLbLocal(SCIP_VAR *var)
Definition: var.c:17332
int SCIPgetNPseudoBranchCands(SCIP *scip)
Definition: scip.c:37365
#define HEUR_DESC
Definition: heur_clique.c:47
SCIP_RETCODE SCIPgetVarsData(SCIP *scip, SCIP_VAR ***vars, int *nvars, int *nbinvars, int *nintvars, int *nimplvars, int *ncontvars)
Definition: scip.c:11686
SCIP_SOL ** SCIPgetSols(SCIP *scip)
Definition: scip.c:39832
#define FALSE
Definition: def.h:64
SCIP_RETCODE SCIPhashmapCreate(SCIP_HASHMAP **hashmap, BMS_BLKMEM *blkmem, int mapsize)
Definition: misc.c:2793
#define DEFAULT_NODESQUOT
Definition: heur_clique.c:68
SCIP_RETCODE SCIPaddLongintParam(SCIP *scip, const char *name, const char *desc, SCIP_Longint *valueptr, SCIP_Bool isadvanced, SCIP_Longint defaultvalue, SCIP_Longint minvalue, SCIP_Longint maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
Definition: scip.c:4293
SCIP_RETCODE SCIPcopyLimits(SCIP *sourcescip, SCIP *targetscip)
Definition: scip.c:4192
SCIP_RETCODE SCIPcopyConsCompression(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, const char *suffix, SCIP_VAR **fixedvars, SCIP_Real *fixedvals, int nfixedvars, SCIP_Bool global, SCIP_Bool enablepricing, SCIP_Bool passmessagehdlr, SCIP_Bool *valid)
Definition: scip.c:3884
SCIP_RETCODE SCIPcutoffNode(SCIP *scip, SCIP_NODE *node)
Definition: scip.c:41747
SCIP_Real SCIPinfinity(SCIP *scip)
Definition: scip.c:47028
int SCIPsnprintf(char *t, int len, const char *s,...)
Definition: misc.c:10011
#define TRUE
Definition: def.h:63
#define SCIPdebug(x)
Definition: pub_message.h:74
SCIP_RETCODE SCIPapplyLockFixings(SCIP *scip, SCIP_HEURDATA *heurdata, SCIP_Bool *cutoff, SCIP_Bool *allrowsfulfilled)
Definition: heur_locks.c:205
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
SCIP_RETCODE SCIPsetPresolving(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
Definition: scip.c:5132
SCIP_BRANCHRULE * SCIPfindBranchrule(SCIP *scip, const char *name)
Definition: scip.c:9269
#define DEFAULT_MAXPROPROUNDS
Definition: heur_clique.c:69
struct SCIP_HeurData SCIP_HEURDATA
Definition: type_heur.h:51
#define SCIPfreeBlockMemory(scip, ptr)
Definition: scip.h:22602
SCIP_RETCODE SCIPincludeHeurBasic(SCIP *scip, SCIP_HEUR **heur, const char *name, const char *desc, char dispchar, int priority, int freq, int freqofs, int maxdepth, SCIP_HEURTIMING timingmask, SCIP_Bool usessubscip, SCIP_DECL_HEUREXEC((*heurexec)), SCIP_HEURDATA *heurdata)
Definition: scip.c:8084
#define HEUR_FREQOFS
Definition: heur_clique.c:51
#define SCIPdebugMessage
Definition: pub_message.h:77
#define DEFAULT_MAXBACKTRACKS
Definition: heur_clique.c:70
void * SCIPhashmapGetImage(SCIP_HASHMAP *hashmap, void *origin)
Definition: misc.c:2931
SCIP_RETCODE SCIPconstructLP(SCIP *scip, SCIP_Bool *cutoff)
Definition: scip.c:29249
#define SCIP_LONGINT_MAX
Definition: def.h:135
#define SCIPfreeBufferArray(scip, ptr)
Definition: scip.h:22632
enum SCIP_LPSolStat SCIP_LPSOLSTAT
Definition: type_lp.h:42
SCIP_RETCODE SCIPcreate(SCIP **scip)
Definition: scip.c:748
void SCIPheurSetData(SCIP_HEUR *heur, SCIP_HEURDATA *heurdata)
Definition: heur.c:1119
#define SCIPallocBlockMemory(scip, ptr)
Definition: scip.h:22585
#define SCIPdebugPrintCons(x, y, z)
Definition: pub_message.h:83
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
Definition: scip.c:1267
#define SCIPdebugMsg
Definition: scip.h:455
SCIP_RETCODE SCIPaddIntParam(SCIP *scip, const char *name, const char *desc, int *valueptr, SCIP_Bool isadvanced, int defaultvalue, int minvalue, int maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
Definition: scip.c:4265
SCIP_RETCODE SCIPprintStatistics(SCIP *scip, FILE *file)
Definition: scip.c:45651
#define DEFAULT_MINNODES
Definition: heur_clique.c:66
static SCIP_RETCODE createNewSol(SCIP *scip, SCIP *subscip, SCIP_VAR **subvars, SCIP_SOL *newsol, SCIP_SOL *subsol, SCIP_Bool *success)
Definition: heur_clique.c:491
SCIP_Bool SCIPisLPConstructed(SCIP *scip)
Definition: scip.c:29226
#define HEUR_DISPCHAR
Definition: heur_clique.c:48
SCIP_RETCODE SCIPsolve(SCIP *scip)
Definition: scip.c:16115
const char * SCIPheurGetName(SCIP_HEUR *heur)
Definition: heur.c:1198
SCIP_RETCODE SCIPincludeHeurClique(SCIP *scip)
Definition: heur_clique.c:1084
SCIP_Bool SCIPisParamFixed(SCIP *scip, const char *name)
Definition: scip.c:4401
SCIP_RETCODE SCIPsetHeurFree(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURFREE((*heurfree)))
Definition: scip.c:8145
SCIP_RETCODE SCIPpropagateProbing(SCIP *scip, int maxproprounds, SCIP_Bool *cutoff, SCIP_Longint *ndomredsfound)
Definition: scip.c:36314
SCIP_RETCODE SCIPgetSolVals(SCIP *scip, SCIP_SOL *sol, int nvars, SCIP_VAR **vars, SCIP_Real *vals)
Definition: scip.c:38948
SCIP_RETCODE SCIPfixVarProbing(SCIP *scip, SCIP_VAR *var, SCIP_Real fixedval)
Definition: scip.c:36157
Constraint handler for logicor constraints (equivalent to set covering, but algorithms are suited fo...
#define HEUR_USESSUBSCIP
Definition: heur_clique.c:54
#define SCIPfreeBufferArrayNull(scip, ptr)
Definition: scip.h:22633
SCIP_RETCODE SCIPsetBoolParam(SCIP *scip, const char *name, SCIP_Bool value)
Definition: scip.c:4630
SCIP_STATUS SCIPgetStatus(SCIP *scip)
Definition: scip.c:928
SCIP_RETCODE SCIPpresolve(SCIP *scip)
Definition: scip.c:15954
SCIP_RETCODE SCIPcopyCuts(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool global, int *ncutsadded)
Definition: scip.c:3065
BMS_BLKMEM * SCIPblkmem(SCIP *scip)
Definition: scip.c:46731
SCIP_RETCODE SCIPendProbing(SCIP *scip)
Definition: scip.c:35999
const char * SCIPvarGetName(SCIP_VAR *var)
Definition: var.c:16662
void SCIPhashmapFree(SCIP_HASHMAP **hashmap)
Definition: misc.c:2826
SCIP_RETCODE SCIPgetBoolParam(SCIP *scip, const char *name, SCIP_Bool *value)
Definition: scip.c:4432
#define SCIP_Shortbool
Definition: def.h:69
#define DEFAULT_USELOCKFIXINGS
Definition: heur_clique.c:76
#define SCIP_CALL(x)
Definition: def.h:350
SCIP_Real SCIPgetLowerbound(SCIP *scip)
Definition: scip.c:43277
SCIP_RETCODE SCIPsolveProbingLP(SCIP *scip, int itlim, SCIP_Bool *lperror, SCIP_Bool *cutoff)
Definition: scip.c:36550
#define DEFAULT_MINIMPROVE
Definition: heur_clique.c:61
static SCIP_RETCODE applyCliqueFixings(SCIP *scip, SCIP_HEURDATA *heurdata, SCIP_VAR **onefixvars, SCIP_Shortbool *onefixvals, int *nonefixvars, SCIP_Bool *cutoff)
Definition: heur_clique.c:150
SCIP_Longint SCIPheurGetNCalls(SCIP_HEUR *heur)
Definition: heur.c:1324
SCIP_Bool SCIPhasCurrentNodeLP(SCIP *scip)
Definition: scip.c:29208
SCIP_RETCODE SCIPaddConsNode(SCIP *scip, SCIP_NODE *node, SCIP_CONS *cons, SCIP_NODE *validnode)
Definition: scip.c:13146
#define SCIPallocBufferArray(scip, ptr, num)
Definition: scip.h:22620
public data structures and miscellaneous methods
#define DEFAULT_NODESOFS
Definition: heur_clique.c:67
#define SCIP_Bool
Definition: def.h:61
SCIP_LPSOLSTAT SCIPgetLPSolstat(SCIP *scip)
Definition: scip.c:29293
SCIP_RETCODE SCIProundSol(SCIP *scip, SCIP_SOL *sol, SCIP_Bool *success)
Definition: scip.c:40024
SCIP_RETCODE SCIPsetObjlimit(SCIP *scip, SCIP_Real objlimit)
Definition: scip.c:11246
int SCIPgetDepth(SCIP *scip)
Definition: scip.c:43045
SCIP_Bool * SCIPcliqueGetValues(SCIP_CLIQUE *clique)
Definition: implics.c:3365
SCIP_RETCODE SCIPsetIntParam(SCIP *scip, const char *name, int value)
Definition: scip.c:4688
SCIP_RETCODE SCIPfreeSol(SCIP *scip, SCIP_SOL **sol)
Definition: scip.c:38535
void SCIPenableVarHistory(SCIP *scip)
Definition: scip.c:25958
SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
Definition: var.c:17124
int SCIPgetNSols(SCIP *scip)
Definition: scip.c:39783
static SCIP_DECL_SORTINDCOMP(compCliquesSize)
Definition: heur_clique.c:115
SCIP_Real SCIPgetSolOrigObj(SCIP *scip, SCIP_SOL *sol)
Definition: scip.c:38994
SCIP_RETCODE SCIPflushLP(SCIP *scip)
Definition: scip.c:29273
locks primal heuristic
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
Definition: scip.c:47039
SCIP_RETCODE SCIPcreateConsLogicor(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode)
SCIP_RETCODE SCIPtrySol(SCIP *scip, SCIP_SOL *sol, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *stored)
Definition: scip.c:40700
SCIP_NODE * SCIPgetFocusNode(SCIP *scip)
Definition: scip.c:41385
#define SCIP_MAXTREEDEPTH
Definition: def.h:286
int SCIPgetNBinVars(SCIP *scip)
Definition: scip.c:11857
SCIP_Bool SCIPinProbing(SCIP *scip)
Definition: scip.c:35836
int SCIPgetNVars(SCIP *scip)
Definition: scip.c:11812
SCIP_CLIQUE ** SCIPgetCliques(SCIP *scip)
Definition: scip.c:24933
SCIP_Real SCIPgetLPObjval(SCIP *scip)
Definition: scip.c:29372
void SCIPsort(int *perm, SCIP_DECL_SORTINDCOMP((*indcomp)), void *dataptr, int len)
Definition: misc.c:5081
int SCIPgetNConss(SCIP *scip)
Definition: scip.c:12862
SCIP_RETCODE SCIPreleaseCons(SCIP *scip, SCIP_CONS **cons)
Definition: scip.c:27761
#define HEUR_NAME
Definition: heur_clique.c:46
int SCIPgetNCliques(SCIP *scip)
Definition: scip.c:24879
SCIP_RETCODE SCIPsetHeurInit(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURINIT((*heurinit)))
Definition: scip.c:8161
#define SCIP_Real
Definition: def.h:149
SCIP_Bool SCIPisStopped(SCIP *scip)
Definition: scip.c:1145
#define HEUR_PRIORITY
Definition: heur_clique.c:49
#define SCIP_Longint
Definition: def.h:134
SCIP_Bool SCIPallColsInLP(SCIP *scip)
Definition: scip.c:29719
static SCIP_DECL_HEURINIT(heurInitClique)
Definition: heur_clique.c:574
SCIP_RETCODE SCIPcheckCopyLimits(SCIP *sourcescip, SCIP_Bool *success)
Definition: scip.c:4156
#define DEFAULT_COPYCUTS
Definition: heur_clique.c:71
SCIP_RETCODE SCIPsetSolVals(SCIP *scip, SCIP_SOL *sol, int nvars, SCIP_VAR **vars, SCIP_Real *vals)
Definition: scip.c:38813
SCIP_RETCODE SCIPsetHeurCopy(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURCOPY((*heurcopy)))
Definition: scip.c:8129
SCIP_Real SCIPvarGetUbLocal(SCIP_VAR *var)
Definition: var.c:17342
SCIP_RETCODE SCIPnewProbingNode(SCIP *scip)
Definition: scip.c:35904
int SCIPcliqueGetNVars(SCIP_CLIQUE *clique)
Definition: implics.c:3343
SCIP_Real SCIPsumepsilon(SCIP *scip)
Definition: scip.c:46429
SCIP_Real SCIPgetUpperbound(SCIP *scip)
Definition: scip.c:43426
SCIP_RETCODE SCIPstartProbing(SCIP *scip)
Definition: scip.c:35858
#define SCIP_CALL_ABORT(x)
Definition: def.h:329
SCIP_HEURDATA * SCIPheurGetData(SCIP_HEUR *heur)
Definition: heur.c:1109
SCIP_Longint SCIPgetNNodes(SCIP *scip)
Definition: scip.c:42133
static SCIP_DECL_HEURCOPY(heurCopyClique)
Definition: heur_clique.c:539
SCIP_RETCODE SCIPaddRealParam(SCIP *scip, const char *name, const char *desc, SCIP_Real *valueptr, SCIP_Bool isadvanced, SCIP_Real defaultvalue, SCIP_Real minvalue, SCIP_Real maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
Definition: scip.c:4321
SCIP_RETCODE SCIPsetSubscipsOff(SCIP *scip, SCIP_Bool quiet)
Definition: scip.c:5083
SCIP_RETCODE SCIPsetLongintParam(SCIP *scip, const char *name, SCIP_Longint value)
Definition: scip.c:4746
SCIP_RETCODE SCIPgetNegatedVar(SCIP *scip, SCIP_VAR *var, SCIP_VAR **negvar)
Definition: scip.c:19045
SCIP callable library.
SCIP_RETCODE SCIPaddBoolParam(SCIP *scip, const char *name, const char *desc, SCIP_Bool *valueptr, SCIP_Bool isadvanced, SCIP_Bool defaultvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
Definition: scip.c:4239
SCIP_RETCODE SCIPfree(SCIP **scip)
Definition: scip.c:780
SCIP_RETCODE SCIPcreateSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
Definition: scip.c:37878
SCIP_RETCODE SCIPprintSol(SCIP *scip, SCIP_SOL *sol, FILE *file, SCIP_Bool printzeros)
Definition: scip.c:39325