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-2017 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  *
22  * @todo allow smaller fixing rate for probing LP?
23  * @todo allow smaller fixing rate after presolve if total number of variables is small (<= 1000)?
24  *
25  * More details about the heuristic can be found in@n
26  * Structure-Based Primal Heuristics for Mixed Integer Programming@n
27  * Gerald Gamrath, Timo Berthold, Stefan Heinz, and Michael Winkler@n
28  * Optimization in the Real World, Volume 13 of the series Mathematics for Industry, pp 37-53@n
29  * Preliminary version available as <a href="https://opus4.kobv.de/opus4-zib/frontdoor/index/index/docId/5551">ZIB-Report 15-26</a>.
30  */
31 
32 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
33 
34 #include <assert.h>
35 #include <string.h>
36 
37 #include "scip/scip.h"
38 #include "scip/heur_clique.h"
39 #include "scip/cons_logicor.h"
40 #include "scip/pub_misc.h"
41 
42 
43 #define HEUR_NAME "clique"
44 #define HEUR_DESC "LNS heuristic using a clique partition to restrict the search neighborhood"
45 #define HEUR_DISPCHAR 'Q'
46 #define HEUR_PRIORITY -1000500
47 #define HEUR_FREQ -1
48 #define HEUR_FREQOFS 0
49 #define HEUR_MAXDEPTH -1
50 #define HEUR_TIMING SCIP_HEURTIMING_BEFORENODE
51 #define HEUR_USESSUBSCIP TRUE /**< does the heuristic use a secondary SCIP instance? */
52 
53 #define DEFAULT_MAXNODES 5000LL /**< maximum number of nodes to regard in the subproblem */
54 #define DEFAULT_MINFIXINGRATE 0.25 /**< minimum percentage of variables that have to be fixed */
55 #define DEFAULT_MINIMPROVE 0.01 /**< factor by which clique heuristic should at least improve the
56  * incumbent
57  */
58 #define DEFAULT_MINNODES 500LL /**< minimum number of nodes to regard in the subproblem */
59 #define DEFAULT_NODESOFS 500LL /**< number of nodes added to the contingent of the total nodes */
60 #define DEFAULT_NODESQUOT 0.1 /**< subproblem nodes in relation to nodes of the original problem */
61 #define DEFAULT_MAXPROPROUNDS 2 /**< maximum number of propagation rounds during probing */
62 #define DEFAULT_RANDSEED 61 /**< random seed value to initialize the random permutation
63  * value for variables
64  */
65 #define DEFAULT_MULTIPLIER 1.1 /**< value to increase node number to determine the next run */
66 #define DEFAULT_COPYCUTS TRUE /**< should all active cuts from the cutpool of the
67  * original scip be copied to constraints of the subscip
68  */
69 
70 
71 /*
72  * Data structures
73  */
74 
75 /** primal heuristic data */
76 struct SCIP_HeurData
77 {
78  SCIP_RANDNUMGEN* randnumgen; /**< random number generator */
79  SCIP_Longint maxnodes; /**< maximum number of nodes to regard in the subproblem */
80  SCIP_Longint minnodes; /**< minimum number of nodes to regard in the subproblem */
81  SCIP_Longint nodesofs; /**< number of nodes added to the contingent of the total nodes */
82  SCIP_Longint usednodes; /**< nodes already used by clique heuristic in earlier calls */
83  SCIP_Real minfixingrate; /**< minimum percentage of variables that have to be fixed */
84  SCIP_Real minimprove; /**< factor by which clique heuristic should at least improve the incumbent */
85  SCIP_Real nodesquot; /**< subproblem nodes in relation to nodes of the original problem */
86  int maxproprounds; /**< maximum number of propagation rounds during probing */
87  SCIP_Longint nnodefornextrun; /**< node number for next run */
88  SCIP_Real multiplier; /**< multiplier to determine next node number */
89  int initseed; /**< initial random seed value */
90  SCIP_Bool copycuts; /**< should all active cuts from cutpool be copied to constraints in
91  * subproblem?
92  */
93 };
94 
95 /*
96  * Local methods
97  */
98 
99 /** comparison method for sorting variables by non-decreasing index */
100 static
101 SCIP_DECL_SORTPTRCOMP(varObjSort)
102 {
103  SCIP_VAR* var1;
104  SCIP_VAR* var2;
105 
106  assert(elem1 != NULL);
107  assert(elem2 != NULL);
108 
109  var1 = (SCIP_VAR*)elem1;
110  var2 = (SCIP_VAR*)elem2;
111 
112  if( SCIPvarGetObj(var1) < SCIPvarGetObj(var2) )
113  return -1;
114  else if( SCIPvarGetObj(var1) > SCIPvarGetObj(var2) )
115  return +1;
116  else
117  return 0;
118 }
119 
120 /** sort the binary variable array w.r.t. the clique partition; thereby ensure the current order within the cliques are
121  * not changed
122  */
123 static
125  SCIP* scip, /**< SCIP data structure */
126  SCIP_VAR** binvars, /**< array of binary variables to sort */
127  int nbinvars, /**< number of binary variables */
128  int* cliquepartition, /**< clique partition to use */
129  int ncliques /**< number of cliques */
130  )
131 {
132  SCIP_VAR*** varpointers;
133  SCIP_VAR** vars;
134  int* cliquecount;
135  int nextpos;
136  int c;
137  int v;
138  int cliquenumber;
139 
140  assert(scip != NULL);
141  assert(binvars != NULL);
142  assert(cliquepartition != NULL);
143 
144  /* @note: we don't want to loose order from same clique numbers, so we need a stable sorting algorithm, or we first
145  * count all clique items and alloc temporary memory for a bucket sort */
146  /* sort variables after clique-numbers */
147  SCIP_CALL( SCIPallocBufferArray(scip, &cliquecount, ncliques) );
148  BMSclearMemoryArray(cliquecount, ncliques);
149 
150  /* first we count for each clique the number of elements */
151  for( v = nbinvars - 1; v >= 0; --v )
152  {
153  assert(0 <= cliquepartition[v] && cliquepartition[v] < ncliques);
154  ++(cliquecount[cliquepartition[v]]);
155  }
156 
157  SCIP_CALL( SCIPallocBufferArray(scip, &vars, nbinvars) );
158 #ifndef NDEBUG
159  BMSclearMemoryArray(vars, nbinvars);
160 #endif
161  SCIP_CALL( SCIPallocBufferArray(scip, &varpointers, ncliques) );
162 
163  nextpos = 0;
164  /* now we initialize all start pointers for each clique, so they will be ordered */
165  for( c = 0; c < ncliques; ++c )
166  {
167  /* to reach the goal that all variables of each clique will be standing next to each other we will initialize the
168  * starting pointers for each clique by adding the number of each clique to the last clique starting pointer
169  * e.g. clique1 has 4 elements and clique2 has 3 elements the the starting pointer for clique1 will be the pointer
170  * to vars[0], the starting pointer to clique2 will be the pointer to vars[4] and to clique3 it will be
171  * vars[7]
172  *
173  */
174  varpointers[c] = (SCIP_VAR**) (vars + nextpos);
175  assert(cliquecount[c] > 0);
176  nextpos += cliquecount[c];
177  assert(nextpos > 0);
178  }
179  assert(nextpos == nbinvars);
180 
181  /* now we copy all variable to the right order in our temporary variable array */
182  for( v = 0; v < nbinvars; ++v )
183  {
184  *(varpointers[cliquepartition[v]]) = binvars[v];
185  ++(varpointers[cliquepartition[v]]);
186  }
187 #ifndef NDEBUG
188  for( v = 0; v < nbinvars; ++v )
189  assert(vars[v] != NULL);
190 #endif
191 
192  /* move all variables back to our variable array */
193  BMScopyMemoryArray(binvars, vars, nbinvars);
194 
195  cliquenumber = 0;
196  nextpos = cliquecount[0];
197 
198  c = 1;
199  for( v = 0; v < nbinvars; ++v )
200  {
201  if( v == nextpos )
202  {
203  nextpos += cliquecount[c];
204  ++c;
205  ++cliquenumber;
206  }
207  cliquepartition[v] = cliquenumber;
208  }
209  assert(cliquepartition[v - 1] == ncliques - 1);
210 
211 #ifndef NDEBUG
212  for( v = 1; v < nbinvars; ++v )
213  assert(SCIPvarGetObj(binvars[v - 1]) <= SCIPvarGetObj(binvars[v - 1]));
214 #endif
215 
216  /* free temporary memory */
217  SCIPfreeBufferArray(scip, &varpointers);
218  SCIPfreeBufferArray(scip, &vars);
219  SCIPfreeBufferArray(scip, &cliquecount);
220 
221  return SCIP_OKAY;
222 }
223 
224 /** apply clique fixing using probing */
225 static
227  SCIP* scip, /**< original SCIP data structure */
228  SCIP_HEURDATA* heurdata, /**< structure containing heurdata */
229  SCIP_VAR** binvars, /**< binary variables order w.r.t. to clique partition */
230  int nbinvars, /**< number of binary variables */
231  int* cliquepartition, /**< clique partition of all binary variables */
232  int ncliques, /**< number of cliques */
233  SCIP_VAR** onefixvars, /**< array to store all variables which are stored to one */
234  int* nonefixvars, /**< pointer to store the number of variables fixed to one */
235  SCIP_SOL* sol, /**< working solution */
236  int* probingdepthofonefix,/**< pointer to store in which depth the last fixing to was applied */
237  SCIP_Bool* cutoff, /**< pointer to store whether the propagation stopped with infeasibility */
238  SCIP_RESULT* result /**< pointer to store the result (solution found) */
239  )
240 {
241 #if 0
242  SCIP_Bool success;
243 #endif
244  SCIP_Bool alreadyone;
245  SCIP_Bool allfixed;
246  int bestpos;
247  int v;
248  int c;
249 #ifdef SCIP_DEBUG
250  int nsolsround;
251  int nsolstried;
252 #endif
253 
254  assert(scip != NULL);
255  assert(heurdata != NULL);
256  assert(binvars != NULL);
257  assert(onefixvars != NULL);
258  assert(nonefixvars != NULL);
259  assert(sol != NULL);
260  assert(probingdepthofonefix != NULL);
261  assert(cutoff != NULL);
262  assert(result != NULL);
263 
264  *cutoff = FALSE;
265  *probingdepthofonefix = 0;
266 
267 #ifdef SCIP_DEBUG
268  nsolsround = 0;
269  nsolstried = 0;
270 #endif
271  v = 0;
272  /* @todo maybe try to fix more than one variable to one in each probing node, to gain faster results */
273  for( c = 0; c < ncliques; ++c )
274  {
275  alreadyone = FALSE;
276  allfixed = TRUE;
277  bestpos = nbinvars;
278 
279  /* find first unfixed variable in this clique */
280  while( v < nbinvars && cliquepartition[v] == c )
281  {
282  if( SCIPvarGetLbLocal(binvars[v]) > 0.5 )
283  alreadyone = TRUE;
284  else if( allfixed && SCIPvarGetUbLocal(binvars[v]) > 0.5 )
285  {
286  bestpos = v;
287  allfixed = FALSE;
288  }
289 
290  ++v;
291  }
292  if( v == nbinvars && allfixed )
293  break;
294 
295  /* if all clique variables are fixed, continue with the next clique */
296  if( allfixed )
297  continue;
298 
299  assert(bestpos < nbinvars);
300  assert(c == cliquepartition[bestpos]);
301 
302  /* stop if we reached the depth limit */
303  if( SCIP_MAXTREEDEPTH <= SCIPgetDepth(scip) )
304  break;
305 
306  SCIP_CALL( SCIPnewProbingNode(scip) );
307 
308  v = bestpos;
309  if( !alreadyone )
310  {
311  *probingdepthofonefix = SCIPgetProbingDepth(scip);
312  onefixvars[(*nonefixvars)] = binvars[v];
313  ++(*nonefixvars);
314 
315  /* fix best possible clique variable to 1 */
316  SCIP_CALL( SCIPfixVarProbing(scip, binvars[v], 1.0) );
317  SCIPdebugMsg(scip, "probing: fixing variable <%s> to 1\n", SCIPvarGetName(binvars[v]));
318 
319  ++v;
320  }
321 
322  /* fix rest of unfixed clique variables to 0 */
323  while( v < nbinvars && cliquepartition[v] == c )
324  {
325  if( SCIPvarGetUbLocal(binvars[v]) > 0.5 && SCIPvarGetLbLocal(binvars[v]) < 0.5 )
326  {
327  SCIP_CALL( SCIPfixVarProbing(scip, binvars[v], 0.0) );
328  SCIPdebugMsg(scip, "probing: fixing variable <%s> to 0\n", SCIPvarGetName(binvars[v]));
329  }
330  ++v;
331  }
332 
333  /* propagate fixings */
334  SCIP_CALL( SCIPpropagateProbing(scip, heurdata->maxproprounds, cutoff, NULL) );
335 
336  if( *cutoff )
337  break;
338 
339  /* @todo need to be check if it's ok to always try to round and check the solution in each probing step */
340 #if 0
341 
342 #ifdef SCIP_DEBUG
343  ++nsolsround;
344 #endif
345  /* create solution from probing run and try to round it */
346  SCIP_CALL( SCIPlinkCurrentSol(scip, sol) );
347  SCIP_CALL( SCIProundSol(scip, sol, &success) );
348 
349  if( success )
350  {
351  SCIPdebugMsg(scip, "clique heuristic found roundable primal solution: obj=%g\n", SCIPgetSolOrigObj(scip, sol));
352 
353 #ifdef SCIP_DEBUG
354  ++nsolstried;
355 #endif
356  /* try to add solution to SCIP */
357  SCIP_CALL( SCIPtrySol(scip, sol, FALSE, FALSE, FALSE, TRUE, &success) );
358 
359  /* check, if solution was feasible and good enough */
360  if( success )
361  {
362  SCIPdebugMsg(scip, " -> solution was feasible and good enough\n");
363  *result = SCIP_FOUNDSOL;
364  }
365  }
366 #endif
367 
368  if( SCIPisStopped(scip) )
369  return SCIP_OKAY;
370 
371 #if 0
372  /* if the rest of all variables are in cliques with one variable stop */
373  if( nbinvars - v == ncliques - c )
374  break;
375 #endif
376  }
377  assert((*probingdepthofonefix > 0 && *nonefixvars > 0) || (*probingdepthofonefix == 0 && *nonefixvars == 0));
378  assert(*cutoff || (nbinvars - v == ncliques - c) || (v == nbinvars && (c == ncliques || c == ncliques - 1)));
379 
380  SCIPdebugMsg(scip, "fixed %d of %d variables in probing\n", v, nbinvars);
381  SCIPdebugMsg(scip, "applied %d of %d cliques in probing\n", c, ncliques);
382  SCIPdebugMsg(scip, "probing was %sfeasible\n", (*cutoff) ? "in" : "");
383 #ifdef SCIP_DEBUG
384  SCIPdebugMsg(scip, "clique heuristic rounded %d solutions and tried %d of them\n", nsolsround, nsolstried);
385 #endif
386  return SCIP_OKAY;
387 }
388 
389 /** creates a new solution for the original problem by copying the solution of the subproblem */
390 static
392  SCIP* scip, /**< original SCIP data structure */
393  SCIP* subscip, /**< SCIP structure of the subproblem */
394  SCIP_VAR** subvars, /**< the variables of the subproblem */
395  SCIP_SOL* newsol, /**< working solution */
396  SCIP_SOL* subsol, /**< solution of the subproblem */
397  SCIP_Bool* success /**< used to store whether new solution was found or not */
398  )
399 {
400  SCIP_VAR** vars; /* the original problem's variables */
401  int nvars;
402  SCIP_Real* subsolvals; /* solution values of the subproblem */
403 
404  assert(scip != NULL);
405  assert(subscip != NULL);
406  assert(subvars != NULL);
407  assert(subsol != NULL);
408  assert(success != NULL);
409 
410  /* get variables' data */
411  SCIP_CALL( SCIPgetVarsData(scip, &vars, &nvars, NULL, NULL, NULL, NULL) );
412 
413  /* sub-SCIP may have more variables than the number of active (transformed) variables in the main SCIP
414  * since constraint copying may have required the copy of variables that are fixed in the main SCIP
415  */
416  assert(nvars <= SCIPgetNOrigVars(subscip));
417 
418  SCIP_CALL( SCIPallocBufferArray(scip, &subsolvals, nvars) );
419 
420  /* copy the solution */
421  SCIP_CALL( SCIPgetSolVals(subscip, subsol, nvars, subvars, subsolvals) );
422 
423  SCIP_CALL( SCIPsetSolVals(scip, newsol, nvars, vars, subsolvals) );
424 
425  /* try to add new solution to scip and free it immediately */
426  SCIP_CALL( SCIPtrySol(scip, newsol, FALSE, FALSE, TRUE, TRUE, TRUE, success) );
427 
428  SCIPfreeBufferArray(scip, &subsolvals);
429 
430  return SCIP_OKAY;
431 }
432 
433 /*
434  * Callback methods of primal heuristic
435  */
436 
437 /** copy method for primal heuristic plugins (called when SCIP copies plugins) */
438 static
439 SCIP_DECL_HEURCOPY(heurCopyClique)
440 { /*lint --e{715}*/
441  assert(scip != NULL);
442  assert(heur != NULL);
443  assert(strcmp(SCIPheurGetName(heur), HEUR_NAME) == 0);
444 
445  /* call inclusion method of primal heuristic */
447 
448  return SCIP_OKAY;
449 }
450 
451 /** destructor of primal heuristic to free user data (called when SCIP is exiting) */
452 static
453 SCIP_DECL_HEURFREE(heurFreeClique)
454 { /*lint --e{715}*/
455  SCIP_HEURDATA* heurdata;
456 
457  assert(heur != NULL);
458  assert(strcmp(SCIPheurGetName(heur), HEUR_NAME) == 0);
459  assert(scip != NULL);
460 
461  /* free heuristic data */
462  heurdata = SCIPheurGetData(heur);
463  assert(heurdata != NULL);
464 
465  SCIPfreeBlockMemory(scip, &heurdata);
466  SCIPheurSetData(heur, NULL);
467 
468  return SCIP_OKAY;
469 }
470 
471 
472 /** initialization method of primal heuristic (called after problem was transformed) */
473 static
474 SCIP_DECL_HEURINIT(heurInitClique)
475 { /*lint --e{715}*/
476  SCIP_HEURDATA* heurdata;
477 
478  assert(heur != NULL);
479  assert(strcmp(SCIPheurGetName(heur), HEUR_NAME) == 0);
480  assert(scip != NULL);
481 
482  /* reset heuristic data */
483  heurdata = SCIPheurGetData(heur);
484  assert(heurdata != NULL);
485 
486  /* create random number generator */
487  SCIP_CALL( SCIPrandomCreate(&heurdata->randnumgen, SCIPblkmem(scip),
488  SCIPinitializeRandomSeed(scip, heurdata->initseed)) );
489 
490  heurdata->usednodes = 0;
491 
492  return SCIP_OKAY;
493 }
494 
495 
496 /** deinitialization method of primal heuristic */
497 static
498 SCIP_DECL_HEUREXIT(heurExitClique)
499 { /*lint --e{715}*/
500  SCIP_HEURDATA* heurdata;
501 
502  assert(heur != NULL);
503  assert(strcmp(SCIPheurGetName(heur), HEUR_NAME) == 0);
504  assert(scip != NULL);
505 
506  /* get heuristic data */
507  heurdata = SCIPheurGetData(heur);
508  assert(heurdata != NULL);
509 
510  /* free random number generator */
511  SCIPrandomFree(&heurdata->randnumgen);
512 
513  return SCIP_OKAY;
514 }
515 
516 
517 /** execution method of primal heuristic */
518 static
519 SCIP_DECL_HEUREXEC(heurExecClique)
520 { /*lint --e{715}*/
521  SCIP_HEURDATA* heurdata;
522  SCIP_VAR** vars;
523  int nvars;
524  SCIP_VAR** binvars;
525  int nbinvars;
526  int* cliquepartition;
527  int ncliques;
528  int oldnpscands;
529  int npscands;
530  int i;
531 #if 0
532  SCIP_Longint tmpnnodes;
533 #endif
534  SCIP_Bool cutoff;
535  SCIP_Bool backtrackcutoff;
536  SCIP_Bool lperror;
537 
538  int probingdepthofonefix;
539  SCIP_VAR** onefixvars;
540  int nonefixvars;
541  SCIP_Bool enabledconflicts;
542  SCIP_LPSOLSTAT lpstatus;
543  SCIP_CONS* conflictcons;
544  SCIP_Bool shortconflict;
545  SCIP_Bool allfixsolfound;
546  SCIP_Bool backtracked;
547  SCIP_Bool solvelp;
548  char consname[SCIP_MAXSTRLEN];
549 
550  SCIP_Longint nstallnodes; /* number of stalling nodes for the subproblem */
551 
552  SCIP_SOL* sol;
553 
554  assert(heur != NULL);
555  assert(strcmp(SCIPheurGetName(heur), HEUR_NAME) == 0);
556  assert(scip != NULL);
557  assert(result != NULL);
558 
559  *result = SCIP_DIDNOTRUN;
560 
561  /* get heuristic's data */
562  heurdata = SCIPheurGetData(heur);
563  assert(heurdata != NULL);
564 
565 #if 0
566  if( heurdata->nnodefornextrun != SCIPgetNNodes(scip) )
567  return SCIP_OKAY;
568 #endif
569  /* get all binary variables */
570  SCIP_CALL( SCIPgetVarsData(scip, &vars, &nvars, &nbinvars, NULL, NULL, NULL) );
571 
572  if( nbinvars < 2 )
573  {
574  heurdata->nnodefornextrun = INT_MAX;
575  return SCIP_OKAY;
576  }
577 
578  /* check for necessary information to apply this heuristic */
579  if( SCIPgetNCliques(scip) == 0 )
580  {
581  heurdata->nnodefornextrun = INT_MAX;
582  return SCIP_OKAY;
583  }
584 
585  /* calculate the maximal number of branching nodes until heuristic is aborted */
586  nstallnodes = (SCIP_Longint)(heurdata->nodesquot * SCIPgetNNodes(scip));
587 
588  /* reward variable bounds heuristic if it succeeded often */
589  nstallnodes = (SCIP_Longint)(nstallnodes * 3.0 * (SCIPheurGetNBestSolsFound(heur)+1.0)/(SCIPheurGetNCalls(heur) + 1.0));
590  nstallnodes -= 100 * SCIPheurGetNCalls(heur); /* count the setup costs for the sub-MIP as 100 nodes */
591  nstallnodes += heurdata->nodesofs;
592 
593  /* determine the node limit for the current process */
594  nstallnodes -= heurdata->usednodes;
595  nstallnodes = MIN(nstallnodes, heurdata->maxnodes);
596 
597  /* check whether we have enough nodes left to call subproblem solving */
598  if( nstallnodes < heurdata->minnodes )
599  {
600  SCIPdebugMsg(scip, "skipping " HEUR_NAME ": nstallnodes=%" SCIP_LONGINT_FORMAT ", minnodes=%" SCIP_LONGINT_FORMAT "\n", nstallnodes, heurdata->minnodes);
601  return SCIP_OKAY;
602  }
603 
604  oldnpscands = SCIPgetNPseudoBranchCands(scip);
605  onefixvars = NULL;
606  sol = NULL;
607 
608  /* allocate memory */
609  SCIP_CALL( SCIPduplicateBufferArray(scip, &binvars, vars, nbinvars) );
610  SCIP_CALL( SCIPallocBufferArray(scip, &cliquepartition, nbinvars) );
611 
612 #if 1
613  /* @todo change sorting after some attempts to random variable order */
614  if( SCIPgetNNodes(scip) == 1 )
615  {
616  /* sort variables after increasing objective value */
617  SCIPsortPtr((void**)binvars, varObjSort, nbinvars);
618  }
619  else
620  {
621  SCIPrandomPermuteArray(heurdata->randnumgen, (void**)binvars, 0, nbinvars);
622  }
623 #endif
624 
625  /* get clique partitions */
626  SCIP_CALL( SCIPcalcCliquePartition(scip, binvars, nbinvars, cliquepartition, &ncliques) );
627  /* @todo get negated clique partition and use this too, or maybe mix both */
628 
629  SCIPdebugMsg(scip, "found %d cliques\n", ncliques);
630 
631  /* disable conflict analysis, because we can it better than SCIP itself, cause we have more information */
632  SCIP_CALL( SCIPgetBoolParam(scip, "conflict/enable", &enabledconflicts) );
633 
634  if( !SCIPisParamFixed(scip, "conflict/enable") )
635  {
636  SCIP_CALL( SCIPsetBoolParam(scip, "conflict/enable", FALSE) );
637  }
638 
639  if( ncliques == nbinvars )
640  {
641  heurdata->nnodefornextrun = INT_MAX;
642  goto TERMINATE;
643  }
644 
645  /* sort the cliques together by respecting the current order (which is w.r.t. the objective coefficients */
646  SCIP_CALL( stableSortBinvars(scip, binvars, nbinvars, cliquepartition, ncliques) );
647 
648  for( i = nbinvars - 1; i >= 0; --i )
649  {
650  if( cliquepartition[i] != ncliques - nbinvars + i )
651  {
652  assert(cliquepartition[i] > ncliques - nbinvars + i);
653  break;
654  }
655  }
656 
657  if( i + 2 < heurdata->minfixingrate * nbinvars )
658  {
659  SCIPdebugMsg(scip, "--> too few variables in nontrivial cliques\n");
660 
661  goto TERMINATE;
662  }
663 
664 
665  solvelp = SCIPhasCurrentNodeLP(scip);
666 
667  if( !SCIPisLPConstructed(scip) && solvelp )
668  {
669  SCIP_CALL( SCIPconstructLP(scip, &cutoff) );
670 
671  /* manually cut off the node if the LP construction detected infeasibility (heuristics cannot return such a result) */
672  if( cutoff )
673  {
675  goto TERMINATE;
676  }
677 
679  }
680 
681  *result = SCIP_DIDNOTFIND;
682 
683  /* start probing */
685 
686  /* create a solution */
687  SCIP_CALL( SCIPcreateSol(scip, &sol, heur) );
688 
689  /* allocate memory for all variables which will be fixed to one during probing */
690  SCIP_CALL(SCIPallocBufferArray(scip, &onefixvars, ncliques) );
691  nonefixvars = 0;
692 
693  /* apply fixings due to clique information */
694  SCIP_CALL( applyCliqueFixings(scip, heurdata, binvars, nbinvars, cliquepartition, ncliques, onefixvars, &nonefixvars, sol, &probingdepthofonefix, &cutoff, result) );
695 
696  if( SCIPisStopped(scip) )
697  goto TERMINATE;
698 
699  backtrackcutoff = FALSE;
700  backtracked = FALSE;
701 
702  /* try to repair probing */
703  if( cutoff && nonefixvars > 0)
704  {
705  assert(probingdepthofonefix > 0);
706 
707  SCIP_CALL( SCIPbacktrackProbing(scip, probingdepthofonefix - 1) );
708 
709  /* fix the last variable, which was fixed to 1 and led to the cutoff, to 0 */
710  SCIP_CALL( SCIPfixVarProbing(scip, onefixvars[nonefixvars - 1], 0.0) );
711 
712  backtracked = TRUE;
713 
714  /* propagate fixings */
715  SCIP_CALL( SCIPpropagateProbing(scip, heurdata->maxproprounds, &backtrackcutoff, NULL) );
716 
717  SCIPdebugMsg(scip, "backtrack was %sfeasible\n", (backtrackcutoff ? "in" : ""));
718  }
719 
720  /* check that we had enough fixings */
721  npscands = SCIPgetNPseudoBranchCands(scip);
722 
723  SCIPdebugMsg(scip, "npscands=%d, oldnpscands=%d, heurdata->minfixingrate=%g\n", npscands, oldnpscands, heurdata->minfixingrate);
724 
725  if( npscands > oldnpscands * (1 - heurdata->minfixingrate) )
726  {
727  SCIPdebugMsg(scip, "--> too few fixings\n");
728 
729  goto TERMINATE;
730  }
731 
732  /*************************** Probing LP Solving ***************************/
733 
734  lpstatus = SCIP_LPSOLSTAT_ERROR;
735  lperror = FALSE;
736  allfixsolfound = FALSE;
737  /* solve lp only if the problem is still feasible */
738  if( !backtrackcutoff && solvelp )
739  {
740 #if 1
741  SCIPdebugMsg(scip, "starting solving clique-lp at time %g\n", SCIPgetSolvingTime(scip));
742 
743  /* solve LP; errors in the LP solver should not kill the overall solving process, if the LP is just needed for a
744  * heuristic. hence in optimized mode, the return code is caught and a warning is printed, only in debug mode,
745  * SCIP will stop.
746  */
747 #ifdef NDEBUG
748  {
749  SCIP_Bool retstat;
750  retstat = SCIPsolveProbingLP(scip, -1, &lperror, NULL);
751  if( retstat != SCIP_OKAY )
752  {
753  SCIPwarningMessage(scip, "Error while solving LP in clique heuristic; LP solve terminated with code <%d>\n",
754  retstat);
755  }
756  }
757 #else
758  SCIP_CALL( SCIPsolveProbingLP(scip, -1, &lperror, NULL) );
759 #endif
760  SCIPdebugMsg(scip, "ending solving clique-lp at time %g\n", SCIPgetSolvingTime(scip));
761 
762  lpstatus = SCIPgetLPSolstat(scip);
763 
764  SCIPdebugMsg(scip, " -> new LP iterations: %" SCIP_LONGINT_FORMAT "\n", SCIPgetNLPIterations(scip));
765  SCIPdebugMsg(scip, " -> error=%u, status=%d\n", lperror, lpstatus);
766  }
767 
768  /* check if this is a feasible solution */
769  if( lpstatus == SCIP_LPSOLSTAT_OPTIMAL && !lperror )
770  {
771  SCIP_Bool stored;
772  SCIP_Bool success;
773 
774  /* copy the current LP solution to the working solution */
775  SCIP_CALL( SCIPlinkLPSol(scip, sol) );
776 
777  SCIP_CALL( SCIProundSol(scip, sol, &success) );
778 
779  if( success )
780  {
781  SCIPdebugMsg(scip, "clique heuristic found roundable primal solution: obj=%g\n",
782  SCIPgetSolOrigObj(scip, sol));
783 
784  /* check solution for feasibility, and add it to solution store if possible.
785  * Neither integrality nor feasibility of LP rows have to be checked, because they
786  * are guaranteed by the heuristic at this stage.
787  */
788 #ifdef SCIP_DEBUG
789  SCIP_CALL( SCIPtrySol(scip, sol, TRUE, TRUE, TRUE, TRUE, TRUE, &stored) );
790 #else
791  SCIP_CALL( SCIPtrySol(scip, sol, FALSE, FALSE, TRUE, FALSE, FALSE, &stored) );
792 #endif
793  allfixsolfound = TRUE;
794 
795  if( stored )
796  {
797  SCIPdebugMsg(scip, "found feasible solution:\n");
799  *result = SCIP_FOUNDSOL;
800  }
801  }
802  }
803 #endif
804 
805  /*************************** END Probing LP Solving ***************************/
806  /*************************** Create Conflict ***************************/
807 
808  if( lpstatus == SCIP_LPSOLSTAT_INFEASIBLE || lpstatus == SCIP_LPSOLSTAT_OBJLIMIT || backtrackcutoff )
809  {
810  /* in case the last fixing in both direction led to infeasibility or to a reached objlimit than our conflict will
811  * only include all variable before that last fixing
812  */
813  shortconflict = cutoff && (nonefixvars > 0);
814 
815  /* create own conflict */
816  (void) SCIPsnprintf(consname, SCIP_MAXSTRLEN, "conf%" SCIP_LONGINT_FORMAT "", SCIPgetNNodes(scip));
817 
818  /* get negated variables for our conflict */
819  SCIP_CALL( SCIPgetNegatedVars(scip, nonefixvars, onefixvars, onefixvars) );
820 
821  /* create conflict constraint */
822  SCIP_CALL( SCIPcreateConsLogicor(scip, &conflictcons, consname, (shortconflict ? nonefixvars - 1 : nonefixvars), onefixvars,
825  SCIPdebugPrintCons(scip, conflictcons, NULL);
826  SCIP_CALL( SCIPreleaseCons(scip, &conflictcons) );
827 
828  goto TERMINATE;
829  }
830 
831  /*************************** End Conflict ***************************/
832 
833  /*************************** Start Subscip Solving ***************************/
834 
835  /* if no solution has been found yet and the subproblem is still feasible --> fix all other variables by subscip if
836  * necessary
837  */
838  if( !allfixsolfound && !lperror )
839  {
840  SCIP* subscip;
841  SCIP_VAR** subvars;
842  SCIP_HASHMAP* varmap;
843  SCIP_Bool valid;
844 
845  /* check whether there is enough time and memory left */
846  SCIP_CALL( SCIPcheckCopyLimits(scip, &valid) );
847 
848  if( !valid )
849  goto TERMINATE;
850 
851  /* get all variables again because SCIPconstructLP() might have changed the variables array */
852  SCIP_CALL( SCIPgetVarsData(scip, &vars, &nvars, NULL, NULL, NULL, NULL) );
853 
854  /* create subproblem */
855  SCIP_CALL( SCIPcreate(&subscip) );
856 
857  /* allocate temporary memory for subscip variables */
858  SCIP_CALL( SCIPallocBufferArray(scip, &subvars, nvars) );
859 
860  /* create the variable mapping hash map */
861  SCIP_CALL( SCIPhashmapCreate(&varmap, SCIPblkmem(subscip), nvars) );
862 
863  SCIP_CALL( SCIPcopyConsCompression(scip, subscip, varmap, NULL, "_clique", NULL, NULL, 0, FALSE, FALSE, TRUE, &valid) );
864 
865  if( heurdata->copycuts )
866  {
867  /* copies all active cuts from cutpool of sourcescip to linear constraints in targetscip */
868  SCIP_CALL( SCIPcopyCuts(scip, subscip, varmap, NULL, FALSE, NULL) );
869  }
870 
871  for( i = 0; i < nvars; i++ )
872  subvars[i] = (SCIP_VAR*) SCIPhashmapGetImage(varmap, vars[i]);
873 
874  /* free hash map */
875  SCIPhashmapFree(&varmap);
876 
877  /* do not abort subproblem on CTRL-C */
878  SCIP_CALL( SCIPsetBoolParam(subscip, "misc/catchctrlc", FALSE) );
879 
880 #ifdef SCIP_DEBUG
881  /* for debugging, enable full output */
882  SCIP_CALL( SCIPsetIntParam(subscip, "display/verblevel", 5) );
883  SCIP_CALL( SCIPsetIntParam(subscip, "display/freq", 100000000) );
884 #else
885  /* disable statistic timing inside sub SCIP and output to console */
886  SCIP_CALL( SCIPsetIntParam(subscip, "display/verblevel", 0) );
887  SCIP_CALL( SCIPsetBoolParam(subscip, "timing/statistictiming", FALSE) );
888 #endif
889 
890  /* set limits for the subproblem */
891  SCIP_CALL( SCIPcopyLimits(scip, subscip) );
892  SCIP_CALL( SCIPsetLongintParam(subscip, "limits/stallnodes", nstallnodes) );
893  SCIP_CALL( SCIPsetLongintParam(subscip, "limits/nodes", heurdata->maxnodes) );
894 
895  /* speed up sub-SCIP by not checking dual LP feasibility */
896  SCIP_CALL( SCIPsetBoolParam(subscip, "lp/checkdualfeas", FALSE) );
897 
898  /* forbid call of heuristics and separators solving sub-CIPs */
899  SCIP_CALL( SCIPsetSubscipsOff(subscip, TRUE) );
900 
901  /* disable cutting plane separation */
903 
904  /* disable expensive presolving */
906 
907  /* use inference branching */
908  if( SCIPfindBranchrule(subscip, "inference") != NULL && !SCIPisParamFixed(subscip, "branching/inference/priority") )
909  {
910  SCIP_CALL( SCIPsetIntParam(subscip, "branching/inference/priority", INT_MAX/4) );
911  }
912 
913  /* employ a limit on the number of enforcement rounds in the quadratic constraint handler; this fixes the issue that
914  * sometimes the quadratic constraint handler needs hundreds or thousands of enforcement rounds to determine the
915  * feasibility status of a single node without fractional branching candidates by separation (namely for uflquad
916  * instances); however, the solution status of the sub-SCIP might get corrupted by this; hence no deductions shall be
917  * made for the original SCIP
918  */
919  if( SCIPfindConshdlr(subscip, "quadratic") != NULL && !SCIPisParamFixed(subscip, "constraints/quadratic/enfolplimit") )
920  {
921  SCIP_CALL( SCIPsetIntParam(subscip, "constraints/quadratic/enfolplimit", 10) );
922  }
923 
924  /* if there is already a solution, add an objective cutoff */
925  if( SCIPgetNSols(scip) > 0 )
926  {
927  SCIP_Real upperbound;
928  SCIP_Real minimprove;
929  SCIP_Real cutoffbound;
930 
931  minimprove = heurdata->minimprove;
933 
934  upperbound = SCIPgetUpperbound(scip) - SCIPsumepsilon(scip);
935 
936  if( !SCIPisInfinity(scip, -1.0 * SCIPgetLowerbound(scip)) )
937  {
938  cutoffbound = (1-minimprove) * SCIPgetUpperbound(scip) + minimprove * SCIPgetLowerbound(scip);
939  }
940  else
941  {
942  if( SCIPgetUpperbound ( scip ) >= 0 )
943  cutoffbound = (1 - minimprove) * SCIPgetUpperbound(scip);
944  else
945  cutoffbound = (1 + minimprove) * SCIPgetUpperbound(scip);
946  }
947  cutoffbound = MIN(upperbound, cutoffbound);
948  SCIP_CALL( SCIPsetObjlimit(subscip, cutoffbound) );
949  SCIPdebugMsg(scip, "setting objlimit for subscip to %g\n", cutoffbound);
950  }
951 
952  SCIPdebugMsg(scip, "starting solving clique-submip at time %g\n", SCIPgetSolvingTime(scip));
953 
954  /* solve the subproblem */
955  /* Errors in the LP solver should not kill the overall solving process, if the LP is just needed for a heuristic.
956  * Hence in optimized mode, the return code is caught and a warning is printed, only in debug mode, SCIP will stop.
957  */
958  SCIP_CALL_ABORT( SCIPpresolve(subscip) );
959 
960  SCIPdebugMsg(scip, "clique heuristic presolved subproblem: %d vars, %d cons; fixing value = %g\n", SCIPgetNVars(subscip), SCIPgetNConss(subscip), ((nvars - SCIPgetNVars(subscip)) / (SCIP_Real)nvars));
961 
962  /* after presolving, we should have at least reached a certain fixing rate over ALL variables (including continuous)
963  * to ensure that not only the MIP but also the LP relaxation is easy enough
964  */
965  if( ((nvars - SCIPgetNVars(subscip)) / (SCIP_Real)nvars) >= heurdata->minfixingrate )
966  {
967  SCIP_SOL** subsols;
968  SCIP_Bool success;
969  int nsubsols;
970 
971  SCIPdebugMsg(scip, "solving subproblem: nstallnodes=%" SCIP_LONGINT_FORMAT ", maxnodes=%" SCIP_LONGINT_FORMAT "\n", nstallnodes, heurdata->maxnodes);
972 
973  SCIP_CALL_ABORT( SCIPsolve(subscip) );
974 
975  SCIPdebugMsg(scip, "ending solving clique-submip at time %g, status = %d\n", SCIPgetSolvingTime(scip), SCIPgetStatus(subscip));
976 
977  /* check, whether a solution was found; due to numerics, it might happen that not all solutions are feasible ->
978  * try all solutions until one was accepted
979  */
980  nsubsols = SCIPgetNSols(subscip);
981  subsols = SCIPgetSols(subscip);
982  success = FALSE;
983 
984  for( i = 0; i < nsubsols && !success; ++i )
985  {
986  SCIP_CALL( createNewSol(scip, subscip, subvars, sol, subsols[i], &success) );
987  }
988  if( success )
989  *result = SCIP_FOUNDSOL;
990 
991  /* if subscip was infeasible we can add a conflict too */
992  if( SCIPgetStatus(subscip) == SCIP_STATUS_INFEASIBLE )
993  {
994  /* in case the last fixing in both direction led to infeasibility or to a reached objlimit than our conflict will only include all variable before that last fixing */
995  shortconflict = backtracked;
996 
997  /* create own conflict */
998  (void) SCIPsnprintf(consname, SCIP_MAXSTRLEN, "conf%" SCIP_LONGINT_FORMAT "", SCIPgetNNodes(scip));
999 
1000  /* get negated variables for our conflict */
1001  SCIP_CALL( SCIPgetNegatedVars(scip, nonefixvars, onefixvars, onefixvars) );
1002 
1003  /* create conflict constraint */
1004  SCIP_CALL( SCIPcreateConsLogicor(scip, &conflictcons, consname, (shortconflict ? nonefixvars - 1 : nonefixvars), onefixvars,
1005  FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE) );
1007  SCIPdebugPrintCons(scip, conflictcons, NULL);
1008  SCIP_CALL( SCIPreleaseCons(scip, &conflictcons) );
1009  }
1010 
1011  }
1012 
1013 #ifdef SCIP_DEBUG
1014  SCIP_CALL( SCIPprintStatistics(subscip, NULL) );
1015 #endif
1016 
1017  /* free subproblem */
1018  SCIPfreeBufferArray(scip, &subvars);
1019  SCIP_CALL( SCIPfree(&subscip) );
1020  }
1021 
1022  /*************************** End Subscip Solving ***************************/
1023 
1024  TERMINATE:
1025 
1026  /* reset the conflict analysis */
1027  if( !SCIPisParamFixed(scip, "conflict/enable") )
1028  {
1029  SCIP_CALL( SCIPsetBoolParam(scip, "conflict/enable", enabledconflicts) );
1030  }
1031 
1032  /* free conflict variables */
1033  if( onefixvars != NULL )
1034  SCIPfreeBufferArray(scip, &onefixvars);
1035 
1036  /* freeing solution */
1037  if( sol != NULL )
1038  {
1039  SCIP_CALL( SCIPfreeSol(scip, &sol) );
1040  }
1041 
1042  /* end probing */
1043  if( SCIPinProbing(scip) )
1044  {
1046  }
1047 
1048  SCIPfreeBufferArray(scip, &cliquepartition);
1049  SCIPfreeBufferArray(scip, &binvars);
1050 
1051 #if 0
1052  /* calculate next node number to run this heuristic */
1053  tmpnnodes = (SCIP_Longint) SCIPceil(scip, heurdata->nnodefornextrun * heurdata->multiplier);
1054  heurdata->nnodefornextrun = MIN(tmpnnodes, INT_MAX);
1055  SCIPdebugMsg(scip, "Next run will be at node %" SCIP_LONGINT_FORMAT ".\n", heurdata->nnodefornextrun);
1056 #endif
1057  return SCIP_OKAY;
1058 }
1059 
1060 /*
1061  * primal heuristic specific interface methods
1062  */
1063 
1064 /** creates the clique primal heuristic and includes it in SCIP */
1066  SCIP* scip /**< SCIP data structure */
1067  )
1068 {
1069  SCIP_HEURDATA* heurdata;
1070  SCIP_HEUR* heur;
1072  /* create clique primal heuristic data */
1073  SCIP_CALL( SCIPallocBlockMemory(scip, &heurdata) );
1074 
1075  /* include primal heuristic */
1076  SCIP_CALL( SCIPincludeHeurBasic(scip, &heur,
1078  HEUR_MAXDEPTH, HEUR_TIMING, HEUR_USESSUBSCIP, heurExecClique, heurdata) );
1079 
1080  assert(heur != NULL);
1081 
1082  /* set non-NULL pointers to callback methods */
1083  SCIP_CALL( SCIPsetHeurCopy(scip, heur, heurCopyClique) );
1084  SCIP_CALL( SCIPsetHeurFree(scip, heur, heurFreeClique) );
1085  SCIP_CALL( SCIPsetHeurInit(scip, heur, heurInitClique) );
1086  SCIP_CALL( SCIPsetHeurExit(scip, heur, heurExitClique) );
1087 
1088  /* add clique primal heuristic parameters */
1089 
1090  SCIP_CALL( SCIPaddRealParam(scip, "heuristics/" HEUR_NAME "/multiplier",
1091  "value to increase nodenumber to determine the next run",
1092  &heurdata->multiplier, TRUE, DEFAULT_MULTIPLIER, 0.0, SCIP_REAL_MAX, NULL, NULL) );
1093 
1094  SCIP_CALL( SCIPaddIntParam(scip, "heuristics/" HEUR_NAME "/initseed",
1095  "initial random seed value to permutate variables",
1096  &(heurdata->initseed), TRUE, DEFAULT_RANDSEED, 1, INT_MAX, NULL, NULL) );
1097 
1098  SCIP_CALL( SCIPaddRealParam(scip, "heuristics/" HEUR_NAME "/minfixingrate",
1099  "minimum percentage of integer variables that have to be fixable",
1100  &heurdata->minfixingrate, FALSE, DEFAULT_MINFIXINGRATE, 0.0, 1.0, NULL, NULL) );
1101 
1102  SCIP_CALL( SCIPaddLongintParam(scip, "heuristics/" HEUR_NAME "/maxnodes",
1103  "maximum number of nodes to regard in the subproblem",
1104  &heurdata->maxnodes, TRUE, DEFAULT_MAXNODES, 0LL, SCIP_LONGINT_MAX, NULL, NULL) );
1105 
1106  SCIP_CALL( SCIPaddLongintParam(scip, "heuristics/" HEUR_NAME "/nodesofs",
1107  "number of nodes added to the contingent of the total nodes",
1108  &heurdata->nodesofs, FALSE, DEFAULT_NODESOFS, 0LL, SCIP_LONGINT_MAX, NULL, NULL) );
1109 
1110  SCIP_CALL( SCIPaddLongintParam(scip, "heuristics/" HEUR_NAME "/minnodes",
1111  "minimum number of nodes required to start the subproblem",
1112  &heurdata->minnodes, TRUE, DEFAULT_MINNODES, 0LL, SCIP_LONGINT_MAX, NULL, NULL) );
1113 
1114  SCIP_CALL( SCIPaddRealParam(scip, "heuristics/" HEUR_NAME "/nodesquot",
1115  "contingent of sub problem nodes in relation to the number of nodes of the original problem",
1116  &heurdata->nodesquot, FALSE, DEFAULT_NODESQUOT, 0.0, 1.0, NULL, NULL) );
1117 
1118  SCIP_CALL( SCIPaddRealParam(scip, "heuristics/" HEUR_NAME "/minimprove",
1119  "factor by which " HEUR_NAME " heuristic should at least improve the incumbent",
1120  &heurdata->minimprove, TRUE, DEFAULT_MINIMPROVE, 0.0, 1.0, NULL, NULL) );
1121 
1122  SCIP_CALL( SCIPaddIntParam(scip, "heuristics/" HEUR_NAME "/maxproprounds",
1123  "maximum number of propagation rounds during probing (-1 infinity)",
1124  &heurdata->maxproprounds, TRUE, DEFAULT_MAXPROPROUNDS, -1, INT_MAX/4, NULL, NULL) );
1125 
1126  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/" HEUR_NAME "/copycuts",
1127  "should all active cuts from cutpool be copied to constraints in subproblem?",
1128  &heurdata->copycuts, TRUE, DEFAULT_COPYCUTS, NULL, NULL) );
1129 
1130  return SCIP_OKAY;
1131 }
enum SCIP_Result SCIP_RESULT
Definition: type_result.h:52
#define DEFAULT_MULTIPLIER
Definition: heur_clique.c:69
SCIP_RETCODE SCIPrandomCreate(SCIP_RANDNUMGEN **randnumgen, BMS_BLKMEM *blkmem, unsigned int initialseed)
Definition: misc.c:8693
SCIP_RETCODE SCIPlinkLPSol(SCIP *scip, SCIP_SOL *sol)
Definition: scip.c:37672
SCIP_Real SCIPgetSolvingTime(SCIP *scip)
Definition: scip.c:45137
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:5095
#define HEUR_TIMING
Definition: heur_clique.c:50
#define DEFAULT_MAXNODES
Definition: heur_clique.c:53
SCIP_RETCODE SCIPlinkCurrentSol(SCIP *scip, SCIP_SOL *sol)
Definition: scip.c:37777
SCIP_NODE * SCIPgetCurrentNode(SCIP *scip)
Definition: scip.c:40453
SCIP_RETCODE SCIPbacktrackProbing(SCIP *scip, int probingdepth)
Definition: scip.c:35152
SCIP_Longint SCIPgetNLPIterations(SCIP *scip)
Definition: scip.c:41382
#define HEUR_FREQ
Definition: heur_clique.c:47
SCIP_CONSHDLR * SCIPfindConshdlr(SCIP *scip, const char *name)
Definition: scip.c:6541
int SCIPgetProbingDepth(SCIP *scip)
Definition: scip.c:35125
#define HEUR_MAXDEPTH
Definition: heur_clique.c:49
#define SCIP_MAXSTRLEN
Definition: def.h:215
SCIP_Longint SCIPheurGetNBestSolsFound(SCIP_HEUR *heur)
Definition: heur.c:1327
static SCIP_DECL_HEURFREE(heurFreeClique)
Definition: heur_clique.c:459
SCIP_RETCODE SCIPsetHeurExit(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEUREXIT((*heurexit)))
Definition: scip.c:8092
static SCIP_DECL_HEUREXEC(heurExecClique)
Definition: heur_clique.c:525
SCIP_RETCODE SCIPgetNegatedVars(SCIP *scip, int nvars, SCIP_VAR **vars, SCIP_VAR **negvars)
Definition: scip.c:18696
int SCIPgetNOrigVars(SCIP *scip)
Definition: scip.c:12071
SCIP_Real SCIPvarGetLbLocal(SCIP_VAR *var)
Definition: var.c:17222
int SCIPgetNPseudoBranchCands(SCIP *scip)
Definition: scip.c:36492
static SCIP_DECL_HEUREXIT(heurExitClique)
Definition: heur_clique.c:504
#define HEUR_DESC
Definition: heur_clique.c:44
SCIP_RETCODE SCIPgetVarsData(SCIP *scip, SCIP_VAR ***vars, int *nvars, int *nbinvars, int *nintvars, int *nimplvars, int *ncontvars)
Definition: scip.c:11505
SCIP_SOL ** SCIPgetSols(SCIP *scip)
Definition: scip.c:38881
#define FALSE
Definition: def.h:64
SCIP_RETCODE SCIPhashmapCreate(SCIP_HASHMAP **hashmap, BMS_BLKMEM *blkmem, int mapsize)
Definition: misc.c:2765
#define DEFAULT_NODESQUOT
Definition: heur_clique.c:62
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:4230
SCIP_RETCODE SCIPcopyLimits(SCIP *sourcescip, SCIP *targetscip)
Definition: scip.c:4126
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:3843
SCIP_RETCODE SCIPcutoffNode(SCIP *scip, SCIP_NODE *node)
Definition: scip.c:40796
int SCIPsnprintf(char *t, int len, const char *s,...)
Definition: misc.c:9340
void SCIPrandomPermuteArray(SCIP_RANDNUMGEN *randnumgen, void **array, int begin, int end)
Definition: misc.c:8794
#define TRUE
Definition: def.h:63
#define SCIPdebug(x)
Definition: pub_message.h:74
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
SCIP_RETCODE SCIPsetPresolving(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
Definition: scip.c:5069
SCIP_BRANCHRULE * SCIPfindBranchrule(SCIP *scip, const char *name)
Definition: scip.c:9184
#define DEFAULT_MAXPROPROUNDS
Definition: heur_clique.c:63
struct SCIP_HeurData SCIP_HEURDATA
Definition: type_heur.h:51
#define SCIPfreeBlockMemory(scip, ptr)
Definition: scip.h:21907
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:7999
#define HEUR_FREQOFS
Definition: heur_clique.c:48
#define SCIPduplicateBufferArray(scip, ptr, source, num)
Definition: scip.h:21933
void * SCIPhashmapGetImage(SCIP_HASHMAP *hashmap, void *origin)
Definition: misc.c:2903
SCIP_RETCODE SCIPconstructLP(SCIP *scip, SCIP_Bool *cutoff)
Definition: scip.c:28810
#define SCIP_LONGINT_MAX
Definition: def.h:121
#define SCIPfreeBufferArray(scip, ptr)
Definition: scip.h:21937
enum SCIP_LPSolStat SCIP_LPSOLSTAT
Definition: type_lp.h:42
SCIP_RETCODE SCIPcreate(SCIP **scip)
Definition: scip.c:696
void SCIPheurSetData(SCIP_HEUR *heur, SCIP_HEURDATA *heurdata)
Definition: heur.c:1102
#define SCIPallocBlockMemory(scip, ptr)
Definition: scip.h:21890
#define SCIPdebugPrintCons(x, y, z)
Definition: pub_message.h:83
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
Definition: scip.c:1260
#define SCIPdebugMsg
Definition: scip.h:451
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:4202
SCIP_RETCODE SCIPprintStatistics(SCIP *scip, FILE *file)
Definition: scip.c:44425
#define DEFAULT_MINNODES
Definition: heur_clique.c:60
static SCIP_RETCODE createNewSol(SCIP *scip, SCIP *subscip, SCIP_VAR **subvars, SCIP_SOL *newsol, SCIP_SOL *subsol, SCIP_Bool *success)
Definition: heur_clique.c:397
SCIP_Bool SCIPisLPConstructed(SCIP *scip)
Definition: scip.c:28787
void SCIPrandomFree(SCIP_RANDNUMGEN **randnumgen)
Definition: misc.c:8710
static SCIP_RETCODE stableSortBinvars(SCIP *scip, SCIP_VAR **binvars, int nbinvars, int *cliquepartition, int ncliques)
Definition: heur_clique.c:130
#define HEUR_DISPCHAR
Definition: heur_clique.c:45
SCIP_RETCODE SCIPsolve(SCIP *scip)
Definition: scip.c:15777
const char * SCIPheurGetName(SCIP_HEUR *heur)
Definition: heur.c:1181
SCIP_RETCODE SCIPincludeHeurClique(SCIP *scip)
Definition: heur_clique.c:1071
SCIP_Bool SCIPisParamFixed(SCIP *scip, const char *name)
Definition: scip.c:4338
SCIP_RETCODE SCIPsetHeurFree(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURFREE((*heurfree)))
Definition: scip.c:8060
#define DEFAULT_MINFIXINGRATE
Definition: heur_clique.c:54
SCIP_RETCODE SCIPpropagateProbing(SCIP *scip, int maxproprounds, SCIP_Bool *cutoff, SCIP_Longint *ndomredsfound)
Definition: scip.c:35477
SCIP_RETCODE SCIPgetSolVals(SCIP *scip, SCIP_SOL *sol, int nvars, SCIP_VAR **vars, SCIP_Real *vals)
Definition: scip.c:38044
SCIP_RETCODE SCIPfixVarProbing(SCIP *scip, SCIP_VAR *var, SCIP_Real fixedval)
Definition: scip.c:35337
Constraint handler for logicor constraints (equivalent to set covering, but algorithms are suited fo...
#define HEUR_USESSUBSCIP
Definition: heur_clique.c:51
SCIP_RETCODE SCIPsetBoolParam(SCIP *scip, const char *name, SCIP_Bool value)
Definition: scip.c:4567
SCIP_STATUS SCIPgetStatus(SCIP *scip)
Definition: scip.c:921
SCIP_RETCODE SCIPpresolve(SCIP *scip)
Definition: scip.c:15616
SCIP_RETCODE SCIPcopyCuts(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool global, int *ncutsadded)
Definition: scip.c:3056
BMS_BLKMEM * SCIPblkmem(SCIP *scip)
Definition: scip.c:45519
SCIP_RETCODE SCIPendProbing(SCIP *scip)
Definition: scip.c:35187
const char * SCIPvarGetName(SCIP_VAR *var)
Definition: var.c:16552
void SCIPhashmapFree(SCIP_HASHMAP **hashmap)
Definition: misc.c:2798
SCIP_RETCODE SCIPgetBoolParam(SCIP *scip, const char *name, SCIP_Bool *value)
Definition: scip.c:4369
#define NULL
Definition: lpi_spx1.cpp:137
void SCIPsortPtr(void **ptrarray, SCIP_DECL_SORTPTRCOMP((*ptrcomp)), int len)
#define SCIP_CALL(x)
Definition: def.h:306
SCIP_Real SCIPgetLowerbound(SCIP *scip)
Definition: scip.c:42323
SCIP_RETCODE SCIPsolveProbingLP(SCIP *scip, int itlim, SCIP_Bool *lperror, SCIP_Bool *cutoff)
Definition: scip.c:35713
#define DEFAULT_MINIMPROVE
Definition: heur_clique.c:55
SCIP_Longint SCIPheurGetNCalls(SCIP_HEUR *heur)
Definition: heur.c:1307
SCIP_Bool SCIPhasCurrentNodeLP(SCIP *scip)
Definition: scip.c:28769
SCIP_RETCODE SCIPaddConsNode(SCIP *scip, SCIP_NODE *node, SCIP_CONS *cons, SCIP_NODE *validnode)
Definition: scip.c:12960
#define SCIPallocBufferArray(scip, ptr, num)
Definition: scip.h:21925
public data structures and miscellaneous methods
#define DEFAULT_NODESOFS
Definition: heur_clique.c:61
#define SCIP_Bool
Definition: def.h:61
SCIP_LPSOLSTAT SCIPgetLPSolstat(SCIP *scip)
Definition: scip.c:28854
SCIP_RETCODE SCIProundSol(SCIP *scip, SCIP_SOL *sol, SCIP_Bool *success)
Definition: scip.c:39073
SCIP_RETCODE SCIPsetObjlimit(SCIP *scip, SCIP_Real objlimit)
Definition: scip.c:11078
int SCIPgetDepth(SCIP *scip)
Definition: scip.c:42094
SCIP_RETCODE SCIPcalcCliquePartition(SCIP *const scip, SCIP_VAR **const vars, int const nvars, int *const cliquepartition, int *const ncliques)
Definition: scip.c:24152
SCIP_RETCODE SCIPsetIntParam(SCIP *scip, const char *name, int value)
Definition: scip.c:4625
unsigned int SCIPinitializeRandomSeed(SCIP *scip, int initialseedvalue)
Definition: scip.c:25467
SCIP_RETCODE SCIPfreeSol(SCIP *scip, SCIP_SOL **sol)
Definition: scip.c:37631
SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
Definition: var.c:17014
int SCIPgetNSols(SCIP *scip)
Definition: scip.c:38832
#define BMScopyMemoryArray(ptr, source, num)
Definition: memory.h:89
SCIP_Real SCIPgetSolOrigObj(SCIP *scip, SCIP_SOL *sol)
Definition: scip.c:38090
SCIP_RETCODE SCIPflushLP(SCIP *scip)
Definition: scip.c:28834
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
Definition: scip.c:45827
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:39749
#define SCIP_MAXTREEDEPTH
Definition: def.h:242
SCIP_Bool SCIPinProbing(SCIP *scip)
Definition: scip.c:35033
int SCIPgetNVars(SCIP *scip)
Definition: scip.c:11631
#define SCIP_REAL_MAX
Definition: def.h:136
int SCIPgetNConss(SCIP *scip)
Definition: scip.c:12679
SCIP_RETCODE SCIPreleaseCons(SCIP *scip, SCIP_CONS **cons)
Definition: scip.c:27323
#define HEUR_NAME
Definition: heur_clique.c:43
int SCIPgetNCliques(SCIP *scip)
Definition: scip.c:24472
SCIP_RETCODE SCIPsetHeurInit(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURINIT((*heurinit)))
Definition: scip.c:8076
#define SCIP_Real
Definition: def.h:135
static SCIP_RETCODE applyCliqueFixings(SCIP *scip, SCIP_HEURDATA *heurdata, SCIP_VAR **binvars, int nbinvars, int *cliquepartition, int ncliques, SCIP_VAR **onefixvars, int *nonefixvars, SCIP_SOL *sol, int *probingdepthofonefix, SCIP_Bool *cutoff, SCIP_RESULT *result)
Definition: heur_clique.c:232
static SCIP_DECL_SORTPTRCOMP(varObjSort)
Definition: heur_clique.c:107
SCIP_Bool SCIPisStopped(SCIP *scip)
Definition: scip.c:1138
#define MIN(x, y)
Definition: memory.c:75
#define HEUR_PRIORITY
Definition: heur_clique.c:46
#define SCIP_Longint
Definition: def.h:120
static SCIP_DECL_HEURINIT(heurInitClique)
Definition: heur_clique.c:480
SCIP_RETCODE SCIPcheckCopyLimits(SCIP *sourcescip, SCIP_Bool *success)
Definition: scip.c:4090
#define DEFAULT_COPYCUTS
Definition: heur_clique.c:70
SCIP_RETCODE SCIPsetSolVals(SCIP *scip, SCIP_SOL *sol, int nvars, SCIP_VAR **vars, SCIP_Real *vals)
Definition: scip.c:37909
#define DEFAULT_RANDSEED
Definition: heur_clique.c:64
SCIP_RETCODE SCIPsetHeurCopy(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURCOPY((*heurcopy)))
Definition: scip.c:8044
SCIP_Real SCIPvarGetUbLocal(SCIP_VAR *var)
Definition: var.c:17232
SCIP_RETCODE SCIPnewProbingNode(SCIP *scip)
Definition: scip.c:35092
SCIP_Real SCIPsumepsilon(SCIP *scip)
Definition: scip.c:45260
SCIP_Real SCIPgetUpperbound(SCIP *scip)
Definition: scip.c:42472
SCIP_RETCODE SCIPstartProbing(SCIP *scip)
Definition: scip.c:35055
#define BMSclearMemoryArray(ptr, num)
Definition: memory.h:85
#define SCIP_CALL_ABORT(x)
Definition: def.h:285
SCIP_Real SCIPceil(SCIP *scip, SCIP_Real val)
Definition: scip.c:45949
SCIP_HEURDATA * SCIPheurGetData(SCIP_HEUR *heur)
Definition: heur.c:1092
SCIP_Longint SCIPgetNNodes(SCIP *scip)
Definition: scip.c:41182
static SCIP_DECL_HEURCOPY(heurCopyClique)
Definition: heur_clique.c:445
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:4258
SCIP_RETCODE SCIPsetSubscipsOff(SCIP *scip, SCIP_Bool quiet)
Definition: scip.c:5020
SCIP_RETCODE SCIPsetLongintParam(SCIP *scip, const char *name, SCIP_Longint value)
Definition: scip.c:4683
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:4176
SCIP_RETCODE SCIPfree(SCIP **scip)
Definition: scip.c:774
SCIP_RETCODE SCIPcreateSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
Definition: scip.c:37005
SCIP_RETCODE SCIPprintSol(SCIP *scip, SCIP_SOL *sol, FILE *file, SCIP_Bool printzeros)
Definition: scip.c:38421