Scippy

SCIP

Solving Constraint Integer Programs

heur_rens.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_rens.c
17  * @brief LNS heuristic that finds the optimal rounding to a given point
18  * @author Timo Berthold
19  */
20 
21 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
22 
23 #include <assert.h>
24 #include <string.h>
25 #include <stdio.h>
26 #include "scip/scip.h"
27 #include "scip/heur_rens.h"
28 #include "scip/scipdefplugins.h" /* needed for the secondary SCIP instance */
29 #include "scip/cons_linear.h" /* needed if the LP relaxation gets copied into linear constraints */
30 #include "scip/pub_misc.h"
31 
32 /* default values for standard parameters that every primal heuristic has in SCIP */
33 #define HEUR_NAME "rens"
34 #define HEUR_DESC "LNS exploring fractional neighborhood of relaxation's optimum"
35 #define HEUR_DISPCHAR 'E'
36 #define HEUR_PRIORITY -1100000
37 #define HEUR_FREQ 0
38 #define HEUR_FREQOFS 0
39 #define HEUR_MAXDEPTH -1
40 #define HEUR_TIMING SCIP_HEURTIMING_AFTERLPNODE
41 #define HEUR_USESSUBSCIP TRUE /**< does the heuristic use a secondary SCIP instance? */
42 
43 /* default values for RENS-specific plugins */
44 #define DEFAULT_BINARYBOUNDS TRUE /* should general integers get binary bounds [floor(.),ceil(.)] ? */
45 #define DEFAULT_MAXNODES 5000LL /* maximum number of nodes to regard in the subproblem */
46 #define DEFAULT_MINFIXINGRATE 0.5 /* minimum percentage of integer variables that have to be fixed */
47 #define DEFAULT_MINIMPROVE 0.01 /* factor by which RENS should at least improve the incumbent */
48 #define DEFAULT_MINNODES 50LL /* minimum number of nodes to regard in the subproblem */
49 #define DEFAULT_NODESOFS 500LL /* number of nodes added to the contingent of the total nodes */
50 #define DEFAULT_NODESQUOT 0.1 /* subproblem nodes in relation to nodes of the original problem */
51 #define DEFAULT_LPLIMFAC 2.0 /* factor by which the limit on the number of LP depends on the node limit */
52 #define DEFAULT_STARTSOL 'l' /* solution that is used for fixing values */
53 #define STARTSOL_CHOICES "nl" /* possible values for startsol ('l'p relaxation, 'n'lp relaxation) */
54 #define DEFAULT_USELPROWS FALSE /* should subproblem be created out of the rows in the LP rows,
55  * otherwise, the copy constructors of the constraints handlers are used */
56 #define DEFAULT_COPYCUTS TRUE /* if DEFAULT_USELPROWS is FALSE, then should all active cuts from the cutpool
57  * of the original scip be copied to constraints of the subscip
58  */
59 #define DEFAULT_EXTRATIME FALSE /* should the RENS sub-CIP get its own full time limit? This is only
60  * implemented for testing and not recommended to be used!
61  */
62 #define DEFAULT_ADDALLSOLS FALSE /* should all subproblem solutions be added to the original SCIP? */
63 
64 #define DEFAULT_FULLSCALE FALSE /* should the RENS sub-CIP be solved with full-scale SCIP settings, including
65  * techniques that merely work on the dual bound, e.g., cuts? This is only
66  * implemented for testing and not recommended to be used!
67  */
68 #define DEFAULT_BESTSOLLIMIT -1 /* limit on number of improving incumbent solutions in sub-CIP */
69 #define DEFAULT_USEUCT FALSE /* should uct node selection be used at the beginning of the search? */
70 
71 /* event handler properties */
72 #define EVENTHDLR_NAME "Rens"
73 #define EVENTHDLR_DESC "LP event handler for " HEUR_NAME " heuristic"
74 
75 /*
76  * Data structures
77  */
78 
79 /** primal heuristic data */
80 struct SCIP_HeurData
81 {
82  SCIP_Longint maxnodes; /**< maximum number of nodes to regard in the subproblem */
83  SCIP_Longint minnodes; /**< minimum number of nodes to regard in the subproblem */
84  SCIP_Longint nodesofs; /**< number of nodes added to the contingent of the total nodes */
85  SCIP_Longint usednodes; /**< nodes already used by RENS in earlier calls */
86  SCIP_Real minfixingrate; /**< minimum percentage of integer variables that have to be fixed */
87  SCIP_Real minimprove; /**< factor by which RENS should at least improve the incumbent */
88  SCIP_Real nodesquot; /**< subproblem nodes in relation to nodes of the original problem */
89  SCIP_Real nodelimit; /**< the nodelimit employed in the current sub-SCIP, for the event handler*/
90  SCIP_Real lplimfac; /**< factor by which the limit on the number of LP depends on the node limit */
91  char startsol; /**< solution used for fixing values ('l'p relaxation, 'n'lp relaxation) */
92  SCIP_Bool binarybounds; /**< should general integers get binary bounds [floor(.),ceil(.)] ? */
93  SCIP_Bool uselprows; /**< should subproblem be created out of the rows in the LP rows? */
94  SCIP_Bool copycuts; /**< if uselprows == FALSE, should all active cuts from cutpool be copied
95  * to constraints in subproblem? */
96  SCIP_Bool extratime; /**< should the RENS sub-CIP get its own full time limit? This is only
97  * implemented for testing and not recommended to be used! */
98  SCIP_Bool addallsols; /**< should all subproblem solutions be added to the original SCIP? */
99  SCIP_Bool fullscale; /**< should the RENS sub-CIP be solved with full-scale SCIP settings,
100  * including techniques that merely work on the dual bound, e.g., cuts?
101  * This is only implemented for testing and not recommended to be used! */
102  int bestsollimit; /**< limit on number of improving incumbent solutions in sub-CIP */
103  SCIP_Bool useuct; /**< should uct node selection be used at the beginning of the search? */
104 };
105 
106 
107 /*
108  * Local methods
109  */
110 
111 /** compute the number of initial fixings and check whether the fixing rate exceeds the minimum fixing rate */
112 static
114  SCIP* scip, /**< SCIP data structure */
115  SCIP_VAR** fixedvars, /**< array to store source SCIP variables whose copies should be fixed in the sub-SCIP */
116  SCIP_Real* fixedvals, /**< array to store solution values for variable fixing */
117  int* nfixedvars, /**< pointer to store the number of fixed variables */
118  int fixedvarssize, /**< size of the arrays to store fixing variables */
119  SCIP_Real minfixingrate, /**< percentage of integer variables that have to be fixed */
120  char* startsol, /**< pointer to solution used for fixing values ('l'p relaxation, 'n'lp relaxation) */
121  SCIP_Real* fixingrate, /**< percentage of integers that get actually fixed */
122  SCIP_Bool* success /**< pointer to store whether minimum fixingrate is exceeded */
123  )
124 {
125  SCIP_VAR** vars;
126  int nintvars;
127  int nbinvars;
128  int i;
129 
130  assert(fixedvars != NULL);
131  assert(fixedvals != NULL);
132  assert(nfixedvars != NULL);
133 
134  *fixingrate = 1.0;
135  *success = FALSE;
136 
137  /* if there is no NLP relaxation available (e.g., because the presolved problem is linear), use LP relaxation */
138  if( !SCIPisNLPConstructed(scip) )
139  {
140  SCIPdebugMsg(scip, "no NLP present, use LP relaxation instead\n");
141  (*startsol) = 'l';
142  }
143 
144  /* get required variable data */
145  SCIP_CALL( SCIPgetVarsData(scip, &vars, NULL, &nbinvars, &nintvars, NULL, NULL) );
146  assert(fixedvarssize >= nbinvars + nintvars);
147  (*nfixedvars) = 0;
148 
149  /* try to solve NLP relaxation */
150  if( (*startsol) == 'n' )
151  {
152  SCIP_NLPSOLSTAT stat;
153  SCIPdebug( int nlpverblevel; )
154 
155  /* only call this function if NLP relaxation is available */
156  assert(SCIPisNLPConstructed(scip));
157 
158  /* activate NLP solver output if we are in SCIP's debug mode */
159  SCIPdebug( SCIP_CALL( SCIPgetNLPIntPar(scip, SCIP_NLPPAR_VERBLEVEL, &nlpverblevel) ) );
160  SCIPdebug( SCIP_CALL( SCIPsetNLPIntPar(scip, SCIP_NLPPAR_VERBLEVEL, MAX(1,nlpverblevel)) ) );
161 
162  SCIPdebugMsg(scip, "try to solve NLP relaxation to obtain fixing values\n");
163 
164  /* set starting point to LP solution */
166 
167  /* solve NLP relaxation */
168  SCIP_CALL( SCIPsolveNLP(scip) );
169 
170  /* get solution status of NLP solver */
171  stat = SCIPgetNLPSolstat(scip);
172  *success = (stat == SCIP_NLPSOLSTAT_GLOBOPT) || (stat == SCIP_NLPSOLSTAT_LOCOPT) || stat == (SCIP_NLPSOLSTAT_FEASIBLE);
173  SCIPdebugMsg(scip, "solving NLP relaxation was %s successful (stat=%d)\n", *success ? "" : "not", stat);
174 
175  /* reset NLP verblevel to the value it had before */
176  SCIPdebug( SCIP_CALL( SCIPsetNLPIntPar(scip, SCIP_NLPPAR_VERBLEVEL, nlpverblevel) ) );
177 
178  /* it the NLP was not successfully solved we stop the heuristic right away */
179  if( !(*success) )
180  return SCIP_OKAY;
181  }
182  else
183  {
184  assert(*startsol == 'l');
185  }
186 
187  /* count the number of variables with integral solution values in the current NLP or LP solution */
188  for( i = 0; i < nbinvars + nintvars; ++i )
189  {
190  SCIP_Real solval;
191 
192  /* get solution value in the relaxation in question */
193  solval = (*startsol == 'l') ? SCIPvarGetLPSol(vars[i]) : SCIPvarGetNLPSol(vars[i]);
194 
195  /* append variable to the buffer storage for integer variables with integer solution values */
196  if( SCIPisFeasIntegral(scip, solval) )
197  {
198  /* fix variables to current LP/NLP solution if it is integral,
199  * use exact integral value, if the variable is only integral within numerical tolerances
200  */
201  solval = SCIPfloor(scip, solval+0.5);
202  fixedvars[(*nfixedvars)] = vars[i];
203  fixedvals[(*nfixedvars)] = solval;
204  (*nfixedvars)++;
205  }
206  }
207 
208  /* abort, if all integer variables were fixed (which should not happen for MIP),
209  * but frequently happens for MINLPs using an LP relaxation
210  */
211  if( (*nfixedvars) == nbinvars + nintvars )
212  return SCIP_OKAY;
213 
214  *fixingrate = (*nfixedvars) / (SCIP_Real)(MAX(nbinvars + nintvars, 1));
215 
216  /* abort, if the amount of fixed variables is insufficient */
217  if( *fixingrate < minfixingrate )
218  return SCIP_OKAY;
219 
220  *success = TRUE;
221  return SCIP_OKAY;
222 }
223 
224 /** fixes bounds of unfixed integer variables to binary bounds */
225 static
227  SCIP* scip, /**< original SCIP data structure */
228  SCIP* subscip, /**< SCIP data structure for the subproblem */
229  SCIP_VAR** subvars, /**< the variables of the subproblem */
230  char startsol /**< solution used for fixing values ('l'p relaxation, 'n'lp relaxation) */
231  )
232 {
233  SCIP_VAR** vars; /* original SCIP variables */
234 
235  int nbinvars;
236  int nintvars;
237  int i;
238 
239  assert(scip != NULL);
240  assert(subscip != NULL);
241  assert(subvars != NULL);
242 
243  assert(startsol == 'l' || startsol == 'n');
244 
245  /* get required variable data */
246  SCIP_CALL( SCIPgetVarsData(scip, &vars, NULL, &nbinvars, &nintvars, NULL, NULL) );
247 
248  /* change bounds of integer variables of the subproblem */
249  for( i = nbinvars; i < nbinvars + nintvars; i++ )
250  {
251  SCIP_Real solval;
252  SCIP_Real lb;
253  SCIP_Real ub;
254 
255  /* get the current LP/NLP solution for each variable */
256  if( startsol == 'l')
257  solval = SCIPvarGetLPSol(vars[i]);
258  else
259  solval = SCIPvarGetNLPSol(vars[i]);
260 
261  /* restrict bounds to nearest integers if the solution value is not already integer */
262  if( !SCIPisFeasIntegral(scip, solval) )
263  {
264  lb = SCIPfeasFloor(scip,solval);
265  ub = SCIPfeasCeil(scip,solval);
266 
267  /* perform the bound change */
268  SCIP_CALL( SCIPchgVarLbGlobal(subscip, subvars[i], lb) );
269  SCIP_CALL( SCIPchgVarUbGlobal(subscip, subvars[i], ub) );
270  }
271  else
272  {
273  /* the variable bounds should be already fixed to this solution value */
274  assert(SCIPisFeasEQ(scip, SCIPvarGetLbGlobal(subvars[i]), solval));
275  assert(SCIPisFeasEQ(scip, SCIPvarGetUbGlobal(subvars[i]), solval));
276  }
277  }
278 
279  return SCIP_OKAY;
280 }
281 
282 
283 /** creates a new solution for the original problem by copying the solution of the subproblem */
284 static
286  SCIP* scip, /**< original SCIP data structure */
287  SCIP* subscip, /**< SCIP structure of the subproblem */
288  SCIP_VAR** subvars, /**< the variables of the subproblem */
289  SCIP_HEUR* heur, /**< RENS heuristic structure */
290  SCIP_SOL* subsol, /**< solution of the subproblem */
291  SCIP_Bool* success /**< used to store whether new solution was found or not */
292  )
293 {
294  SCIP_VAR** vars; /* the original problem's variables */
295  int nvars; /* the original problem's number of variables */
296  SCIP_Real* subsolvals; /* solution values of the subproblem */
297  SCIP_SOL* newsol; /* solution to be created for the original problem */
298 
299  assert(scip != NULL);
300  assert(subscip != NULL);
301  assert(subvars != NULL);
302  assert(subsol != NULL);
303 
304  /* get variables' data */
305  SCIP_CALL( SCIPgetVarsData(scip, &vars, &nvars, NULL, NULL, NULL, NULL) );
306 
307  /* sub-SCIP may have more variables than the number of active (transformed) variables in the main SCIP
308  * since constraint copying may have required the copy of variables that are fixed in the main SCIP
309  */
310  assert(nvars <= SCIPgetNOrigVars(subscip));
311 
312  SCIP_CALL( SCIPallocBufferArray(scip, &subsolvals, nvars) );
313 
314  /* copy the solution */
315  SCIP_CALL( SCIPgetSolVals(subscip, subsol, nvars, subvars, subsolvals) );
316 
317  /* create new solution for the original problem */
318  SCIP_CALL( SCIPcreateSol(scip, &newsol, heur) );
319  SCIP_CALL( SCIPsetSolVals(scip, newsol, nvars, vars, subsolvals) );
320 
321  /* try to add new solution to scip and free it immediately */
322  SCIP_CALL( SCIPtrySolFree(scip, &newsol, FALSE, FALSE, TRUE, TRUE, TRUE, success) );
323 
324  SCIPfreeBufferArray(scip, &subsolvals);
325 
326  return SCIP_OKAY;
327 }
328 
329 /* ---------------- Callback methods of event handler ---------------- */
330 
331 /* exec the event handler
332  *
333  * we interrupt the solution process
334  */
335 static
336 SCIP_DECL_EVENTEXEC(eventExecRens)
337 {
338  SCIP_HEURDATA* heurdata;
339 
340  assert(eventhdlr != NULL);
341  assert(eventdata != NULL);
342  assert(strcmp(SCIPeventhdlrGetName(eventhdlr), EVENTHDLR_NAME) == 0);
343  assert(event != NULL);
344  assert(SCIPeventGetType(event) & SCIP_EVENTTYPE_LPSOLVED);
345 
346  heurdata = (SCIP_HEURDATA*)eventdata;
347  assert(heurdata != NULL);
348 
349  /* interrupt solution process of sub-SCIP */
350  if( SCIPgetNLPs(scip) > heurdata->lplimfac * heurdata->nodelimit )
351  {
352  SCIPdebugMsg(scip, "interrupt after %" SCIP_LONGINT_FORMAT " LPs\n",SCIPgetNLPs(scip));
354  }
355 
356  return SCIP_OKAY;
357 }
358 
359 /* ---------------- external methods of RENS heuristic ---------------- */
360 
361 /** main procedure of the RENS heuristic, creates and solves a sub-SCIP */
363  SCIP* scip, /**< original SCIP data structure */
364  SCIP_HEUR* heur, /**< heuristic data structure */
365  SCIP_RESULT* result, /**< result data structure */
366  SCIP_Real minfixingrate, /**< minimum percentage of integer variables that have to be fixed */
367  SCIP_Real minimprove, /**< factor by which RENS should at least improve the incumbent */
368  SCIP_Longint maxnodes, /**< maximum number of nodes for the subproblem */
369  SCIP_Longint nstallnodes, /**< number of stalling nodes for the subproblem */
370  char startsol, /**< solution used for fixing values ('l'p relaxation, 'n'lp relaxation) */
371  SCIP_Bool binarybounds, /**< should general integers get binary bounds [floor(.),ceil(.)]? */
372  SCIP_Bool uselprows /**< should subproblem be created out of the rows in the LP rows? */
373  )
374 {
375  SCIP* subscip; /* the subproblem created by RENS */
376  SCIP_HASHMAP* varmapfw; /* mapping of SCIP variables to sub-SCIP variables */
377  SCIP_VAR** vars; /* original problem's variables */
378  SCIP_VAR** subvars; /* subproblem's variables */
379  SCIP_HEURDATA* heurdata; /* heuristic's private data structure */
380  SCIP_EVENTHDLR* eventhdlr; /* event handler for LP events */
381 
382  SCIP_Real cutoff; /* objective cutoff for the subproblem */
383  SCIP_Real allfixingrate; /* percentage of all variables fixed */
384  SCIP_Real intfixingrate; /* percentage of integer variables fixed */
385 
386  int nvars; /* number of original problem's variables */
387  int i;
388  SCIP_VAR** fixedvars;
389  SCIP_Real* fixedvals;
390  int nfixedvars;
391  int fixedvarssize;
392  int nbinvars;
393  int nintvars;
394 
395  SCIP_Bool success;
396  SCIP_RETCODE retcode;
397 
398  assert(scip != NULL);
399  assert(heur != NULL);
400  assert(result != NULL);
401 
402  assert(maxnodes >= 0);
403  assert(nstallnodes >= 0);
404 
405  assert(0.0 <= minfixingrate && minfixingrate <= 1.0);
406  assert(0.0 <= minimprove && minimprove <= 1.0);
407  assert(startsol == 'l' || startsol == 'n');
408 
409  *result = SCIP_DIDNOTRUN;
410 
411  nbinvars = SCIPgetNBinVars(scip);
412  nintvars = SCIPgetNIntVars(scip);
413 
414  /* allocate buffer storage to keep fixings for the variables in the sub SCIP */
415  fixedvarssize = nbinvars + nintvars;
416  SCIP_CALL( SCIPallocBufferArray(scip, &fixedvars, nbinvars + nintvars) );
417  SCIP_CALL( SCIPallocBufferArray(scip, &fixedvals, nbinvars + nintvars) );
418  nfixedvars = 0;
419 
420  /* compute the number of initial fixings and check if the fixing rate exceeds the minimum fixing rate */
421  SCIP_CALL( computeFixingrate(scip, fixedvars, fixedvals, &nfixedvars, fixedvarssize, minfixingrate, &startsol, &intfixingrate, &success) );
422 
423  if( !success )
424  {
425  SCIPstatisticPrintf("RENS statistic: fixed only %5.2f integer variables --> abort \n", intfixingrate);
426  goto TERMINATE;
427  }
428 
429  /* get heuristic data */
430  heurdata = SCIPheurGetData(heur);
431  assert(heurdata != NULL);
432 
433  /* check whether there is enough time and memory left */
434  SCIP_CALL( SCIPcheckCopyLimits(scip, &success) );
435 
436  if( !success )
437  goto TERMINATE;
438 
439  *result = SCIP_DIDNOTFIND;
440 
441  /* get variable data */
442  SCIP_CALL( SCIPgetVarsData(scip, &vars, &nvars, NULL, NULL, NULL, NULL) );
443 
444  /* initialize the subproblem */
445  SCIP_CALL( SCIPcreate(&subscip) );
446 
447  /* create the variable mapping hash map */
448  SCIP_CALL( SCIPhashmapCreate(&varmapfw, SCIPblkmem(subscip), nvars) );
449 
450  /* create a problem copy as sub SCIP */
451  SCIP_CALL( SCIPcopyLargeNeighborhoodSearch(scip, subscip, varmapfw, "rens", fixedvars, fixedvals, nfixedvars, uselprows,
452  heurdata->copycuts, &success, NULL) );
453 
454  eventhdlr = NULL;
455  /* create event handler for LP events */
456  SCIP_CALL( SCIPincludeEventhdlrBasic(subscip, &eventhdlr, EVENTHDLR_NAME, EVENTHDLR_DESC, eventExecRens, NULL) );
457  if( eventhdlr == NULL )
458  {
459  SCIPerrorMessage("event handler for " HEUR_NAME " heuristic not found.\n");
460  return SCIP_PLUGINNOTFOUND;
461  }
462 
463  /* copy subproblem variables into the same order as the source SCIP variables */
464  SCIP_CALL( SCIPallocBufferArray(scip, &subvars, nvars) );
465  for( i = 0; i < nvars; i++ )
466  subvars[i] = (SCIP_VAR*) SCIPhashmapGetImage(varmapfw, vars[i]);
467 
468  /* free hash map */
469  SCIPhashmapFree(&varmapfw);
470 
471  /* restrict the integer variables to binary bounds */
472  if( binarybounds )
473  {
474  SCIP_CALL( restrictToBinaryBounds(scip, subscip, subvars, startsol) );
475  }
476 
477  SCIPdebugMsg(scip, "RENS subproblem: %d vars, %d cons\n", SCIPgetNVars(subscip), SCIPgetNConss(subscip));
478 
479  /* do not abort subproblem on CTRL-C */
480  SCIP_CALL( SCIPsetBoolParam(subscip, "misc/catchctrlc", FALSE) );
481 
482 #ifdef SCIP_DEBUG
483  /* for debugging, enable full output */
484  SCIP_CALL( SCIPsetIntParam(subscip, "display/verblevel", 5) );
485  SCIP_CALL( SCIPsetIntParam(subscip, "display/freq", 100000000) );
486 #else
487  /* disable statistic timing inside sub SCIP and output to console */
488  SCIP_CALL( SCIPsetIntParam(subscip, "display/verblevel", 0) );
489  SCIP_CALL( SCIPsetBoolParam(subscip, "timing/statistictiming", FALSE) );
490 #endif
491 
492  /* set limits for the subproblem */
493  SCIP_CALL( SCIPcopyLimits(scip, subscip) );
494  heurdata->nodelimit = maxnodes;
495  SCIP_CALL( SCIPsetLongintParam(subscip, "limits/stallnodes", nstallnodes) );
496  SCIP_CALL( SCIPsetLongintParam(subscip, "limits/nodes", maxnodes) );
497  SCIP_CALL( SCIPsetIntParam(subscip, "limits/bestsol", heurdata->bestsollimit) );
498 
499  /* forbid recursive call of heuristics and separators solving sub-SCIPs */
500  SCIP_CALL( SCIPsetSubscipsOff(subscip, TRUE) );
501 
502  /* disable expensive techniques that merely work on the dual bound */
503  if( !heurdata->fullscale )
504  {
505  /* disable cutting plane separation */
507 
508  /* disable expensive presolving */
510 
511  /* use best estimate node selection */
512  if( SCIPfindNodesel(subscip, "estimate") != NULL && !SCIPisParamFixed(subscip, "nodeselection/estimate/stdpriority") )
513  {
514  SCIP_CALL( SCIPsetIntParam(subscip, "nodeselection/estimate/stdpriority", INT_MAX/4) );
515  }
516 
517  /* activate uct node selection at the top of the tree */
518  if( heurdata->useuct && SCIPfindNodesel(subscip, "uct") != NULL && !SCIPisParamFixed(subscip, "nodeselection/uct/stdpriority") )
519  {
520  SCIP_CALL( SCIPsetIntParam(subscip, "nodeselection/uct/stdpriority", INT_MAX/2) );
521  }
522 
523  /* use inference branching */
524  if( SCIPfindBranchrule(subscip, "inference") != NULL && !SCIPisParamFixed(subscip, "branching/inference/priority") )
525  {
526  SCIP_CALL( SCIPsetIntParam(subscip, "branching/inference/priority", INT_MAX/4) );
527  }
528 
529  /* enable conflict analysis and restrict conflict pool */
530  if( !SCIPisParamFixed(subscip, "conflict/enable") )
531  {
532  SCIP_CALL( SCIPsetBoolParam(subscip, "conflict/enable", TRUE) );
533  }
534  if( !SCIPisParamFixed(subscip, "conflict/maxstoresize") )
535  {
536  SCIP_CALL( SCIPsetIntParam(subscip, "conflict/maxstoresize", 100) );
537  }
538 
539  /* speed up sub-SCIP by not checking dual LP feasibility */
540  SCIP_CALL( SCIPsetBoolParam(subscip, "lp/checkdualfeas", FALSE) );
541 
542  /* employ a limit on the number of enforcement rounds in the quadratic constraint handler; this fixes the issue that
543  * sometimes the quadratic constraint handler needs hundreds or thousands of enforcement rounds to determine the
544  * feasibility status of a single node without fractional branching candidates by separation (namely for uflquad
545  * instances); however, the solution status of the sub-SCIP might get corrupted by this; hence no deductions shall be
546  * made for the original SCIP
547  */
548  if( SCIPfindConshdlr(subscip, "quadratic") != NULL && !SCIPisParamFixed(subscip, "constraints/quadratic/enfolplimit") )
549  {
550  SCIP_CALL( SCIPsetIntParam(subscip, "constraints/quadratic/enfolplimit", 500) );
551  }
552  }
553 
554  /* if there is already a solution, add an objective cutoff */
555  if( SCIPgetNSols(scip) > 0 )
556  {
557  SCIP_Real upperbound;
558  assert( !SCIPisInfinity(scip,SCIPgetUpperbound(scip)) );
559 
560  upperbound = SCIPgetUpperbound(scip) - SCIPsumepsilon(scip);
561 
562  if( !SCIPisInfinity(scip, -1.0 * SCIPgetLowerbound(scip)) )
563  {
564  cutoff = (1 - minimprove) * SCIPgetUpperbound(scip)
565  + minimprove * SCIPgetLowerbound(scip);
566  }
567  else
568  {
569  if( SCIPgetUpperbound(scip) >= 0 )
570  cutoff = (1 - minimprove) * SCIPgetUpperbound(scip);
571  else
572  cutoff = (1 + minimprove) * SCIPgetUpperbound(scip);
573  }
574  cutoff = MIN(upperbound, cutoff);
575  SCIP_CALL(SCIPsetObjlimit(subscip, cutoff));
576  }
577 
578  /* presolve the subproblem */
579  retcode = SCIPpresolve(subscip);
580 
581  /* errors in solving the subproblem should not kill the overall solving process;
582  * hence, the return code is caught and a warning is printed, only in debug mode, SCIP will stop.
583  */
584  if( retcode != SCIP_OKAY )
585  {
586  SCIPwarningMessage(scip, "Error while presolving subproblem in RENS heuristic; sub-SCIP terminated with code <%d>\n", retcode);
587  SCIPABORT(); /*lint --e{527}*/
588 
589  /* free sub problem data */
590  SCIPfreeBufferArray(scip, &subvars);
591  SCIP_CALL( SCIPfree(&subscip) );
592 
593  goto TERMINATE;
594  }
595 
596  SCIPdebugMsg(scip, "RENS presolved subproblem: %d vars, %d cons, success=%u\n", SCIPgetNVars(subscip), SCIPgetNConss(subscip), success);
597 
598  allfixingrate = (SCIPgetNOrigVars(subscip) - SCIPgetNVars(subscip)) / (SCIP_Real)SCIPgetNOrigVars(subscip);
599 
600  /* additional variables added in presolving may lead to the subSCIP having more variables than the original */
601  allfixingrate = MAX(allfixingrate, 0.0);
602 
603  /* after presolving, we should have at least reached a certain fixing rate over ALL variables (including continuous)
604  * to ensure that not only the MIP but also the LP relaxation is easy enough
605  */
606  if( allfixingrate >= minfixingrate / 2.0 )
607  {
608  SCIP_SOL** subsols;
609  int nsubsols;
610 
611  /* catch LP events of sub-SCIP */
612  assert(eventhdlr != NULL);
613  SCIP_CALL( SCIPtransformProb(subscip) );
614  SCIP_CALL( SCIPcatchEvent(subscip, SCIP_EVENTTYPE_LPSOLVED, eventhdlr, (SCIP_EVENTDATA*) heurdata, NULL) );
615 
616  /* solve the subproblem */
617  SCIPdebugMsg(scip, "solving subproblem: nstallnodes=%" SCIP_LONGINT_FORMAT ", maxnodes=%" SCIP_LONGINT_FORMAT "\n", nstallnodes, maxnodes);
618  retcode = SCIPsolve(subscip);
619 
620  /* drop LP events of sub-SCIP */
621  SCIP_CALL( SCIPdropEvent(subscip, SCIP_EVENTTYPE_LPSOLVED, eventhdlr, (SCIP_EVENTDATA*) heurdata, -1) );
622 
623  /* errors in solving the subproblem should not kill the overall solving process;
624  * hence, the return code is caught and a warning is printed, only in debug mode, SCIP will stop.
625  */
626  if( retcode != SCIP_OKAY )
627  {
628  SCIPwarningMessage(scip, "Error while solving subproblem in RENS heuristic; sub-SCIP terminated with code <%d>\n", retcode);
629  SCIPABORT();
630  }
631  else
632  {
633  /* transfer variable statistics from sub-SCIP */
634  SCIP_CALL( SCIPmergeVariableStatistics(subscip, scip, subvars, vars, nvars) );
635  }
636 
637  /* print solving statistics of subproblem if we are in SCIP's debug mode */
639 
640  /* check, whether a solution was found;
641  * due to numerics, it might happen that not all solutions are feasible -> try all solutions until one was accepted
642  */
643  nsubsols = SCIPgetNSols(subscip);
644  subsols = SCIPgetSols(subscip);
645  success = FALSE;
646  for( i = 0; i < nsubsols && (!success || heurdata->addallsols); ++i )
647  {
648  SCIP_CALL( createNewSol(scip, subscip, subvars, heur, subsols[i], &success) );
649  if( success )
650  *result = SCIP_FOUNDSOL;
651  }
652 
653  SCIPstatisticPrintf("RENS statistic: fixed %6.3f integer variables, %6.3f all variables, needed %6.1f seconds, %" SCIP_LONGINT_FORMAT " nodes, solution %10.4f found at node %" SCIP_LONGINT_FORMAT "\n",
654  intfixingrate, allfixingrate, SCIPgetSolvingTime(subscip), SCIPgetNNodes(subscip), success ? SCIPgetPrimalbound(scip) : SCIPinfinity(scip),
655  nsubsols > 0 ? SCIPsolGetNodenum(SCIPgetBestSol(subscip)) : -1 );
656  }
657  else
658  {
659  SCIPstatisticPrintf("RENS statistic: fixed only %6.3f integer variables, %6.3f all variables --> abort \n", intfixingrate, allfixingrate);
660  }
661 
662  /* free subproblem */
663  SCIPfreeBufferArray(scip, &subvars);
664  SCIP_CALL( SCIPfree(&subscip) );
665 
666 TERMINATE:
667  /* free buffer storage for variable fixings */
668  SCIPfreeBufferArray(scip, &fixedvals);
669  SCIPfreeBufferArray(scip, &fixedvars);
670 
671  return SCIP_OKAY;
672 }
673 
674 
675 /*
676  * Callback methods of primal heuristic
677  */
678 
679 /** copy method for primal heuristic plugins (called when SCIP copies plugins) */
680 static
681 SCIP_DECL_HEURCOPY(heurCopyRens)
682 { /*lint --e{715}*/
683  assert(scip != NULL);
684  assert(heur != NULL);
685  assert(strcmp(SCIPheurGetName(heur), HEUR_NAME) == 0);
686 
687  /* call inclusion method of primal heuristic */
689 
690  return SCIP_OKAY;
691 }
692 
693 /** destructor of primal heuristic to free user data (called when SCIP is exiting) */
694 static
695 SCIP_DECL_HEURFREE(heurFreeRens)
696 { /*lint --e{715}*/
697  SCIP_HEURDATA* heurdata;
698 
699  assert( heur != NULL );
700  assert( scip != NULL );
701 
702  /* get heuristic data */
703  heurdata = SCIPheurGetData(heur);
704  assert( heurdata != NULL );
705 
706  /* free heuristic data */
707  SCIPfreeBlockMemory(scip, &heurdata);
708  SCIPheurSetData(heur, NULL);
709 
710  return SCIP_OKAY;
711 }
712 
713 /** initialization method of primal heuristic (called after problem was transformed) */
714 static
715 SCIP_DECL_HEURINIT(heurInitRens)
716 { /*lint --e{715}*/
717  SCIP_HEURDATA* heurdata;
718 
719  assert( heur != NULL );
720  assert( scip != NULL );
721 
722  /* get heuristic data */
723  heurdata = SCIPheurGetData(heur);
724  assert( heurdata != NULL );
725 
726  /* initialize data */
727  heurdata->usednodes = 0;
728 
729  return SCIP_OKAY;
730 }
731 
732 
733 /** execution method of primal heuristic */
734 static
735 SCIP_DECL_HEUREXEC(heurExecRens)
736 { /*lint --e{715}*/
737 
738  SCIP_HEURDATA* heurdata; /* heuristic's data */
739  SCIP_Longint nstallnodes; /* number of stalling nodes for the subproblem */
740 
741  assert( heur != NULL );
742  assert( scip != NULL );
743  assert( result != NULL );
744  assert( SCIPhasCurrentNodeLP(scip) );
745 
746  *result = SCIP_DELAYED;
747 
748  /* do not call heuristic of node was already detected to be infeasible */
749  if( nodeinfeasible )
750  return SCIP_OKAY;
751 
752  /* get heuristic data */
753  heurdata = SCIPheurGetData(heur);
754  assert( heurdata != NULL );
755 
756  /* only call heuristic, if an optimal LP solution is at hand */
757  if( heurdata->startsol == 'l' && SCIPgetLPSolstat(scip) != SCIP_LPSOLSTAT_OPTIMAL )
758  return SCIP_OKAY;
759 
760  /* only call heuristic, if the LP objective value is smaller than the cutoff bound */
761  if( heurdata->startsol == 'l' && SCIPisGE(scip, SCIPgetLPObjval(scip), SCIPgetCutoffbound(scip)) )
762  return SCIP_OKAY;
763 
764  /* only continue with some fractional variables */
765  if( heurdata->startsol == 'l' && SCIPgetNLPBranchCands(scip) == 0 )
766  return SCIP_OKAY;
767 
768  /* do not proceed, when we should use the NLP relaxation, but there is no NLP solver included in SCIP */
769  if( heurdata->startsol == 'n' && SCIPgetNNlpis(scip) == 0 )
770  return SCIP_OKAY;
771 
772  *result = SCIP_DIDNOTRUN;
773 
774  /* calculate the maximal number of branching nodes until heuristic is aborted */
775  nstallnodes = (SCIP_Longint)(heurdata->nodesquot * SCIPgetNNodes(scip));
776 
777  /* reward RENS if it succeeded often */
778  nstallnodes = (SCIP_Longint)(nstallnodes * 3.0 * (SCIPheurGetNBestSolsFound(heur)+1.0)/(SCIPheurGetNCalls(heur) + 1.0));
779  nstallnodes -= 100 * SCIPheurGetNCalls(heur); /* count the setup costs for the sub-SCIP as 100 nodes */
780  nstallnodes += heurdata->nodesofs;
781 
782  /* determine the node limit for the current process */
783  nstallnodes -= heurdata->usednodes;
784  nstallnodes = MIN(nstallnodes, heurdata->maxnodes);
785 
786  /* check whether we have enough nodes left to call subproblem solving */
787  if( nstallnodes < heurdata->minnodes )
788  {
789  SCIPdebugMsg(scip, "skipping RENS: nstallnodes=%" SCIP_LONGINT_FORMAT ", minnodes=%" SCIP_LONGINT_FORMAT "\n", nstallnodes, heurdata->minnodes);
790  return SCIP_OKAY;
791  }
792 
793  if( SCIPisStopped(scip) && !heurdata->extratime )
794  return SCIP_OKAY;
795 
796  SCIP_CALL( SCIPapplyRens(scip, heur, result, heurdata->minfixingrate, heurdata->minimprove,
797  heurdata->maxnodes, nstallnodes, heurdata->startsol, heurdata->binarybounds, heurdata->uselprows) );
798 
799  return SCIP_OKAY;
800 }
801 
802 
803 /*
804  * primal heuristic specific interface methods
805  */
806 
807 /** creates the rens primal heuristic and includes it in SCIP */
809  SCIP* scip /**< SCIP data structure */
810  )
811 {
812  SCIP_HEURDATA* heurdata;
813  SCIP_HEUR* heur;
814 
815  /* create Rens primal heuristic data */
816  SCIP_CALL( SCIPallocBlockMemory(scip, &heurdata) );
817 
818  /* include primal heuristic */
819  SCIP_CALL( SCIPincludeHeurBasic(scip, &heur,
821  HEUR_MAXDEPTH, HEUR_TIMING, HEUR_USESSUBSCIP, heurExecRens, heurdata) );
822 
823  assert(heur != NULL);
824 
825  /* set non-NULL pointers to callback methods */
826  SCIP_CALL( SCIPsetHeurCopy(scip, heur, heurCopyRens) );
827  SCIP_CALL( SCIPsetHeurFree(scip, heur, heurFreeRens) );
828  SCIP_CALL( SCIPsetHeurInit(scip, heur, heurInitRens) );
829 
830  /* add rens primal heuristic parameters */
831 
832  SCIP_CALL( SCIPaddRealParam(scip, "heuristics/" HEUR_NAME "/minfixingrate",
833  "minimum percentage of integer variables that have to be fixable",
834  &heurdata->minfixingrate, FALSE, DEFAULT_MINFIXINGRATE, 0.0, 1.0, NULL, NULL) );
835 
836  SCIP_CALL( SCIPaddLongintParam(scip, "heuristics/" HEUR_NAME "/maxnodes",
837  "maximum number of nodes to regard in the subproblem",
838  &heurdata->maxnodes, TRUE,DEFAULT_MAXNODES, 0LL, SCIP_LONGINT_MAX, NULL, NULL) );
839 
840  SCIP_CALL( SCIPaddLongintParam(scip, "heuristics/" HEUR_NAME "/nodesofs",
841  "number of nodes added to the contingent of the total nodes",
842  &heurdata->nodesofs, FALSE, DEFAULT_NODESOFS, 0LL, SCIP_LONGINT_MAX, NULL, NULL) );
843 
844  SCIP_CALL( SCIPaddLongintParam(scip, "heuristics/" HEUR_NAME "/minnodes",
845  "minimum number of nodes required to start the subproblem",
846  &heurdata->minnodes, TRUE, DEFAULT_MINNODES, 0LL, SCIP_LONGINT_MAX, NULL, NULL) );
847 
848  SCIP_CALL( SCIPaddRealParam(scip, "heuristics/" HEUR_NAME "/nodesquot",
849  "contingent of sub problem nodes in relation to the number of nodes of the original problem",
850  &heurdata->nodesquot, FALSE, DEFAULT_NODESQUOT, 0.0, 1.0, NULL, NULL) );
851 
852  SCIP_CALL( SCIPaddRealParam(scip, "heuristics/" HEUR_NAME "/minimprove",
853  "factor by which RENS should at least improve the incumbent",
854  &heurdata->minimprove, TRUE, DEFAULT_MINIMPROVE, 0.0, 1.0, NULL, NULL) );
855 
856  SCIP_CALL( SCIPaddRealParam(scip, "heuristics/" HEUR_NAME "/lplimfac",
857  "factor by which the limit on the number of LP depends on the node limit",
858  &heurdata->lplimfac, TRUE, DEFAULT_LPLIMFAC, 1.0, SCIP_REAL_MAX, NULL, NULL) );
859 
860  SCIP_CALL( SCIPaddCharParam(scip, "heuristics/" HEUR_NAME "/startsol",
861  "solution that is used for fixing values ('l'p relaxation, 'n'lp relaxation)",
862  &heurdata->startsol, FALSE, DEFAULT_STARTSOL, STARTSOL_CHOICES, NULL, NULL) );
863 
864  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/" HEUR_NAME "/binarybounds",
865  "should general integers get binary bounds [floor(.),ceil(.)] ?",
866  &heurdata->binarybounds, TRUE, DEFAULT_BINARYBOUNDS, NULL, NULL) );
867 
868  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/" HEUR_NAME "/uselprows",
869  "should subproblem be created out of the rows in the LP rows?",
870  &heurdata->uselprows, TRUE, DEFAULT_USELPROWS, NULL, NULL) );
871 
872  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/" HEUR_NAME "/copycuts",
873  "if uselprows == FALSE, should all active cuts from cutpool be copied to constraints in subproblem?",
874  &heurdata->copycuts, TRUE, DEFAULT_COPYCUTS, NULL, NULL) );
875 
876  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/" HEUR_NAME "/extratime",
877  "should the RENS sub-CIP get its own full time limit? This is only for tesing and not recommended!",
878  &heurdata->extratime, TRUE, DEFAULT_EXTRATIME, NULL, NULL) );
879 
880  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/" HEUR_NAME "/addallsols",
881  "should all subproblem solutions be added to the original SCIP?",
882  &heurdata->addallsols, TRUE, DEFAULT_ADDALLSOLS, NULL, NULL) );
883 
884  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/" HEUR_NAME "/fullscale",
885  "should the RENS sub-CIP be solved with cuts, conflicts, strong branching,... This is only for tesing and not recommended!",
886  &heurdata->fullscale, TRUE, DEFAULT_FULLSCALE, NULL, NULL) );
887 
888  SCIP_CALL( SCIPaddIntParam(scip, "heuristics/" HEUR_NAME "/bestsollimit",
889  "limit on number of improving incumbent solutions in sub-CIP",
890  &heurdata->bestsollimit, FALSE, DEFAULT_BESTSOLLIMIT, -1, INT_MAX, NULL, NULL) );
891 
892  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/" HEUR_NAME "/useuct",
893  "should uct node selection be used at the beginning of the search?",
894  &heurdata->useuct, TRUE, DEFAULT_USEUCT, NULL, NULL) );
895 
896  return SCIP_OKAY;
897 }
enum SCIP_Result SCIP_RESULT
Definition: type_result.h:52
static SCIP_DECL_HEURINIT(heurInitRens)
Definition: heur_rens.c:715
int SCIPgetNIntVars(SCIP *scip)
Definition: scip.c:11770
#define DEFAULT_BINARYBOUNDS
Definition: heur_rens.c:44
static SCIP_DECL_HEUREXEC(heurExecRens)
Definition: heur_rens.c:735
SCIP_RETCODE SCIPchgVarLbGlobal(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
Definition: scip.c:21971
SCIP_Real SCIPgetSolvingTime(SCIP *scip)
Definition: scip.c:45371
#define SCIP_EVENTTYPE_LPSOLVED
Definition: type_event.h:84
SCIP_RETCODE SCIPsetSeparating(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
Definition: scip.c:5130
SCIP_Bool SCIPisNLPConstructed(SCIP *scip)
Definition: scip.c:30965
SCIP_Bool SCIPisFeasEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
Definition: scip.c:46320
SCIP_RETCODE SCIPgetNLPIntPar(SCIP *scip, SCIP_NLPPARAM type, int *ival)
Definition: scip.c:31499
SCIP_RETCODE SCIPapplyRens(SCIP *scip, SCIP_HEUR *heur, SCIP_RESULT *result, SCIP_Real minfixingrate, SCIP_Real minimprove, SCIP_Longint maxnodes, SCIP_Longint nstallnodes, char startsol, SCIP_Bool binarybounds, SCIP_Bool uselprows)
Definition: heur_rens.c:362
SCIP_CONSHDLR * SCIPfindConshdlr(SCIP *scip, const char *name)
Definition: scip.c:6576
SCIP_Real SCIPgetCutoffbound(SCIP *scip)
Definition: scip.c:42726
#define HEUR_PRIORITY
Definition: heur_rens.c:36
SCIP_Real SCIPgetPrimalbound(SCIP *scip)
Definition: scip.c:42675
SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
Definition: var.c:17169
SCIP_Longint SCIPheurGetNBestSolsFound(SCIP_HEUR *heur)
Definition: heur.c:1327
#define DEFAULT_BESTSOLLIMIT
Definition: heur_rens.c:68
int SCIPgetNOrigVars(SCIP *scip)
Definition: scip.c:12120
SCIP_Bool SCIPisGE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
Definition: scip.c:46037
SCIP_RETCODE SCIPincludeEventhdlrBasic(SCIP *scip, SCIP_EVENTHDLR **eventhdlrptr, const char *name, const char *desc, SCIP_DECL_EVENTEXEC((*eventexec)), SCIP_EVENTHDLRDATA *eventhdlrdata)
Definition: scip.c:8561
SCIP_NLPSOLSTAT SCIPgetNLPSolstat(SCIP *scip)
Definition: scip.c:31348
#define DEFAULT_EXTRATIME
Definition: heur_rens.c:59
#define DEFAULT_MINNODES
Definition: heur_rens.c:48
SCIP_RETCODE SCIPgetVarsData(SCIP *scip, SCIP_VAR ***vars, int *nvars, int *nbinvars, int *nintvars, int *nimplvars, int *ncontvars)
Definition: scip.c:11554
SCIP_SOL ** SCIPgetSols(SCIP *scip)
Definition: scip.c:39108
#define FALSE
Definition: def.h:64
SCIP_RETCODE SCIPhashmapCreate(SCIP_HASHMAP **hashmap, BMS_BLKMEM *blkmem, int mapsize)
Definition: misc.c:2764
const char * SCIPeventhdlrGetName(SCIP_EVENTHDLR *eventhdlr)
Definition: event.c:278
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:4265
SCIP_RETCODE SCIPcopyLimits(SCIP *sourcescip, SCIP *targetscip)
Definition: scip.c:4164
SCIP_Real SCIPinfinity(SCIP *scip)
Definition: scip.c:46050
#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 SCIPsolveNLP(SCIP *scip)
Definition: scip.c:31325
SCIP_RETCODE SCIPsetPresolving(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
Definition: scip.c:5104
SCIP_BRANCHRULE * SCIPfindBranchrule(SCIP *scip, const char *name)
Definition: scip.c:9219
#define HEUR_FREQ
Definition: heur_rens.c:37
struct SCIP_HeurData SCIP_HEURDATA
Definition: type_heur.h:51
#define SCIPfreeBlockMemory(scip, ptr)
Definition: scip.h:21973
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:8034
#define EVENTHDLR_NAME
Definition: heur_rens.c:72
SCIP_RETCODE SCIPincludeHeurRens(SCIP *scip)
Definition: heur_rens.c:808
SCIP_RETCODE SCIPsetNLPIntPar(SCIP *scip, SCIP_NLPPARAM type, int ival)
Definition: scip.c:31527
void * SCIPhashmapGetImage(SCIP_HASHMAP *hashmap, void *origin)
Definition: misc.c:2902
#define DEFAULT_STARTSOL
Definition: heur_rens.c:52
#define SCIP_LONGINT_MAX
Definition: def.h:131
#define SCIPfreeBufferArray(scip, ptr)
Definition: scip.h:22003
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:21956
int SCIPgetNLPBranchCands(SCIP *scip)
Definition: scip.c:36334
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
Definition: scip.c:1260
SCIP_RETCODE SCIPchgVarUbGlobal(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
Definition: scip.c:22058
#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:4237
SCIP_RETCODE SCIPprintStatistics(SCIP *scip, FILE *file)
Definition: scip.c:44659
SCIP_Real SCIPfeasCeil(SCIP *scip, SCIP_Real val)
Definition: scip.c:46457
SCIP_Real SCIPfeasFloor(SCIP *scip, SCIP_Real val)
Definition: scip.c:46445
SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
Definition: var.c:17179
#define DEFAULT_MINIMPROVE
Definition: heur_rens.c:47
static SCIP_RETCODE createNewSol(SCIP *scip, SCIP *subscip, SCIP_VAR **subvars, SCIP_HEUR *heur, SCIP_SOL *subsol, SCIP_Bool *success)
Definition: heur_rens.c:285
SCIP_RETCODE SCIPsolve(SCIP *scip)
Definition: scip.c:15846
const char * SCIPheurGetName(SCIP_HEUR *heur)
Definition: heur.c:1181
#define STARTSOL_CHOICES
Definition: heur_rens.c:53
#define DEFAULT_USELPROWS
Definition: heur_rens.c:54
#define SCIPerrorMessage
Definition: pub_message.h:45
SCIP_Bool SCIPisParamFixed(SCIP *scip, const char *name)
Definition: scip.c:4373
SCIP_RETCODE SCIPsetHeurFree(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURFREE((*heurfree)))
Definition: scip.c:8095
enum SCIP_NlpSolStat SCIP_NLPSOLSTAT
Definition: type_nlpi.h:69
SCIP_RETCODE SCIPgetSolVals(SCIP *scip, SCIP_SOL *sol, int nvars, SCIP_VAR **vars, SCIP_Real *vals)
Definition: scip.c:38219
#define HEUR_USESSUBSCIP
Definition: heur_rens.c:41
SCIP_RETCODE SCIPsetBoolParam(SCIP *scip, const char *name, SCIP_Bool value)
Definition: scip.c:4602
SCIP_RETCODE SCIPpresolve(SCIP *scip)
Definition: scip.c:15685
BMS_BLKMEM * SCIPblkmem(SCIP *scip)
Definition: scip.c:45753
#define DEFAULT_MAXNODES
Definition: heur_rens.c:45
struct SCIP_EventData SCIP_EVENTDATA
Definition: type_event.h:155
void SCIPhashmapFree(SCIP_HASHMAP **hashmap)
Definition: misc.c:2797
SCIP_RETCODE SCIPmergeVariableStatistics(SCIP *sourcescip, SCIP *targetscip, SCIP_VAR **sourcevars, SCIP_VAR **targetvars, int nvars)
Definition: scip.c:2420
#define NULL
Definition: lpi_spx1.cpp:137
int SCIPgetNNlpis(SCIP *scip)
Definition: scip.c:9479
SCIP_Real SCIPvarGetLPSol(SCIP_VAR *var)
Definition: var.c:17543
#define DEFAULT_USEUCT
Definition: heur_rens.c:69
SCIP_RETCODE SCIPsetNLPInitialGuessSol(SCIP *scip, SCIP_SOL *sol)
Definition: scip.c:31293
static SCIP_DECL_HEURFREE(heurFreeRens)
Definition: heur_rens.c:695
#define SCIP_CALL(x)
Definition: def.h:316
SCIP_Real SCIPgetLowerbound(SCIP *scip)
Definition: scip.c:42550
#define DEFAULT_LPLIMFAC
Definition: heur_rens.c:51
#define SCIPstatisticPrintf
Definition: pub_message.h:107
LNS heuristic that finds the optimal rounding to a given point.
SCIP_Longint SCIPheurGetNCalls(SCIP_HEUR *heur)
Definition: heur.c:1307
SCIP_Bool SCIPhasCurrentNodeLP(SCIP *scip)
Definition: scip.c:28863
#define DEFAULT_MINFIXINGRATE
Definition: heur_rens.c:46
static SCIP_RETCODE restrictToBinaryBounds(SCIP *scip, SCIP *subscip, SCIP_VAR **subvars, char startsol)
Definition: heur_rens.c:226
#define SCIPallocBufferArray(scip, ptr, num)
Definition: scip.h:21991
public data structures and miscellaneous methods
#define HEUR_MAXDEPTH
Definition: heur_rens.c:39
#define HEUR_TIMING
Definition: heur_rens.c:40
#define DEFAULT_NODESOFS
Definition: heur_rens.c:49
#define SCIP_Bool
Definition: def.h:61
SCIP_RETCODE SCIPcatchEvent(SCIP *scip, SCIP_EVENTTYPE eventtype, SCIP_EVENTHDLR *eventhdlr, SCIP_EVENTDATA *eventdata, int *filterpos)
Definition: scip.c:40434
SCIP_LPSOLSTAT SCIPgetLPSolstat(SCIP *scip)
Definition: scip.c:28948
#define HEUR_DESC
Definition: heur_rens.c:34
SCIP_EVENTTYPE SCIPeventGetType(SCIP_EVENT *event)
Definition: event.c:959
#define HEUR_NAME
Definition: heur_rens.c:33
SCIP_Longint SCIPsolGetNodenum(SCIP_SOL *sol)
Definition: sol.c:2362
SCIP_RETCODE SCIPsetObjlimit(SCIP *scip, SCIP_Real objlimit)
Definition: scip.c:11114
SCIP_Real SCIPvarGetNLPSol(SCIP_VAR *var)
Definition: var.c:17556
#define MAX(x, y)
Definition: tclique_def.h:75
SCIP_RETCODE SCIPtrySolFree(SCIP *scip, SCIP_SOL **sol, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *stored)
Definition: scip.c:40070
SCIP_RETCODE SCIPsetIntParam(SCIP *scip, const char *name, int value)
Definition: scip.c:4660
static SCIP_DECL_HEURCOPY(heurCopyRens)
Definition: heur_rens.c:681
SCIP_RETCODE SCIPdropEvent(SCIP *scip, SCIP_EVENTTYPE eventtype, SCIP_EVENTHDLR *eventhdlr, SCIP_EVENTDATA *eventdata, int filterpos)
Definition: scip.c:40468
int SCIPgetNSols(SCIP *scip)
Definition: scip.c:39059
Constraint handler for linear constraints in their most general form, .
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
Definition: scip.c:46061
int SCIPgetNBinVars(SCIP *scip)
Definition: scip.c:11725
int SCIPgetNVars(SCIP *scip)
Definition: scip.c:11680
#define SCIP_REAL_MAX
Definition: def.h:146
#define DEFAULT_ADDALLSOLS
Definition: heur_rens.c:62
SCIP_Real SCIPgetLPObjval(SCIP *scip)
Definition: scip.c:29027
#define HEUR_DISPCHAR
Definition: heur_rens.c:35
SCIP_SOL * SCIPgetBestSol(SCIP *scip)
Definition: scip.c:39158
SCIP_RETCODE SCIPaddCharParam(SCIP *scip, const char *name, const char *desc, char *valueptr, SCIP_Bool isadvanced, char defaultvalue, const char *allowedvalues, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
Definition: scip.c:4321
int SCIPgetNConss(SCIP *scip)
Definition: scip.c:12728
SCIP_RETCODE SCIPsetHeurInit(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURINIT((*heurinit)))
Definition: scip.c:8111
SCIP_NODESEL * SCIPfindNodesel(SCIP *scip, const char *name)
Definition: scip.c:8907
SCIP_RETCODE SCIPcopyLargeNeighborhoodSearch(SCIP *sourcescip, SCIP *subscip, SCIP_HASHMAP *varmap, const char *suffix, SCIP_VAR **fixedvars, SCIP_Real *fixedvals, int nfixedvars, SCIP_Bool uselprows, SCIP_Bool copycuts, SCIP_Bool *success, SCIP_Bool *valid)
Definition: heuristics.c:899
#define SCIP_Real
Definition: def.h:145
SCIP_Bool SCIPisStopped(SCIP *scip)
Definition: scip.c:1138
#define MIN(x, y)
Definition: memory.c:75
#define HEUR_FREQOFS
Definition: heur_rens.c:38
#define SCIP_Longint
Definition: def.h:130
SCIP_RETCODE SCIPcheckCopyLimits(SCIP *sourcescip, SCIP_Bool *success)
Definition: scip.c:4128
SCIP_RETCODE SCIPsetSolVals(SCIP *scip, SCIP_SOL *sol, int nvars, SCIP_VAR **vars, SCIP_Real *vals)
Definition: scip.c:38084
SCIP_RETCODE SCIPtransformProb(SCIP *scip)
Definition: scip.c:13717
SCIP_RETCODE SCIPsetHeurCopy(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURCOPY((*heurcopy)))
Definition: scip.c:8079
SCIP_Bool SCIPisFeasIntegral(SCIP *scip, SCIP_Real val)
Definition: scip.c:46421
SCIP_Real SCIPsumepsilon(SCIP *scip)
Definition: scip.c:45494
static SCIP_RETCODE computeFixingrate(SCIP *scip, SCIP_VAR **fixedvars, SCIP_Real *fixedvals, int *nfixedvars, int fixedvarssize, SCIP_Real minfixingrate, char *startsol, SCIP_Real *fixingrate, SCIP_Bool *success)
Definition: heur_rens.c:113
SCIP_RETCODE SCIPinterruptSolve(SCIP *scip)
Definition: scip.c:17019
SCIP_Real SCIPgetUpperbound(SCIP *scip)
Definition: scip.c:42699
#define DEFAULT_COPYCUTS
Definition: heur_rens.c:56
#define DEFAULT_FULLSCALE
Definition: heur_rens.c:64
SCIP_HEURDATA * SCIPheurGetData(SCIP_HEUR *heur)
Definition: heur.c:1092
SCIP_Longint SCIPgetNNodes(SCIP *scip)
Definition: scip.c:41409
SCIP_Longint SCIPgetNLPs(SCIP *scip)
Definition: scip.c:41590
#define SCIPABORT()
Definition: def.h:288
#define DEFAULT_NODESQUOT
Definition: heur_rens.c:50
default SCIP plugins
#define EVENTHDLR_DESC
Definition: heur_rens.c:73
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:4293
SCIP_RETCODE SCIPsetSubscipsOff(SCIP *scip, SCIP_Bool quiet)
Definition: scip.c:5055
SCIP_Real SCIPfloor(SCIP *scip, SCIP_Real val)
Definition: scip.c:46171
SCIP_RETCODE SCIPsetLongintParam(SCIP *scip, const char *name, SCIP_Longint value)
Definition: scip.c:4718
SCIP callable library.
static SCIP_DECL_EVENTEXEC(eventExecRens)
Definition: heur_rens.c:336
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:4211
SCIP_RETCODE SCIPfree(SCIP **scip)
Definition: scip.c:774
SCIP_RETCODE SCIPcreateSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
Definition: scip.c:37178