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