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