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-2016 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SCIP is distributed under the terms of the ZIB Academic License. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SCIP; see the file COPYING. If not email to scip@zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file heur_rens.c
17  * @brief LNS heuristic that finds the optimal rounding to a given point
18  * @author Timo Berthold
19  */
20 
21 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
22 
23 #include <assert.h>
24 #include <string.h>
25 #include <stdio.h>
26 #include "scip/scip.h"
27 #include "scip/heur_rens.h"
28 #include "scip/scipdefplugins.h" /* needed for the secondary SCIP instance */
29 #include "scip/cons_linear.h" /* needed if the LP relaxation gets copied into linear constraints */
30 #include "scip/pub_misc.h"
31 
32 /* default values for standard parameters that every primal heuristic has in SCIP */
33 #define HEUR_NAME "rens"
34 #define HEUR_DESC "LNS exploring fractional neighborhood of relaxation's optimum"
35 #define HEUR_DISPCHAR 'E'
36 #define HEUR_PRIORITY -1100000
37 #define HEUR_FREQ 0
38 #define HEUR_FREQOFS 0
39 #define HEUR_MAXDEPTH -1
40 #define HEUR_TIMING SCIP_HEURTIMING_AFTERLPNODE
41 #define HEUR_USESSUBSCIP TRUE /**< does the heuristic use a secondary SCIP instance? */
42 
43 /* default values for RENS-specific plugins */
44 #define DEFAULT_BINARYBOUNDS TRUE /* should general integers get binary bounds [floor(.),ceil(.)] ? */
45 #define DEFAULT_MAXNODES 5000LL /* maximum number of nodes to regard in the subproblem */
46 #define DEFAULT_MINFIXINGRATE 0.5 /* minimum percentage of integer variables that have to be fixed */
47 #define DEFAULT_MINIMPROVE 0.01 /* factor by which RENS should at least improve the incumbent */
48 #define DEFAULT_MINNODES 50LL /* minimum number of nodes to regard in the subproblem */
49 #define DEFAULT_NODESOFS 500LL /* number of nodes added to the contingent of the total nodes */
50 #define DEFAULT_NODESQUOT 0.1 /* subproblem nodes in relation to nodes of the original problem */
51 #define DEFAULT_LPLIMFAC 2.0 /* factor by which the limit on the number of LP depends on the node limit */
52 #define DEFAULT_STARTSOL 'l' /* solution that is used for fixing values */
53 #define STARTSOL_CHOICES "nl" /* possible values for startsol ('l'p relaxation, 'n'lp relaxation) */
54 #define DEFAULT_USELPROWS FALSE /* should subproblem be created out of the rows in the LP rows,
55  * otherwise, the copy constructors of the constraints handlers are used */
56 #define DEFAULT_COPYCUTS TRUE /* if DEFAULT_USELPROWS is FALSE, then should all active cuts from the cutpool
57  * of the original scip be copied to constraints of the subscip
58  */
59 #define DEFAULT_EXTRATIME FALSE /* should the RENS sub-CIP get its own full time limit? This is only
60  * implemented for testing and not recommended to be used!
61  */
62 #define DEFAULT_ADDALLSOLS FALSE /* should all subproblem solutions be added to the original SCIP? */
63 
64 #define DEFAULT_FULLSCALE FALSE /* should the RENS sub-CIP be solved with full-scale SCIP settings, including
65  * techniques that merely work on the dual bound, e.g., cuts? This is only
66  * implemented for testing and not recommended to be used!
67  */
68 
69 /* event handler properties */
70 #define EVENTHDLR_NAME "Rens"
71 #define EVENTHDLR_DESC "LP event handler for " HEUR_NAME " heuristic"
72 
73 /*
74  * Data structures
75  */
76 
77 /** primal heuristic data */
78 struct SCIP_HeurData
79 {
80  SCIP_Longint maxnodes; /**< maximum number of nodes to regard in the subproblem */
81  SCIP_Longint minnodes; /**< minimum number of nodes to regard in the subproblem */
82  SCIP_Longint nodesofs; /**< number of nodes added to the contingent of the total nodes */
83  SCIP_Longint usednodes; /**< nodes already used by RENS in earlier calls */
84  SCIP_Real minfixingrate; /**< minimum percentage of integer variables that have to be fixed */
85  SCIP_Real minimprove; /**< factor by which RENS should at least improve the incumbent */
86  SCIP_Real nodesquot; /**< subproblem nodes in relation to nodes of the original problem */
87  SCIP_Real nodelimit; /**< the nodelimit employed in the current sub-SCIP, for the event handler*/
88  SCIP_Real lplimfac; /**< factor by which the limit on the number of LP depends on the node limit */
89  char startsol; /**< solution used for fixing values ('l'p relaxation, 'n'lp relaxation) */
90  SCIP_Bool binarybounds; /**< should general integers get binary bounds [floor(.),ceil(.)] ? */
91  SCIP_Bool uselprows; /**< should subproblem be created out of the rows in the LP rows? */
92  SCIP_Bool copycuts; /**< if uselprows == FALSE, should all active cuts from cutpool be copied
93  * to constraints in subproblem? */
94  SCIP_Bool extratime; /**< should the RENS sub-CIP get its own full time limit? This is only
95  * implemented for testing and not recommended to be used! */
96  SCIP_Bool addallsols; /**< should all subproblem solutions be added to the original SCIP? */
97  SCIP_Bool fullscale; /**< should the RENS sub-CIP be solved with full-scale SCIP settings,
98  * including techniques that merely work on the dual bound, e.g., cuts?
99  * This is only implemented for testing and not recommended to be used! */
100 };
101 
102 
103 /*
104  * Local methods
105  */
106 
107 /** compute the number of initial fixings and check whether the fixing rate exceeds the minimum fixing rate */
108 static
110  SCIP* scip, /**< SCIP data structure */
111  SCIP_Real minfixingrate, /**< percentage of integer variables that have to be fixed */
112  char* startsol, /**< pointer to solution used for fixing values ('l'p relaxation, 'n'lp relaxation) */
113  SCIP_Real* fixingrate, /**< percentage of integers that get actually fixed */
114  SCIP_Bool* success /**< pointer to store whether minimum fixingrate is exceeded */
115  )
116 {
117  SCIP_VAR** vars;
118  int fixingcounter;
119  int nintvars;
120  int nbinvars;
121  int i;
122 
123  *fixingrate = 1.0;
124  *success = FALSE;
125 
126  fixingcounter = 0;
127 
128  /* if there is no NLP relaxation available (e.g., because the presolved problem is linear), use LP relaxation */
129  if( !SCIPisNLPConstructed(scip) )
130  {
131  SCIPdebugMessage("no NLP present, use LP relaxation instead\n");
132  (*startsol) = 'l';
133  }
134 
135  /* get required variable data */
136  SCIP_CALL( SCIPgetVarsData(scip, &vars, NULL, &nbinvars, &nintvars, NULL, NULL) );
137 
138  /* try to solve NLP relaxation */
139  if( (*startsol) == 'n' )
140  {
141  SCIP_NLPSOLSTAT stat;
142  SCIPdebug( int nlpverblevel; )
143 
144  /* only call this function if NLP relaxation is available */
145  assert(SCIPisNLPConstructed(scip));
146 
147  /* activate NLP solver output if we are in SCIP's debug mode */
148  SCIPdebug( SCIP_CALL( SCIPgetNLPIntPar(scip, SCIP_NLPPAR_VERBLEVEL, &nlpverblevel) ) );
149  SCIPdebug( SCIP_CALL( SCIPsetNLPIntPar(scip, SCIP_NLPPAR_VERBLEVEL, MAX(1,nlpverblevel)) ) );
150 
151  SCIPdebugMessage("try to solve NLP relaxation to obtain fixing values\n");
152 
153  /* set starting point to LP solution */
155 
156  /* solve NLP relaxation */
157  SCIP_CALL( SCIPsolveNLP(scip) );
158 
159  /* get solution status of NLP solver */
160  stat = SCIPgetNLPSolstat(scip);
161  *success = (stat == SCIP_NLPSOLSTAT_GLOBOPT) || (stat == SCIP_NLPSOLSTAT_LOCOPT) || stat == (SCIP_NLPSOLSTAT_FEASIBLE);
162  SCIPdebugMessage("solving NLP relaxation was %s successful (stat=%d)\n", *success ? "" : "not", stat);
163 
164  /* reset NLP verblevel to the value it had before */
165  SCIPdebug( SCIP_CALL( SCIPsetNLPIntPar(scip, SCIP_NLPPAR_VERBLEVEL, nlpverblevel) ) );
166 
167  /* it the NLP was not successfully solved we stop the heuristic right away */
168  if( !(*success) )
169  return SCIP_OKAY;
170 
171  /* count the number of variables with integral solution values in the current NLP solution */
172  for( i = 0; i < nbinvars + nintvars; ++i )
173  {
174  SCIP_Real solval;
175 
176  solval = SCIPvarGetNLPSol(vars[i]);
177 
178  if( SCIPisFeasIntegral(scip, solval) )
179  fixingcounter++;
180  }
181  }
182  else
183  {
184  assert(*startsol == 'l');
185 
186  /* compute the number of variables which have an integral solution value in the LP */
187  fixingcounter = SCIPgetNPseudoBranchCands(scip) - SCIPgetNLPBranchCands(scip);
188  }
189 
190  /* abort, if all integer variables were fixed (which should not happen for MIP),
191  * but frequently happens for MINLPs using an LP relaxation
192  */
193  if( fixingcounter == nbinvars + nintvars )
194  return SCIP_OKAY;
195 
196  *fixingrate = fixingcounter / (SCIP_Real)(MAX(nbinvars + nintvars, 1));
197 
198  /* abort, if the amount of fixed variables is insufficient */
199  if( *fixingrate < minfixingrate )
200  return SCIP_OKAY;
201 
202  *success = TRUE;
203  return SCIP_OKAY;
204 }
205 
206 /** creates a subproblem by fixing a number of variables */
207 static
209  SCIP* scip, /**< original SCIP data structure */
210  SCIP* subscip, /**< SCIP data structure for the subproblem */
211  SCIP_VAR** subvars, /**< the variables of the subproblem */
212  char startsol, /**< solution used for fixing values ('l'p relaxation, 'n'lp relaxation) */
213  SCIP_Bool binarybounds, /**< should general integers get binary bounds [floor(.),ceil(.)] ? */
214  SCIP_Bool uselprows /**< should subproblem be created out of the rows in the LP rows? */
215  )
216 {
217  SCIP_VAR** vars; /* original SCIP variables */
218 
219  int nbinvars;
220  int nintvars;
221  int i;
222 
223  assert(scip != NULL);
224  assert(subscip != NULL);
225  assert(subvars != NULL);
226 
227  assert(startsol == 'l' || startsol == 'n');
228 
229  /* get required variable data */
230  SCIP_CALL( SCIPgetVarsData(scip, &vars, NULL, &nbinvars, &nintvars, NULL, NULL) );
231 
232  /* change bounds of variables of the subproblem */
233  for( i = 0; i < nbinvars + nintvars; i++ )
234  {
235  SCIP_Real solval;
236  SCIP_Real lb;
237  SCIP_Real ub;
238 
239  /* get the current LP solution for each variable */
240  if( startsol == 'l')
241  solval = SCIPvarGetLPSol(vars[i]);
242  else
243  solval = SCIPvarGetNLPSol(vars[i]);
244 
245  if( SCIPisFeasIntegral(scip, solval) )
246  {
247  /* fix variables to current LP solution if it is integral,
248  * use exact integral value, if the variable is only integral within numerical tolerances
249  */
250  lb = SCIPfloor(scip, solval+0.5);
251  ub = lb;
252  }
253  else if( binarybounds )
254  {
255  /* if the subproblem should be a binary problem, change the bounds to nearest integers */
256  lb = SCIPfeasFloor(scip,solval);
257  ub = SCIPfeasCeil(scip,solval);
258  }
259  else
260  {
261  /* otherwise just copy bounds */
262  lb = SCIPvarGetLbGlobal(vars[i]);
263  ub = SCIPvarGetUbGlobal(vars[i]);
264  }
265 
266  /* perform the bound change */
267  SCIP_CALL( SCIPchgVarLbGlobal(subscip, subvars[i], lb) );
268  SCIP_CALL( SCIPchgVarUbGlobal(subscip, subvars[i], ub) );
269  }
270 
271  if( uselprows )
272  {
273  SCIP_ROW** rows; /* original scip rows */
274  int nrows;
275 
276  /* get the rows and their number */
277  SCIP_CALL( SCIPgetLPRowsData(scip, &rows, &nrows) );
278 
279  /* copy all rows to linear constraints */
280  for( i = 0; i < nrows; i++ )
281  {
282  SCIP_CONS* cons;
283  SCIP_VAR** consvars;
284  SCIP_COL** cols;
285  SCIP_Real constant;
286  SCIP_Real lhs;
287  SCIP_Real rhs;
288  SCIP_Real* vals;
289  int nnonz;
290  int j;
291 
292  /* ignore rows that are only locally valid */
293  if( SCIProwIsLocal(rows[i]) )
294  continue;
295 
296  /* get the row's data */
297  constant = SCIProwGetConstant(rows[i]);
298  lhs = SCIProwGetLhs(rows[i]) - constant;
299  rhs = SCIProwGetRhs(rows[i]) - constant;
300  vals = SCIProwGetVals(rows[i]);
301  nnonz = SCIProwGetNNonz(rows[i]);
302  cols = SCIProwGetCols(rows[i]);
303 
304  assert(lhs <= rhs);
305 
306  /* allocate memory array to be filled with the corresponding subproblem variables */
307  SCIP_CALL( SCIPallocBufferArray(subscip, &consvars, nnonz) );
308  for( j = 0; j < nnonz; j++ )
309  consvars[j] = subvars[SCIPvarGetProbindex(SCIPcolGetVar(cols[j]))];
310 
311  /* create a new linear constraint and add it to the subproblem */
312  SCIP_CALL( SCIPcreateConsLinear(subscip, &cons, SCIProwGetName(rows[i]), nnonz, consvars, vals, lhs, rhs,
313  TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE) );
314  SCIP_CALL( SCIPaddCons(subscip, cons) );
315  SCIP_CALL( SCIPreleaseCons(subscip, &cons) );
316 
317  /* free temporary memory */
318  SCIPfreeBufferArray(subscip, &consvars);
319  }
320  }
321 
322  return SCIP_OKAY;
323 }
324 
325 
326 /** creates a new solution for the original problem by copying the solution of the subproblem */
327 static
329  SCIP* scip, /**< original SCIP data structure */
330  SCIP* subscip, /**< SCIP structure of the subproblem */
331  SCIP_VAR** subvars, /**< the variables of the subproblem */
332  SCIP_HEUR* heur, /**< RENS heuristic structure */
333  SCIP_SOL* subsol, /**< solution of the subproblem */
334  SCIP_Bool* success /**< used to store whether new solution was found or not */
335  )
336 {
337  SCIP_VAR** vars; /* the original problem's variables */
338  int nvars; /* the original problem's number of variables */
339  SCIP_Real* subsolvals; /* solution values of the subproblem */
340  SCIP_SOL* newsol; /* solution to be created for the original problem */
341 
342  assert(scip != NULL);
343  assert(subscip != NULL);
344  assert(subvars != NULL);
345  assert(subsol != NULL);
346 
347  /* get variables' data */
348  SCIP_CALL( SCIPgetVarsData(scip, &vars, &nvars, NULL, NULL, NULL, NULL) );
349 
350  /* sub-SCIP may have more variables than the number of active (transformed) variables in the main SCIP
351  * since constraint copying may have required the copy of variables that are fixed in the main SCIP
352  */
353  assert(nvars <= SCIPgetNOrigVars(subscip));
354 
355  SCIP_CALL( SCIPallocBufferArray(scip, &subsolvals, nvars) );
356 
357  /* copy the solution */
358  SCIP_CALL( SCIPgetSolVals(subscip, subsol, nvars, subvars, subsolvals) );
359 
360  /* create new solution for the original problem */
361  SCIP_CALL( SCIPcreateSol(scip, &newsol, heur) );
362  SCIP_CALL( SCIPsetSolVals(scip, newsol, nvars, vars, subsolvals) );
363 
364  /* try to add new solution to scip and free it immediately */
365  SCIP_CALL( SCIPtrySolFree(scip, &newsol, FALSE, TRUE, TRUE, TRUE, success) );
366 
367  SCIPfreeBufferArray(scip, &subsolvals);
368 
369  return SCIP_OKAY;
370 }
371 
372 /* ---------------- Callback methods of event handler ---------------- */
373 
374 /* exec the event handler
375  *
376  * we interrupt the solution process
377  */
378 static
379 SCIP_DECL_EVENTEXEC(eventExecRens)
380 {
381  SCIP_HEURDATA* heurdata;
382 
383  assert(eventhdlr != NULL);
384  assert(eventdata != NULL);
385  assert(strcmp(SCIPeventhdlrGetName(eventhdlr), EVENTHDLR_NAME) == 0);
386  assert(event != NULL);
387  assert(SCIPeventGetType(event) & SCIP_EVENTTYPE_LPSOLVED);
388 
389  heurdata = (SCIP_HEURDATA*)eventdata;
390  assert(heurdata != NULL);
391 
392  /* interrupt solution process of sub-SCIP */
393  if( SCIPgetNLPs(scip) > heurdata->lplimfac * heurdata->nodelimit )
394  {
395  SCIPdebugMessage("interrupt after %" SCIP_LONGINT_FORMAT " LPs\n",SCIPgetNLPs(scip));
397  }
398 
399  return SCIP_OKAY;
400 }
401 
402 /* ---------------- external methods of RENS heuristic ---------------- */
403 
404 /** main procedure of the RENS heuristic, creates and solves a sub-SCIP */
406  SCIP* scip, /**< original SCIP data structure */
407  SCIP_HEUR* heur, /**< heuristic data structure */
408  SCIP_RESULT* result, /**< result data structure */
409  SCIP_Real minfixingrate, /**< minimum percentage of integer variables that have to be fixed */
410  SCIP_Real minimprove, /**< factor by which RENS should at least improve the incumbent */
411  SCIP_Longint maxnodes, /**< maximum number of nodes for the subproblem */
412  SCIP_Longint nstallnodes, /**< number of stalling nodes for the subproblem */
413  char startsol, /**< solution used for fixing values ('l'p relaxation, 'n'lp relaxation) */
414  SCIP_Bool binarybounds, /**< should general integers get binary bounds [floor(.),ceil(.)]? */
415  SCIP_Bool uselprows /**< should subproblem be created out of the rows in the LP rows? */
416  )
417 {
418  SCIP* subscip; /* the subproblem created by RENS */
419  SCIP_HASHMAP* varmapfw; /* mapping of SCIP variables to sub-SCIP variables */
420  SCIP_VAR** vars; /* original problem's variables */
421  SCIP_VAR** subvars; /* subproblem's variables */
422  SCIP_HEURDATA* heurdata; /* heuristic's private data structure */
423  SCIP_EVENTHDLR* eventhdlr; /* event handler for LP events */
424 
425  SCIP_Real cutoff; /* objective cutoff for the subproblem */
426  SCIP_Real timelimit; /* time limit for RENS subproblem */
427  SCIP_Real memorylimit; /* memory limit for RENS subproblem */
428  SCIP_Real allfixingrate; /* percentage of all variables fixed */
429  SCIP_Real intfixingrate; /* percentage of integer variables fixed */
430 
431  int nvars; /* number of original problem's variables */
432  int i;
433 
434  SCIP_Bool success;
435  SCIP_RETCODE retcode;
436 
437  assert(scip != NULL);
438  assert(heur != NULL);
439  assert(result != NULL);
440 
441  assert(maxnodes >= 0);
442  assert(nstallnodes >= 0);
443 
444  assert(0.0 <= minfixingrate && minfixingrate <= 1.0);
445  assert(0.0 <= minimprove && minimprove <= 1.0);
446  assert(startsol == 'l' || startsol == 'n');
447 
448  *result = SCIP_DIDNOTRUN;
449 
450  /* compute the number of initial fixings and check if the fixing rate exceeds the minimum fixing rate */
451  SCIP_CALL( computeFixingrate(scip, minfixingrate, &startsol, &intfixingrate, &success) );
452 
453  if( !success )
454  {
455  SCIPstatisticPrintf("RENS statistic: fixed only %5.2f integer variables --> abort \n", intfixingrate);
456  return SCIP_OKAY;
457  }
458 
459  /* get heuristic data */
460  heurdata = SCIPheurGetData(heur);
461  assert(heurdata != NULL);
462 
463  /* check whether there is enough time and memory left */
464  timelimit = 0.0;
465  memorylimit = 0.0;
466  SCIP_CALL( SCIPgetRealParam(scip, "limits/time", &timelimit) );
467  if( !SCIPisInfinity(scip, timelimit) && !heurdata->extratime )
468  timelimit -= SCIPgetSolvingTime(scip);
469  SCIP_CALL( SCIPgetRealParam(scip, "limits/memory", &memorylimit) );
470 
471  /* substract the memory already used by the main SCIP and the estimated memory usage of external software */
472  if( !SCIPisInfinity(scip, memorylimit) )
473  {
474  memorylimit -= SCIPgetMemUsed(scip)/1048576.0;
475  memorylimit -= SCIPgetMemExternEstim(scip)/1048576.0;
476  }
477 
478  /* abort if no time is left or not enough memory to create a copy of SCIP, including external memory usage */
479  if( timelimit <= 0.0 || memorylimit <= 2.0*SCIPgetMemExternEstim(scip)/1048576.0 )
480  return SCIP_OKAY;
481 
482  *result = SCIP_DIDNOTFIND;
483 
484  /* get variable data */
485  SCIP_CALL( SCIPgetVarsData(scip, &vars, &nvars, NULL, NULL, NULL, NULL) );
486 
487  /* initialize the subproblem */
488  SCIP_CALL( SCIPcreate(&subscip) );
489 
490  /* create the variable mapping hash map */
491  SCIP_CALL( SCIPhashmapCreate(&varmapfw, SCIPblkmem(subscip), SCIPcalcHashtableSize(5 * nvars)) );
492  SCIP_CALL( SCIPallocBufferArray(scip, &subvars, nvars) );
493 
494  eventhdlr = NULL;
495 
496  /* different methods to create sub-problem: either copy LP relaxation or the CIP with all constraints */
497  if( uselprows )
498  {
499  char probname[SCIP_MAXSTRLEN];
500 
501  /* copy all plugins */
503 
504  /* get name of the original problem and add the string "_renssub" */
505  (void) SCIPsnprintf(probname, SCIP_MAXSTRLEN, "%s_renssub", SCIPgetProbName(scip));
506 
507  /* create the subproblem */
508  SCIP_CALL( SCIPcreateProb(subscip, probname, NULL, NULL, NULL, NULL, NULL, NULL, NULL) );
509 
510  /* copy all variables */
511  SCIP_CALL( SCIPcopyVars(scip, subscip, varmapfw, NULL, TRUE) );
512  }
513  else
514  {
515  SCIP_Bool valid;
516 
517  valid = FALSE;
518 
519  /* copy complete SCIP instance */
520  SCIP_CALL( SCIPcopy(scip, subscip, varmapfw, NULL, "rens", TRUE, FALSE, TRUE, &valid) );
521 
522  if( heurdata->copycuts )
523  {
524  /* copies all active cuts from cutpool of sourcescip to linear constraints in targetscip */
525  SCIP_CALL( SCIPcopyCuts(scip, subscip, varmapfw, NULL, TRUE, NULL) );
526  }
527 
528  SCIPdebugMessage("Copying the SCIP instance was %s complete.\n", valid ? "" : "not ");
529 
530  /* create event handler for LP events */
531  SCIP_CALL( SCIPincludeEventhdlrBasic(subscip, &eventhdlr, EVENTHDLR_NAME, EVENTHDLR_DESC, eventExecRens, NULL) );
532  if( eventhdlr == NULL )
533  {
534  SCIPerrorMessage("event handler for " HEUR_NAME " heuristic not found.\n");
535  return SCIP_PLUGINNOTFOUND;
536  }
537  }
538 
539  for( i = 0; i < nvars; i++ )
540  subvars[i] = (SCIP_VAR*) SCIPhashmapGetImage(varmapfw, vars[i]);
541 
542  /* free hash map */
543  SCIPhashmapFree(&varmapfw);
544 
545  /* create a new problem, which fixes variables with same value in bestsol and LP relaxation */
546  SCIP_CALL( createSubproblem(scip, subscip, subvars, startsol, binarybounds, uselprows) );
547  SCIPdebugMessage("RENS subproblem: %d vars, %d cons\n", SCIPgetNVars(subscip), SCIPgetNConss(subscip));
548 
549  /* do not abort subproblem on CTRL-C */
550  SCIP_CALL( SCIPsetBoolParam(subscip, "misc/catchctrlc", FALSE) );
551 
552  /* disable output to console */
553  SCIP_CALL( SCIPsetIntParam(subscip, "display/verblevel", 0) );
554 
555  /* disable statistic timing inside sub SCIP */
556  SCIP_CALL( SCIPsetBoolParam(subscip, "timing/statistictiming", FALSE) );
557 
558  /* set limits for the subproblem */
559  heurdata->nodelimit = maxnodes;
560  SCIP_CALL( SCIPsetLongintParam(subscip, "limits/stallnodes", nstallnodes) );
561  SCIP_CALL( SCIPsetLongintParam(subscip, "limits/nodes", maxnodes) );
562  SCIP_CALL( SCIPsetRealParam(subscip, "limits/time", timelimit) );
563  SCIP_CALL( SCIPsetRealParam(subscip, "limits/memory", memorylimit) );
564 
565  /* forbid recursive call of heuristics and separators solving sub-SCIPs */
566  SCIP_CALL( SCIPsetSubscipsOff(subscip, TRUE) );
567 
568  /* disable expensive techniques that merely work on the dual bound */
569  if( !heurdata->fullscale )
570  {
571  /* disable cutting plane separation */
573 
574  /* disable expensive presolving */
576 
577  /* use best estimate node selection */
578  if( SCIPfindNodesel(subscip, "estimate") != NULL && !SCIPisParamFixed(subscip, "nodeselection/estimate/stdpriority") )
579  {
580  SCIP_CALL( SCIPsetIntParam(subscip, "nodeselection/estimate/stdpriority", INT_MAX/4) );
581  }
582 
583  /* use inference branching */
584  if( SCIPfindBranchrule(subscip, "inference") != NULL && !SCIPisParamFixed(subscip, "branching/inference/priority") )
585  {
586  SCIP_CALL( SCIPsetIntParam(subscip, "branching/inference/priority", INT_MAX/4) );
587  }
588 
589  /* disable conflict analysis */
590  if( !SCIPisParamFixed(subscip, "conflict/enable") )
591  {
592  SCIP_CALL( SCIPsetBoolParam(subscip, "conflict/enable", FALSE) );
593  }
594 
595  /* employ a limit on the number of enforcement rounds in the quadratic constraint handler; this fixes the issue that
596  * sometimes the quadratic constraint handler needs hundreds or thousands of enforcement rounds to determine the
597  * feasibility status of a single node without fractional branching candidates by separation (namely for uflquad
598  * instances); however, the solution status of the sub-SCIP might get corrupted by this; hence no deductions shall be
599  * made for the original SCIP
600  */
601  if( SCIPfindConshdlr(subscip, "quadratic") != NULL && !SCIPisParamFixed(subscip, "constraints/quadratic/enfolplimit") )
602  {
603  SCIP_CALL( SCIPsetIntParam(subscip, "constraints/quadratic/enfolplimit", 500) );
604  }
605  }
606 
607 #ifdef SCIP_DEBUG
608  /* for debugging RENS, enable MIP output */
609  SCIP_CALL( SCIPsetIntParam(subscip, "display/verblevel", 5) );
610  SCIP_CALL( SCIPsetIntParam(subscip, "display/freq", 100000000) );
611 #endif
612 
613  /* if there is already a solution, add an objective cutoff */
614  if( SCIPgetNSols(scip) > 0 )
615  {
616  SCIP_Real upperbound;
617  cutoff = SCIPinfinity(scip);
618  assert( !SCIPisInfinity(scip,SCIPgetUpperbound(scip)) );
619 
620  upperbound = SCIPgetUpperbound(scip) - SCIPsumepsilon(scip);
621 
622  if( !SCIPisInfinity(scip, -1.0 * SCIPgetLowerbound(scip)) )
623  {
624  cutoff = (1 - minimprove) * SCIPgetUpperbound(scip)
625  + minimprove * SCIPgetLowerbound(scip);
626  }
627  else
628  {
629  if( SCIPgetUpperbound(scip) >= 0 )
630  cutoff = (1 - minimprove) * SCIPgetUpperbound(scip);
631  else
632  cutoff = (1 + minimprove) * SCIPgetUpperbound(scip);
633  }
634  cutoff = MIN(upperbound, cutoff);
635  SCIP_CALL(SCIPsetObjlimit(subscip, cutoff));
636  }
637 
638  /* presolve the subproblem */
639  retcode = SCIPpresolve(subscip);
640 
641  /* errors in solving the subproblem should not kill the overall solving process;
642  * hence, the return code is caught and a warning is printed, only in debug mode, SCIP will stop.
643  */
644  if( retcode != SCIP_OKAY )
645  {
646 #ifndef NDEBUG
647  SCIP_CALL( retcode );
648 #endif
649  SCIPwarningMessage(scip, "Error while presolving subproblem in RENS heuristic; sub-SCIP terminated with code <%d>\n", retcode);
650 
651  /* free */
652  SCIPfreeBufferArray(scip, &subvars);
653  SCIP_CALL( SCIPfree(&subscip) );
654  return SCIP_OKAY;
655  }
656 
657  SCIPdebugMessage("RENS presolved subproblem: %d vars, %d cons, success=%u\n", SCIPgetNVars(subscip), SCIPgetNConss(subscip), success);
658 
659  allfixingrate = (SCIPgetNOrigVars(subscip) - SCIPgetNVars(subscip)) / (SCIP_Real)SCIPgetNOrigVars(subscip);
660 
661  /* additional variables added in presolving may lead to the subSCIP having more variables than the original */
662  allfixingrate = MAX(allfixingrate, 0.0);
663 
664  /* after presolving, we should have at least reached a certain fixing rate over ALL variables (including continuous)
665  * to ensure that not only the MIP but also the LP relaxation is easy enough
666  */
667  if( allfixingrate >= minfixingrate / 2.0 )
668  {
669  SCIP_SOL** subsols;
670  int nsubsols;
671 
672  /* catch LP events of sub-SCIP */
673  if( !heurdata->uselprows )
674  {
675  assert(eventhdlr != NULL);
676 
677  SCIP_CALL( SCIPtransformProb(subscip) );
678  SCIP_CALL( SCIPcatchEvent(subscip, SCIP_EVENTTYPE_LPSOLVED, eventhdlr, (SCIP_EVENTDATA*) heurdata, NULL) );
679  }
680 
681  /* solve the subproblem */
682  SCIPdebugMessage("solving subproblem: nstallnodes=%" SCIP_LONGINT_FORMAT ", maxnodes=%" SCIP_LONGINT_FORMAT "\n", nstallnodes, maxnodes);
683  retcode = SCIPsolve(subscip);
684 
685  /* drop LP events of sub-SCIP */
686  if( !heurdata->uselprows )
687  {
688  assert(eventhdlr != NULL);
689 
690  SCIP_CALL( SCIPdropEvent(subscip, SCIP_EVENTTYPE_LPSOLVED, eventhdlr, (SCIP_EVENTDATA*) heurdata, -1) );
691  }
692 
693  /* errors in solving the subproblem should not kill the overall solving process;
694  * hence, the return code is caught and a warning is printed, only in debug mode, SCIP will stop.
695  */
696  if( retcode != SCIP_OKAY )
697  {
698 #ifndef NDEBUG
699  SCIP_CALL( retcode );
700 #endif
701  SCIPwarningMessage(scip, "Error while solving subproblem in RENS heuristic; sub-SCIP terminated with code <%d>\n", retcode);
702  }
703  else
704  {
705  /* transfer variable statistics from sub-SCIP */
706  SCIP_CALL( SCIPmergeVariableStatistics(subscip, scip, subvars, vars, nvars) );
707  }
708 
709  /* print solving statistics of subproblem if we are in SCIP's debug mode */
711 
712  /* check, whether a solution was found;
713  * due to numerics, it might happen that not all solutions are feasible -> try all solutions until one was accepted
714  */
715  nsubsols = SCIPgetNSols(subscip);
716  subsols = SCIPgetSols(subscip);
717  success = FALSE;
718  for( i = 0; i < nsubsols && (!success || heurdata->addallsols); ++i )
719  {
720  SCIP_CALL( createNewSol(scip, subscip, subvars, heur, subsols[i], &success) );
721  if( success )
722  *result = SCIP_FOUNDSOL;
723  }
724 
725  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",
726  intfixingrate, allfixingrate, SCIPgetSolvingTime(subscip), SCIPgetNNodes(subscip), success ? SCIPgetPrimalbound(scip) : SCIPinfinity(scip),
727  nsubsols > 0 ? SCIPsolGetNodenum(SCIPgetBestSol(subscip)) : -1 );
728  }
729  else
730  {
731  SCIPstatisticPrintf("RENS statistic: fixed only %6.3f integer variables, %6.3f all variables --> abort \n", intfixingrate, allfixingrate);
732  }
733 
734  /* free subproblem */
735  SCIPfreeBufferArray(scip, &subvars);
736  SCIP_CALL( SCIPfree(&subscip) );
737 
738  return SCIP_OKAY;
739 }
740 
741 
742 /*
743  * Callback methods of primal heuristic
744  */
745 
746 /** copy method for primal heuristic plugins (called when SCIP copies plugins) */
747 static
748 SCIP_DECL_HEURCOPY(heurCopyRens)
749 { /*lint --e{715}*/
750  assert(scip != NULL);
751  assert(heur != NULL);
752  assert(strcmp(SCIPheurGetName(heur), HEUR_NAME) == 0);
753 
754  /* call inclusion method of primal heuristic */
756 
757  return SCIP_OKAY;
758 }
759 
760 /** destructor of primal heuristic to free user data (called when SCIP is exiting) */
761 static
762 SCIP_DECL_HEURFREE(heurFreeRens)
763 { /*lint --e{715}*/
764  SCIP_HEURDATA* heurdata;
765 
766  assert( heur != NULL );
767  assert( scip != NULL );
768 
769  /* get heuristic data */
770  heurdata = SCIPheurGetData(heur);
771  assert( heurdata != NULL );
772 
773  /* free heuristic data */
774  SCIPfreeMemory(scip, &heurdata);
775  SCIPheurSetData(heur, NULL);
776 
777  return SCIP_OKAY;
778 }
779 
780 /** initialization method of primal heuristic (called after problem was transformed) */
781 static
782 SCIP_DECL_HEURINIT(heurInitRens)
783 { /*lint --e{715}*/
784  SCIP_HEURDATA* heurdata;
785 
786  assert( heur != NULL );
787  assert( scip != NULL );
788 
789  /* get heuristic data */
790  heurdata = SCIPheurGetData(heur);
791  assert( heurdata != NULL );
792 
793  /* initialize data */
794  heurdata->usednodes = 0;
795 
796  return SCIP_OKAY;
797 }
798 
799 
800 /** execution method of primal heuristic */
801 static
802 SCIP_DECL_HEUREXEC(heurExecRens)
803 { /*lint --e{715}*/
804 
805  SCIP_HEURDATA* heurdata; /* heuristic's data */
806  SCIP_Longint nstallnodes; /* number of stalling nodes for the subproblem */
807 
808  assert( heur != NULL );
809  assert( scip != NULL );
810  assert( result != NULL );
811  assert( SCIPhasCurrentNodeLP(scip) );
812 
813  *result = SCIP_DELAYED;
814 
815  /* do not call heuristic of node was already detected to be infeasible */
816  if( nodeinfeasible )
817  return SCIP_OKAY;
818 
819  /* get heuristic data */
820  heurdata = SCIPheurGetData(heur);
821  assert( heurdata != NULL );
822 
823  /* only call heuristic, if an optimal LP solution is at hand */
824  if( heurdata->startsol == 'l' && SCIPgetLPSolstat(scip) != SCIP_LPSOLSTAT_OPTIMAL )
825  return SCIP_OKAY;
826 
827  /* only call heuristic, if the LP objective value is smaller than the cutoff bound */
828  if( heurdata->startsol == 'l' && SCIPisGE(scip, SCIPgetLPObjval(scip), SCIPgetCutoffbound(scip)) )
829  return SCIP_OKAY;
830 
831  /* only continue with some fractional variables */
832  if( heurdata->startsol == 'l' && SCIPgetNLPBranchCands(scip) == 0 )
833  return SCIP_OKAY;
834 
835  /* do not proceed, when we should use the NLP relaxation, but there is no NLP solver included in SCIP */
836  if( heurdata->startsol == 'n' && SCIPgetNNlpis(scip) == 0 )
837  return SCIP_OKAY;
838 
839  *result = SCIP_DIDNOTRUN;
840 
841  /* calculate the maximal number of branching nodes until heuristic is aborted */
842  nstallnodes = (SCIP_Longint)(heurdata->nodesquot * SCIPgetNNodes(scip));
843 
844  /* reward RENS if it succeeded often */
845  nstallnodes = (SCIP_Longint)(nstallnodes * 3.0 * (SCIPheurGetNBestSolsFound(heur)+1.0)/(SCIPheurGetNCalls(heur) + 1.0));
846  nstallnodes -= 100 * SCIPheurGetNCalls(heur); /* count the setup costs for the sub-SCIP as 100 nodes */
847  nstallnodes += heurdata->nodesofs;
848 
849  /* determine the node limit for the current process */
850  nstallnodes -= heurdata->usednodes;
851  nstallnodes = MIN(nstallnodes, heurdata->maxnodes);
852 
853  /* check whether we have enough nodes left to call subproblem solving */
854  if( nstallnodes < heurdata->minnodes )
855  {
856  SCIPdebugMessage("skipping RENS: nstallnodes=%" SCIP_LONGINT_FORMAT ", minnodes=%" SCIP_LONGINT_FORMAT "\n", nstallnodes, heurdata->minnodes);
857  return SCIP_OKAY;
858  }
859 
860  if( SCIPisStopped(scip) && !heurdata->extratime )
861  return SCIP_OKAY;
862 
863  SCIP_CALL( SCIPapplyRens(scip, heur, result, heurdata->minfixingrate, heurdata->minimprove,
864  heurdata->maxnodes, nstallnodes, heurdata->startsol, heurdata->binarybounds, heurdata->uselprows) );
865 
866  return SCIP_OKAY;
867 }
868 
869 
870 /*
871  * primal heuristic specific interface methods
872  */
873 
874 /** creates the rens primal heuristic and includes it in SCIP */
876  SCIP* scip /**< SCIP data structure */
877  )
878 {
879  SCIP_HEURDATA* heurdata;
880  SCIP_HEUR* heur;
881 
882  /* create Rens primal heuristic data */
883  SCIP_CALL( SCIPallocMemory(scip, &heurdata) );
884 
885  /* include primal heuristic */
886  SCIP_CALL( SCIPincludeHeurBasic(scip, &heur,
888  HEUR_MAXDEPTH, HEUR_TIMING, HEUR_USESSUBSCIP, heurExecRens, heurdata) );
889 
890  assert(heur != NULL);
891 
892  /* set non-NULL pointers to callback methods */
893  SCIP_CALL( SCIPsetHeurCopy(scip, heur, heurCopyRens) );
894  SCIP_CALL( SCIPsetHeurFree(scip, heur, heurFreeRens) );
895  SCIP_CALL( SCIPsetHeurInit(scip, heur, heurInitRens) );
896 
897  /* add rens primal heuristic parameters */
898 
899  SCIP_CALL( SCIPaddRealParam(scip, "heuristics/" HEUR_NAME "/minfixingrate",
900  "minimum percentage of integer variables that have to be fixable",
901  &heurdata->minfixingrate, FALSE, DEFAULT_MINFIXINGRATE, 0.0, 1.0, NULL, NULL) );
902 
903  SCIP_CALL( SCIPaddLongintParam(scip, "heuristics/" HEUR_NAME "/maxnodes",
904  "maximum number of nodes to regard in the subproblem",
905  &heurdata->maxnodes, TRUE,DEFAULT_MAXNODES, 0LL, SCIP_LONGINT_MAX, NULL, NULL) );
906 
907  SCIP_CALL( SCIPaddLongintParam(scip, "heuristics/" HEUR_NAME "/nodesofs",
908  "number of nodes added to the contingent of the total nodes",
909  &heurdata->nodesofs, FALSE, DEFAULT_NODESOFS, 0LL, SCIP_LONGINT_MAX, NULL, NULL) );
910 
911  SCIP_CALL( SCIPaddLongintParam(scip, "heuristics/" HEUR_NAME "/minnodes",
912  "minimum number of nodes required to start the subproblem",
913  &heurdata->minnodes, TRUE, DEFAULT_MINNODES, 0LL, SCIP_LONGINT_MAX, NULL, NULL) );
914 
915  SCIP_CALL( SCIPaddRealParam(scip, "heuristics/" HEUR_NAME "/nodesquot",
916  "contingent of sub problem nodes in relation to the number of nodes of the original problem",
917  &heurdata->nodesquot, FALSE, DEFAULT_NODESQUOT, 0.0, 1.0, NULL, NULL) );
918 
919  SCIP_CALL( SCIPaddRealParam(scip, "heuristics/" HEUR_NAME "/minimprove",
920  "factor by which RENS should at least improve the incumbent",
921  &heurdata->minimprove, TRUE, DEFAULT_MINIMPROVE, 0.0, 1.0, NULL, NULL) );
922 
923  SCIP_CALL( SCIPaddRealParam(scip, "heuristics/" HEUR_NAME "/lplimfac",
924  "factor by which the limit on the number of LP depends on the node limit",
925  &heurdata->lplimfac, TRUE, DEFAULT_LPLIMFAC, 1.0, SCIP_REAL_MAX, NULL, NULL) );
926 
927  SCIP_CALL( SCIPaddCharParam(scip, "heuristics/" HEUR_NAME "/startsol",
928  "solution that is used for fixing values ('l'p relaxation, 'n'lp relaxation)",
929  &heurdata->startsol, FALSE, DEFAULT_STARTSOL, STARTSOL_CHOICES, NULL, NULL) );
930 
931  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/" HEUR_NAME "/binarybounds",
932  "should general integers get binary bounds [floor(.),ceil(.)] ?",
933  &heurdata->binarybounds, TRUE, DEFAULT_BINARYBOUNDS, NULL, NULL) );
934 
935  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/" HEUR_NAME "/uselprows",
936  "should subproblem be created out of the rows in the LP rows?",
937  &heurdata->uselprows, TRUE, DEFAULT_USELPROWS, NULL, NULL) );
938 
939  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/" HEUR_NAME "/copycuts",
940  "if uselprows == FALSE, should all active cuts from cutpool be copied to constraints in subproblem?",
941  &heurdata->copycuts, TRUE, DEFAULT_COPYCUTS, NULL, NULL) );
942 
943  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/" HEUR_NAME "/extratime",
944  "should the RENS sub-CIP get its own full time limit? This is only for tesing and not recommended!",
945  &heurdata->extratime, TRUE, DEFAULT_EXTRATIME, NULL, NULL) );
946 
947  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/" HEUR_NAME "/addallsols",
948  "should all subproblem solutions be added to the original SCIP?",
949  &heurdata->addallsols, TRUE, DEFAULT_ADDALLSOLS, NULL, NULL) );
950 
951  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/" HEUR_NAME "/fullscale",
952  "should the RENS sub-CIP be solved with cuts, conflicts, strong branching,... This is only for tesing and not recommended!",
953  &heurdata->fullscale, TRUE, DEFAULT_FULLSCALE, NULL, NULL) );
954 
955  return SCIP_OKAY;
956 }
enum SCIP_Result SCIP_RESULT
Definition: type_result.h:51
int SCIPgetNLPBranchCands(SCIP *scip)
Definition: scip.c:33158
static SCIP_DECL_HEURINIT(heurInitRens)
Definition: heur_rens.c:782
SCIP_RETCODE SCIPsetNLPIntPar(SCIP *scip, SCIP_NLPPARAM type, int ival)
Definition: scip.c:28969
#define DEFAULT_BINARYBOUNDS
Definition: heur_rens.c:44
static SCIP_DECL_HEUREXEC(heurExecRens)
Definition: heur_rens.c:802
SCIP_RETCODE SCIPprintStatistics(SCIP *scip, FILE *file)
Definition: scip.c:40329
int SCIPgetNVars(SCIP *scip)
Definition: scip.c:10698
SCIP_CONSHDLR * SCIPfindConshdlr(SCIP *scip, const char *name)
Definition: scip.c:5878
#define SCIPallocMemory(scip, ptr)
Definition: scip.h:20526
#define SCIP_EVENTTYPE_LPSOLVED
Definition: type_event.h:78
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:405
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
Definition: scip.c:41648
const char * SCIPheurGetName(SCIP_HEUR *heur)
Definition: heur.c:1147
SCIP_Longint SCIPheurGetNCalls(SCIP_HEUR *heur)
Definition: heur.c:1273
SCIP_RETCODE SCIPsetHeurCopy(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURCOPY((*heurcopy)))
Definition: scip.c:7297
static SCIP_RETCODE createSubproblem(SCIP *scip, SCIP *subscip, SCIP_VAR **subvars, char startsol, SCIP_Bool binarybounds, SCIP_Bool uselprows)
Definition: heur_rens.c:208
#define HEUR_PRIORITY
Definition: heur_rens.c:36
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
Definition: scip.c:1248
#define SCIP_MAXSTRLEN
Definition: def.h:201
#define NULL
Definition: lpi_spx.cpp:130
SCIP_Bool SCIPisStopped(SCIP *scip)
Definition: scip.c:1125
SCIP_Real SCIPfeasFloor(SCIP *scip, SCIP_Real val)
Definition: scip.c:42032
SCIP_Real SCIProwGetLhs(SCIP_ROW *row)
Definition: lp.c:18915
SCIP_COL ** SCIProwGetCols(SCIP_ROW *row)
Definition: lp.c:18861
SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
Definition: var.c:17067
#define DEFAULT_EXTRATIME
Definition: heur_rens.c:59
#define DEFAULT_MINNODES
Definition: heur_rens.c:48
SCIP_RETCODE SCIPincludeHeurBasic(SCIP *scip, SCIP_HEUR **heur, const char *name, const char *desc, char dispchar, int priority, int freq, int freqofs, int maxdepth, unsigned int timingmask, SCIP_Bool usessubscip, SCIP_DECL_HEUREXEC((*heurexec)), SCIP_HEURDATA *heurdata)
Definition: scip.c:7252
#define FALSE
Definition: def.h:56
SCIP_RETCODE SCIPhashmapCreate(SCIP_HASHMAP **hashmap, BMS_BLKMEM *blkmem, int mapsize)
Definition: misc.c:2057
SCIP_Real SCIPgetSolvingTime(SCIP *scip)
Definition: scip.c:41009
SCIP_RETCODE SCIPsetLongintParam(SCIP *scip, const char *name, SCIP_Longint value)
Definition: scip.c:4046
int SCIPgetNPseudoBranchCands(SCIP *scip)
Definition: scip.c:33489
SCIP_RETCODE SCIPincludeEventhdlrBasic(SCIP *scip, SCIP_EVENTHDLR **eventhdlrptr, const char *name, const char *desc, SCIP_DECL_EVENTEXEC((*eventexec)), SCIP_EVENTHDLRDATA *eventhdlrdata)
Definition: scip.c:7778
int SCIPsnprintf(char *t, int len, const char *s,...)
Definition: misc.c:8174
#define TRUE
Definition: def.h:55
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
SCIP_RETCODE SCIPsolveNLP(SCIP *scip)
Definition: scip.c:28767
SCIP_NLPSOLSTAT SCIPgetNLPSolstat(SCIP *scip)
Definition: scip.c:28790
#define SCIP_CALL(x)
Definition: def.h:266
SCIP_RETCODE SCIPtrySolFree(SCIP *scip, SCIP_SOL **sol, SCIP_Bool printreason, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *stored)
Definition: scip.c:36299
#define HEUR_FREQ
Definition: heur_rens.c:37
SCIP_RETCODE SCIPsetRealParam(SCIP *scip, const char *name, SCIP_Real value)
Definition: scip.c:4109
struct SCIP_HeurData SCIP_HEURDATA
Definition: type_heur.h:51
SCIP_Bool SCIPisFeasIntegral(SCIP *scip, SCIP_Real val)
Definition: scip.c:42008
SCIP_Real SCIPgetCutoffbound(SCIP *scip)
Definition: scip.c:38561
SCIP_LPSOLSTAT SCIPgetLPSolstat(SCIP *scip)
Definition: scip.c:26439
SCIP_RETCODE SCIPaddLongintParam(SCIP *scip, const char *name, const char *desc, SCIP_Longint *valueptr, SCIP_Bool isadvanced, SCIP_Longint defaultvalue, SCIP_Longint minvalue, SCIP_Longint maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
Definition: scip.c:3601
#define SCIPdebugMessage
Definition: pub_message.h:77
#define EVENTHDLR_NAME
Definition: heur_rens.c:70
void * SCIPhashmapGetImage(SCIP_HASHMAP *hashmap, void *origin)
Definition: misc.c:2116
SCIP_Real SCIProwGetConstant(SCIP_ROW *row)
Definition: lp.c:18881
#define DEFAULT_STARTSOL
Definition: heur_rens.c:52
#define SCIP_LONGINT_MAX
Definition: def.h:113
SCIP_RETCODE SCIPreleaseCons(SCIP *scip, SCIP_CONS **cons)
Definition: scip.c:24949
SCIP_Real SCIPgetLPObjval(SCIP *scip)
Definition: scip.c:26482
SCIP_Real SCIPfeasCeil(SCIP *scip, SCIP_Real val)
Definition: scip.c:42044
SCIP_Real SCIPgetLowerbound(SCIP *scip)
Definition: scip.c:38393
SCIP_RETCODE SCIPcopyCuts(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool global, int *ncutsadded)
Definition: scip.c:2883
int SCIPgetNSols(SCIP *scip)
Definition: scip.c:35668
SCIP_RETCODE SCIPaddBoolParam(SCIP *scip, const char *name, const char *desc, SCIP_Bool *valueptr, SCIP_Bool isadvanced, SCIP_Bool defaultvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
Definition: scip.c:3547
int SCIPgetNOrigVars(SCIP *scip)
Definition: scip.c:11138
#define DEFAULT_MINIMPROVE
Definition: heur_rens.c:47
#define SCIPfreeMemory(scip, ptr)
Definition: scip.h:20542
int SCIPgetNConss(SCIP *scip)
Definition: scip.c:11736
SCIP_RETCODE SCIPinterruptSolve(SCIP *scip)
Definition: scip.c:15442
static SCIP_RETCODE createNewSol(SCIP *scip, SCIP *subscip, SCIP_VAR **subvars, SCIP_HEUR *heur, SCIP_SOL *subsol, SCIP_Bool *success)
Definition: heur_rens.c:328
SCIP_RETCODE SCIPcopy(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, const char *suffix, SCIP_Bool global, SCIP_Bool enablepricing, SCIP_Bool passmessagehdlr, SCIP_Bool *valid)
Definition: scip.c:3254
#define STARTSOL_CHOICES
Definition: heur_rens.c:53
#define DEFAULT_USELPROWS
Definition: heur_rens.c:54
SCIP_RETCODE SCIPchgVarUbGlobal(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
Definition: scip.c:20049
#define SCIPerrorMessage
Definition: pub_message.h:45
SCIP_Real SCIProwGetRhs(SCIP_ROW *row)
Definition: lp.c:18925
enum SCIP_NlpSolStat SCIP_NLPSOLSTAT
Definition: type_nlpi.h:69
SCIP_RETCODE SCIPmergeVariableStatistics(SCIP *sourcescip, SCIP *targetscip, SCIP_VAR **sourcevars, SCIP_VAR **targetvars, int nvars)
Definition: scip.c:2260
int SCIPcalcHashtableSize(int minsize)
Definition: misc.c:1157
#define HEUR_USESSUBSCIP
Definition: heur_rens.c:41
SCIP_Bool SCIPisNLPConstructed(SCIP *scip)
Definition: scip.c:28407
SCIP_RETCODE SCIPcreateSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
Definition: scip.c:34002
BMS_BLKMEM * SCIPblkmem(SCIP *scip)
Definition: scip.c:41353
#define DEFAULT_MAXNODES
Definition: heur_rens.c:45
SCIP_Real SCIPfloor(SCIP *scip, SCIP_Real val)
Definition: scip.c:41758
SCIP_Bool SCIProwIsLocal(SCIP_ROW *row)
Definition: lp.c:19024
struct SCIP_EventData SCIP_EVENTDATA
Definition: type_event.h:146
void SCIPhashmapFree(SCIP_HASHMAP **hashmap)
Definition: misc.c:2075
SCIP_RETCODE SCIPsetSeparating(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
Definition: scip.c:4457
SCIP_RETCODE SCIPcreateProb(SCIP *scip, const char *name, SCIP_DECL_PROBDELORIG((*probdelorig)), SCIP_DECL_PROBTRANS((*probtrans)), SCIP_DECL_PROBDELTRANS((*probdeltrans)), SCIP_DECL_PROBINITSOL((*probinitsol)), SCIP_DECL_PROBEXITSOL((*probexitsol)), SCIP_DECL_PROBCOPY((*probcopy)), SCIP_PROBDATA *probdata)
Definition: scip.c:9019
SCIP_RETCODE SCIPgetLPRowsData(SCIP *scip, SCIP_ROW ***rows, int *nrows)
Definition: scip.c:26750
SCIP_RETCODE SCIPgetSolVals(SCIP *scip, SCIP_SOL *sol, int nvars, SCIP_VAR **vars, SCIP_Real *vals)
Definition: scip.c:35020
static SCIP_DECL_HEURFREE(heurFreeRens)
Definition: heur_rens.c:762
SCIP_Real SCIPinfinity(SCIP *scip)
Definition: scip.c:41637
SCIP_RETCODE SCIPpresolve(SCIP *scip)
Definition: scip.c:14342
SCIP_Bool SCIPhasCurrentNodeLP(SCIP *scip)
Definition: scip.c:26354
#define DEFAULT_LPLIMFAC
Definition: heur_rens.c:51
#define SCIPstatisticPrintf
Definition: pub_message.h:107
SCIP_RETCODE SCIPfree(SCIP **scip)
Definition: scip.c:766
SCIP_SOL ** SCIPgetSols(SCIP *scip)
Definition: scip.c:35717
SCIP_Longint SCIPgetNLPs(SCIP *scip)
Definition: scip.c:37435
const char * SCIProwGetName(SCIP_ROW *row)
Definition: lp.c:18974
LNS heuristic that finds the optimal rounding to a given point.
SCIP_RETCODE SCIPtransformProb(SCIP *scip)
Definition: scip.c:12623
void SCIPheurSetData(SCIP_HEUR *heur, SCIP_HEURDATA *heurdata)
Definition: heur.c:1068
SCIP_Real SCIPgetUpperbound(SCIP *scip)
Definition: scip.c:38534
#define DEFAULT_MINFIXINGRATE
Definition: heur_rens.c:46
static SCIP_RETCODE computeFixingrate(SCIP *scip, SCIP_Real minfixingrate, char *startsol, SCIP_Real *fixingrate, SCIP_Bool *success)
Definition: heur_rens.c:109
public data structures and miscellaneous methods
SCIP_RETCODE SCIPincludeHeurRens(SCIP *scip)
Definition: heur_rens.c:875
#define HEUR_MAXDEPTH
Definition: heur_rens.c:39
SCIP_Real SCIPvarGetNLPSol(SCIP_VAR *var)
Definition: var.c:17444
#define HEUR_TIMING
Definition: heur_rens.c:40
#define DEFAULT_NODESOFS
Definition: heur_rens.c:49
#define SCIP_Bool
Definition: def.h:53
SCIP_RETCODE SCIPincludeDefaultPlugins(SCIP *scip)
#define HEUR_DESC
Definition: heur_rens.c:34
#define HEUR_NAME
Definition: heur_rens.c:33
SCIP_RETCODE SCIPsetIntParam(SCIP *scip, const char *name, int value)
Definition: scip.c:4001
SCIP_Bool SCIPisParamFixed(SCIP *scip, const char *name)
Definition: scip.c:3709
SCIP_Longint SCIPsolGetNodenum(SCIP_SOL *sol)
Definition: sol.c:2232
SCIP_RETCODE SCIPsetSubscipsOff(SCIP *scip, SCIP_Bool quiet)
Definition: scip.c:4382
SCIP_RETCODE SCIPcopyVars(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool global)
Definition: scip.c:2179
#define MAX(x, y)
Definition: tclique_def.h:75
static SCIP_DECL_HEURCOPY(heurCopyRens)
Definition: heur_rens.c:748
SCIP_Longint SCIPgetMemUsed(SCIP *scip)
Definition: scip.c:41396
SCIP_RETCODE SCIPsetPresolving(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
Definition: scip.c:4431
Constraint handler for linear constraints in their most general form, .
SCIP_Bool SCIPisGE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
Definition: scip.c:41624
SCIP_RETCODE SCIPsetHeurInit(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURINIT((*heurinit)))
Definition: scip.c:7329
SCIP_Real SCIPvarGetLPSol(SCIP_VAR *var)
Definition: var.c:17431
#define SCIP_REAL_MAX
Definition: def.h:128
SCIP_RETCODE SCIPaddCons(SCIP *scip, SCIP_CONS *cons)
Definition: scip.c:11477
#define DEFAULT_ADDALLSOLS
Definition: heur_rens.c:62
SCIP_RETCODE SCIPsolve(SCIP *scip)
Definition: scip.c:14503
SCIP_Longint SCIPheurGetNBestSolsFound(SCIP_HEUR *heur)
Definition: heur.c:1293
#define SCIPallocBufferArray(scip, ptr, num)
Definition: scip.h:20585
SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
Definition: var.c:17057
SCIP_RETCODE SCIPcreate(SCIP **scip)
Definition: scip.c:692
SCIP_RETCODE SCIPdropEvent(SCIP *scip, SCIP_EVENTTYPE eventtype, SCIP_EVENTHDLR *eventhdlr, SCIP_EVENTDATA *eventdata, int filterpos)
Definition: scip.c:36588
#define HEUR_DISPCHAR
Definition: heur_rens.c:35
SCIP_RETCODE SCIPcreateConsLinear(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, SCIP_Real *vals, SCIP_Real lhs, SCIP_Real rhs, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode)
SCIP_Real SCIPgetPrimalbound(SCIP *scip)
Definition: scip.c:38510
SCIP_Real * SCIProwGetVals(SCIP_ROW *row)
Definition: lp.c:18871
const char * SCIPeventhdlrGetName(SCIP_EVENTHDLR *eventhdlr)
Definition: event.c:278
SCIP_RETCODE SCIPsetHeurFree(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURFREE((*heurfree)))
Definition: scip.c:7313
int SCIPvarGetProbindex(SCIP_VAR *var)
Definition: var.c:16750
SCIP_BRANCHRULE * SCIPfindBranchrule(SCIP *scip, const char *name)
Definition: scip.c:8436
#define SCIP_Real
Definition: def.h:127
SCIP_RETCODE SCIPaddCharParam(SCIP *scip, const char *name, const char *desc, char *valueptr, SCIP_Bool isadvanced, char defaultvalue, const char *allowedvalues, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
Definition: scip.c:3657
#define MIN(x, y)
Definition: memory.c:67
#define HEUR_FREQOFS
Definition: heur_rens.c:38
SCIP_RETCODE SCIPchgVarLbGlobal(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
Definition: scip.c:19972
SCIP_RETCODE SCIPsetObjlimit(SCIP *scip, SCIP_Real objlimit)
Definition: scip.c:10194
const char * SCIPgetProbName(SCIP *scip)
Definition: scip.c:9941
SCIP_RETCODE SCIPsetNLPInitialGuessSol(SCIP *scip, SCIP_SOL *sol)
Definition: scip.c:28735
#define SCIP_Longint
Definition: def.h:112
int SCIPgetNNlpis(SCIP *scip)
Definition: scip.c:8685
SCIP_EVENTTYPE SCIPeventGetType(SCIP_EVENT *event)
Definition: event.c:917
SCIP_RETCODE SCIPsetSolVals(SCIP *scip, SCIP_SOL *sol, int nvars, SCIP_VAR **vars, SCIP_Real *vals)
Definition: scip.c:34885
SCIP_RETCODE SCIPsetBoolParam(SCIP *scip, const char *name, SCIP_Bool value)
Definition: scip.c:3938
int SCIProwGetNNonz(SCIP_ROW *row)
Definition: lp.c:18836
SCIP_HEURDATA * SCIPheurGetData(SCIP_HEUR *heur)
Definition: heur.c:1058
SCIP_RETCODE SCIPgetVarsData(SCIP *scip, SCIP_VAR ***vars, int *nvars, int *nbinvars, int *nintvars, int *nimplvars, int *ncontvars)
Definition: scip.c:10572
#define SCIPfreeBufferArray(scip, ptr)
Definition: scip.h:20597
SCIP_RETCODE SCIPgetRealParam(SCIP *scip, const char *name, SCIP_Real *value)
Definition: scip.c:3797
#define SCIPdebug(x)
Definition: pub_message.h:74
#define DEFAULT_COPYCUTS
Definition: heur_rens.c:56
SCIP_NODESEL * SCIPfindNodesel(SCIP *scip, const char *name)
Definition: scip.c:8124
#define DEFAULT_FULLSCALE
Definition: heur_rens.c:64
SCIP_VAR * SCIPcolGetVar(SCIP_COL *col)
Definition: lp.c:18685
SCIP_RETCODE SCIPgetNLPIntPar(SCIP *scip, SCIP_NLPPARAM type, int *ival)
Definition: scip.c:28941
SCIP_SOL * SCIPgetBestSol(SCIP *scip)
Definition: scip.c:35767
SCIP_RETCODE SCIPaddRealParam(SCIP *scip, const char *name, const char *desc, SCIP_Real *valueptr, SCIP_Bool isadvanced, SCIP_Real defaultvalue, SCIP_Real minvalue, SCIP_Real maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
Definition: scip.c:3629
SCIP_Real SCIPsumepsilon(SCIP *scip)
Definition: scip.c:41132
#define DEFAULT_NODESQUOT
Definition: heur_rens.c:50
default SCIP plugins
#define EVENTHDLR_DESC
Definition: heur_rens.c:71
SCIP_Longint SCIPgetNNodes(SCIP *scip)
Definition: scip.c:37372
SCIP callable library.
static SCIP_DECL_EVENTEXEC(eventExecRens)
Definition: heur_rens.c:379
SCIP_RETCODE SCIPcatchEvent(SCIP *scip, SCIP_EVENTTYPE eventtype, SCIP_EVENTHDLR *eventhdlr, SCIP_EVENTDATA *eventdata, int *filterpos)
Definition: scip.c:36554
SCIP_Longint SCIPgetMemExternEstim(SCIP *scip)
Definition: scip.c:41409