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