Scippy

SCIP

Solving Constraint Integer Programs

heur_proximity.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-2014 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_proximity.c
17  * @brief improvement heuristic which uses an auxiliary objective instead of the original objective function which
18  * is itself added as a constraint to a sub-SCIP instance. The heuristic was presented by Matteo Fischetti
19  * and Michele Monaci
20  *
21  *
22  * @author Gregor Hendel
23  */
24 
25 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
26 
27 #include <assert.h>
28 #include <string.h>
29 
30 #include "scip/heur_proximity.h"
31 #include "scip/cons_linear.h"
32 
33 #define HEUR_NAME "proximity"
34 #define HEUR_DESC "heuristic trying to improve the incumbent by an auxiliary proximity objective function"
35 #define HEUR_DISPCHAR 'P'
36 #define HEUR_PRIORITY -2000000
37 #define HEUR_FREQ -1
38 #define HEUR_FREQOFS 0
39 #define HEUR_MAXDEPTH -1
40 #define HEUR_TIMING SCIP_HEURTIMING_AFTERNODE
41 #define HEUR_USESSUBSCIP TRUE /**< does the heuristic use a secondary SCIP instance? */
42 
43 /* event handler properties */
44 #define EVENTHDLR_NAME "Proximity"
45 #define EVENTHDLR_DESC "LP event handler for "HEUR_NAME" heuristic"
46 
47 /* default values for proximity-specific parameters */
48 /* todo refine these values */
49 #define DEFAULT_MAXNODES 10000LL /* maximum number of nodes to regard in the subproblem */
50 #define DEFAULT_MINIMPROVE 0.25 /* factor by which proximity should at least improve the incumbent */
51 #define DEFAULT_MINGAP 0.01 /* minimum primal-dual gap for which the heuristic is executed */
52 #define DEFAULT_MINNODES 1LL /* minimum number of nodes to regard in the subproblem */
53 #define DEFAULT_MINLPITERS 200LL /* minimum number of LP iterations to perform in one sub-mip */
54 #define DEFAULT_MAXLPITERS 100000LL /* maximum number of LP iterations to be performed in the subproblem */
55 #define DEFAULT_NODESOFS 50LL /* number of nodes added to the contingent of the total nodes */
56 #define DEFAULT_WAITINGNODES 100LL /* default waiting nodes since last incumbent before heuristic is executed */
57 #define DEFAULT_NODESQUOT 0.1 /* default quotient of sub-MIP nodes with respect to number of processed nodes*/
58 #define DEFAULT_USELPROWS FALSE /* should subproblem be constructed based on LP row information? */
59 #define DEFAULT_BINVARQUOT 0.1 /* default threshold for percentage of binary variables required to start */
60 #define DEFAULT_RESTART TRUE /* should the heuristic immediately run again on its newly found solution? */
61 #define DEFAULT_USEFINALLP TRUE /* should the heuristic solve a final LP in case of continuous objective variables? */
62 #define DEFAULT_LPITERSQUOT 0.2 /* default quotient of sub-MIP LP iterations with respect to LP iterations so far */
63 
64 /*
65  * Data structures
66  */
67 
68 /** primal heuristic data */
69 struct SCIP_HeurData
70 {
71  SCIP_Longint maxnodes; /**< maximum number of nodes to regard in the subproblem */
72  SCIP_Longint minnodes; /**< minimum number of nodes to regard in the subproblem */
73  SCIP_Longint maxlpiters; /**< maximum number of LP iterations to be performed in the subproblem */
74  SCIP_Longint nusedlpiters; /**< number of actually performed LP iterations */
75  SCIP_Longint minlpiters; /**< minimum number of LP iterations to perform in one sub-mip */
76  SCIP_Longint nodesofs; /**< number of nodes added to the contingent of the total nodes */
77  SCIP_Longint usednodes; /**< nodes already used by proximity in earlier calls */
78  SCIP_Longint waitingnodes; /**< waiting nodes since last incumbent before heuristic is executed */
79  SCIP_Real lpitersquot; /**< quotient of sub-MIP LP iterations with respect to LP iterations so far */
80  SCIP_Real minimprove; /**< factor by which proximity should at least improve the incumbent */
81  SCIP_Real mingap; /**< minimum primal-dual gap for which the heuristic is executed */
82  SCIP_Real nodesquot; /**< quotient of sub-MIP nodes with respect to number of processed nodes */
83  SCIP_Real binvarquot; /**< threshold for percantage of binary variables required to start */
84 
85  SCIP* subscip; /**< the subscip used by the heuristic */
86  SCIP_HASHMAP* varmapfw; /**< map between scip variables and subscip variables */
87  SCIP_VAR** subvars; /**< variables in subscip */
88  SCIP_CONS* objcons; /**< the objective cutoff constraint of the subproblem */
89 
90  int nsubvars; /**< the number of subvars */
91  int lastsolidx; /**< index of last solution on which the heuristic was processed */
92  int subprobidx; /**< counter for the subproblem index to be solved by proximity */
93 
94  SCIP_Bool uselprows; /**< should subproblem be constructed based on LP row information? */
95  SCIP_Bool restart; /* should the heuristic immediately run again on its newly found solution? */
96  SCIP_Bool usefinallp; /* should the heuristic solve a final LP in case of continuous objective variables? */
97 };
98 
99 
100 /*
101  * Local methods
102  */
103 
104 /** optimizes the continuous variables in an LP diving by fixing all integer variables to the given solution values */
105 static
107  SCIP* scip, /* SCIP data structure */
108  SCIP_SOL* sol, /* current incumbent */
109  SCIP_Bool* success /* was the dive successful? */
110 )
111 {
112  SCIP_VAR** vars;
113  SCIP_RETCODE retstat;
114 
115  int v;
116  int nvars;
117  int ncontvars;
118  int nintvars;
119 
120  SCIP_Bool lperror;
121  SCIP_Bool requiresnlp;
122 
123  assert(success != NULL);
124 
125  SCIP_CALL( SCIPgetVarsData(scip, &vars, &nvars, NULL, NULL, NULL, &ncontvars) );
126 
127  nintvars = nvars - ncontvars;
128 
129  /**@todo in case of an MINLP, if SCIPisNLPConstructed() is TRUE rather solve the NLP instead of the LP */
130  requiresnlp = SCIPisNLPConstructed(scip);
131  if( requiresnlp || ncontvars == 0 )
132  return SCIP_OKAY;
133 
134  /* start diving to calculate the LP relaxation */
135  SCIP_CALL( SCIPstartDive(scip) );
136 
137  /* set the bounds of the variables: fixed for integers, global bounds for continuous */
138  for( v = 0; v < nvars; ++v )
139  {
140  if( SCIPvarGetStatus(vars[v]) == SCIP_VARSTATUS_COLUMN )
141  {
142  SCIP_CALL( SCIPchgVarLbDive(scip, vars[v], SCIPvarGetLbGlobal(vars[v])) );
143  SCIP_CALL( SCIPchgVarUbDive(scip, vars[v], SCIPvarGetUbGlobal(vars[v])) );
144  }
145  }
146  /* apply this after global bounds to not cause an error with intermediate empty domains */
147  for( v = 0; v < nintvars; ++v )
148  {
149  if( SCIPvarGetStatus(vars[v]) == SCIP_VARSTATUS_COLUMN )
150  {
151  SCIP_Real solval;
152 
153  solval = SCIPgetSolVal(scip, sol, vars[v]);
154  SCIP_CALL( SCIPchgVarLbDive(scip, vars[v], solval) );
155  SCIP_CALL( SCIPchgVarUbDive(scip, vars[v], solval) );
156  }
157  }
158 
159  /* solve LP */
160  SCIPdebugMessage(" -> old LP iterations: %"SCIP_LONGINT_FORMAT"\n", SCIPgetNLPIterations(scip));
161 
162  /* Errors in the LP solver should not kill the overall solving process, if the LP is just needed for a heuristic.
163  * Hence in optimized mode, the return code is caught and a warning is printed, only in debug mode, SCIP will stop.
164  */
165  retstat = SCIPsolveDiveLP(scip, -1, &lperror, NULL);
166  if( retstat != SCIP_OKAY )
167  {
168 #ifdef NDEBUG
169  SCIPwarningMessage(scip, "Error while solving LP in Proximity heuristic; LP solve terminated with code <%d>\n",retstat);
170 #else
171  SCIP_CALL( retstat );
172 #endif
173  }
174 
175  SCIPdebugMessage(" -> new LP iterations: %"SCIP_LONGINT_FORMAT"\n", SCIPgetNLPIterations(scip));
176  SCIPdebugMessage(" -> error=%u, status=%d\n", lperror, SCIPgetLPSolstat(scip));
177  if( !lperror && SCIPgetLPSolstat(scip) == SCIP_LPSOLSTAT_OPTIMAL )
178  {
179  SCIP_CALL( SCIPlinkLPSol(scip, sol) );
180  SCIP_CALL( SCIPtrySol(scip, sol, FALSE, TRUE, TRUE, TRUE, success) );
181  }
182 
183  SCIP_CALL( SCIPendDive(scip) );
184 
185  return SCIP_OKAY;
186 }
187 
188 /** creates a new solution for the original problem by copying the solution of the subproblem */
189 static
191  SCIP* scip, /**< original SCIP data structure */
192  SCIP* subscip, /**< SCIP structure of the subproblem */
193  SCIP_VAR** subvars, /**< the variables of the subproblem */
194  SCIP_HEUR* heur, /**< proximity heuristic structure */
195  SCIP_SOL* subsol, /**< solution of the subproblem */
196  SCIP_Bool usefinallp, /**< should continuous variables be optimized by a final LP */
197  SCIP_Bool* success /**< used to store whether new solution was found or not */
198  )
199 {
200  SCIP_VAR** vars; /* the original problem's variables */
201  int nvars; /* the original problem's number of variables */
202  int ncontvars; /* the original problem's number of continuous variables */
203  SCIP_Real* subsolvals; /* solution values of the subproblem */
204  SCIP_SOL* newsol; /* solution to be created for the original problem */
205 
206  assert(scip != NULL);
207  assert(subscip != NULL);
208  assert(subvars != NULL);
209  assert(subsol != NULL);
210 
211  /* get variables' data */
212  SCIP_CALL( SCIPgetVarsData(scip, &vars, &nvars, NULL, NULL, NULL, &ncontvars) );
213 
214  /* sub-SCIP may have more variables than the number of active (transformed) variables in the main SCIP
215  * since constraint copying may have required the copy of variables that are fixed in the main SCIP
216  */
217  assert(nvars <= SCIPgetNOrigVars(subscip));
218 
219  SCIP_CALL( SCIPallocBufferArray(scip, &subsolvals, nvars) );
220 
221  /* copy the solution */
222  SCIP_CALL( SCIPgetSolVals(subscip, subsol, nvars, subvars, subsolvals) );
223 
224  /* create new solution for the original problem */
225  SCIP_CALL( SCIPcreateSol(scip, &newsol, heur) );
226  SCIP_CALL( SCIPsetSolVals(scip, newsol, nvars, vars, subsolvals) );
227 
228  /* solve an LP with all integer variables fixed to improve solution quality */
229  if( ncontvars > 0 && usefinallp )
230  {
231  int v;
232  int ncontobjvars; /* does the problem instance have continuous variables with nonzero objective coefficients? */
233  SCIP_Real sumofobjsquares;
234 
235  /* check if continuous variables with nonzero objective coefficient are present */
236  ncontobjvars = 0;
237  sumofobjsquares = 0.0;
238  for( v = nvars - 1; v >= nvars - ncontvars; --v )
239  {
240  SCIP_VAR* var;
241 
242  var = vars[v];
243  assert(vars[v] != NULL);
244  assert(!SCIPvarIsIntegral(var));
245 
246  if( SCIPvarGetStatus(var) == SCIP_VARSTATUS_COLUMN && !SCIPisZero(scip, SCIPvarGetObj(var)) )
247  {
248  ++ncontobjvars;
249  sumofobjsquares += SCIPvarGetObj(var) * SCIPvarGetObj(var);
250  }
251  }
252 
253  SCIPstatisticMessage(" Continuous Objective variables: %d, Euclidean OBJ: %g total, %g continuous\n", ncontobjvars, SCIPgetObjNorm(scip), sumofobjsquares);
254  /* solve a final LP to optimize solution values of continuous problem variables */
255  if( ncontobjvars > 0 )
256  {
257  SCIPstatisticMessage("Solution Value before LP resolve: %g\n", SCIPgetSolOrigObj(scip, newsol));
258  SCIP_CALL( solveLp(scip, newsol, success) );
259 
260  if( !*success )
261  {
262  for( v = nvars - 1; v >= nvars - ncontvars; --v )
263  {
264  SCIP_CALL( SCIPsetSolVal(scip, newsol, vars[v], subsolvals[v]) );
265  }
266 
267  }
268  }
269  }
270 
271  /* try to add new solution to SCIP and free it immediately */
272  if( !*success )
273  {
274  SCIP_CALL( SCIPtrySol(scip, newsol, FALSE, TRUE, TRUE, TRUE, success) );
275  }
276  SCIP_CALL( SCIPfreeSol(scip, &newsol) );
277 
278  SCIPfreeBufferArray(scip, &subsolvals);
279 
280  return SCIP_OKAY;
281 }
282 
283 /** sets solving parameters for the subproblem created by the heuristic */
284 static
286  SCIP* subscip /**< copied SCIP data structure */
287  )
288 {
289  assert(subscip != NULL);
290 
291  /* do not abort subproblem on CTRL-C */
292  SCIP_CALL( SCIPsetBoolParam(subscip, "misc/catchctrlc", FALSE) );
293 
294  /* disable output to console */
295  SCIP_CALL( SCIPsetIntParam(subscip, "display/verblevel", 0) );
296 
297  /* forbid recursive call of heuristics and separators solving sub-SCIPs */
298  SCIP_CALL( SCIPsetSubscipsOff(subscip, TRUE) );
299 
300  /* use best dfs node selection */
301  if( SCIPfindNodesel(subscip, "dfs") != NULL && !SCIPisParamFixed(subscip, "nodeselection/dfs/stdpriority") )
302  {
303  SCIP_CALL( SCIPsetIntParam(subscip, "nodeselection/dfs/stdpriority", INT_MAX/4) );
304  }
305 
306  /* disable expensive presolving
307  * todo maybe presolving can be entirely turned off here - parameter???
308  */
310 
311  /* SCIP_CALL( SCIPsetPresolving(scip, SCIP_PARAMSETTING_OFF, TRUE) ); */
312  if( !SCIPisParamFixed(subscip, "presolving/maxrounds") )
313  {
314  SCIP_CALL( SCIPsetIntParam(subscip, "presolving/maxrounds", 50) );
315  }
316 
317  /* disable cutting plane separation */
319 
320 
321  /* todo: check branching rule in sub-SCIP */
322  if( SCIPfindBranchrule(subscip, "leastinf") != NULL && !SCIPisParamFixed(subscip, "branching/leastinf/priority") )
323  {
324  SCIP_CALL( SCIPsetIntParam(subscip, "branching/leastinf/priority", INT_MAX/4) );
325  }
326 
327  /* disable feasibility pump and fractional diving */
328  if( !SCIPisParamFixed(subscip, "heuristics/feaspump/freq") )
329  {
330  SCIP_CALL( SCIPsetIntParam(subscip, "heuristics/feaspump/freq", -1) );
331  }
332  if( !SCIPisParamFixed(subscip, "heuristics/fracdiving/freq") )
333  {
334  SCIP_CALL( SCIPsetIntParam(subscip, "heuristics/fracdiving/freq", -1) );
335  }
336 
337  /* employ a limit on the number of enforcement rounds in the quadratic constraint handler; this fixes the issue that
338  * sometimes the quadratic constraint handler needs hundreds or thousands of enforcement rounds to determine the
339  * feasibility status of a single node without fractional branching candidates by separation (namely for uflquad
340  * instances); however, the solution status of the sub-SCIP might get corrupted by this; hence no deductions shall be
341  * made for the original SCIP
342  */
343  if( SCIPfindConshdlr(subscip, "quadratic") != NULL && !SCIPisParamFixed(subscip, "constraints/quadratic/enfolplimit") )
344  {
345  SCIP_CALL( SCIPsetIntParam(subscip, "constraints/quadratic/enfolplimit", 500) );
346  }
347 
348  /* todo check if
349  * SCIP_CALL( SCIPsetEmphasis(subscip, SCIP_PARAMEMPHASIS_FEASIBILITY, TRUE) );
350  * improves performance */
351 
352 #ifdef SCIP_DEBUG
353  /* for debugging proximity, enable MIP output */
354  SCIP_CALL( SCIPsetIntParam(subscip, "display/verblevel", 5) );
355  SCIP_CALL( SCIPsetIntParam(subscip, "display/freq", 100000000) );
356 #endif
357 
358  return SCIP_OKAY;
359 }
360 
361 /** creates the rows of the subproblem */
362 static
364  SCIP* scip, /**< original SCIP data structure */
365  SCIP* subscip, /**< SCIP data structure for the subproblem */
366  SCIP_VAR** subvars /**< the variables of the subproblem */
367  )
368 {
369  SCIP_ROW** rows; /* original scip rows */
370  SCIP_CONS* cons; /* new constraint */
371  SCIP_VAR** consvars; /* new constraint's variables */
372  SCIP_COL** cols; /* original row's columns */
373 
374  SCIP_Real constant; /* constant added to the row */
375  SCIP_Real lhs; /* left hand side of the row */
376  SCIP_Real rhs; /* left right side of the row */
377  SCIP_Real* vals; /* variables' coefficient values of the row */
378 
379  int nrows;
380  int nnonz;
381  int i;
382  int j;
383 
384  /* get the rows and their number */
385  SCIP_CALL( SCIPgetLPRowsData(scip, &rows, &nrows) );
386 
387  /* copy all rows to linear constraints */
388  for( i = 0; i < nrows; i++ )
389  {
390  /* ignore rows that are only locally valid */
391  if( SCIProwIsLocal(rows[i]) )
392  continue;
393 
394  /* get the row's data */
395  constant = SCIProwGetConstant(rows[i]);
396  lhs = SCIProwGetLhs(rows[i]) - constant;
397  rhs = SCIProwGetRhs(rows[i]) - constant;
398  vals = SCIProwGetVals(rows[i]);
399  nnonz = SCIProwGetNNonz(rows[i]);
400  cols = SCIProwGetCols(rows[i]);
401 
402  assert(lhs <= rhs);
403 
404  /* allocate memory array to be filled with the corresponding subproblem variables */
405  SCIP_CALL( SCIPallocBufferArray(scip, &consvars, nnonz) );
406  for( j = 0; j < nnonz; j++ )
407  consvars[j] = subvars[SCIPvarGetProbindex(SCIPcolGetVar(cols[j]))];
408 
409  /* create a new linear constraint and add it to the subproblem */
410  SCIP_CALL( SCIPcreateConsLinear(subscip, &cons, SCIProwGetName(rows[i]), nnonz, consvars, vals, lhs, rhs,
411  TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE) );
412  SCIP_CALL( SCIPaddCons(subscip, cons) );
413  SCIP_CALL( SCIPreleaseCons(subscip, &cons) );
414 
415  /* free temporary memory */
416  SCIPfreeBufferArray(scip, &consvars);
417  }
418 
419  return SCIP_OKAY;
420 }
421 
422 /** frees the subproblem */
423 static
425  SCIP* scip, /**< SCIP data structure */
426  SCIP_HEURDATA* heurdata /**< heuristic data */
427  )
428 {
429  /* free remaining memory from heuristic execution */
430  if( heurdata->subscip != NULL )
431  {
432 
433  assert(heurdata->varmapfw != NULL);
434  assert(heurdata->subvars != NULL);
435  assert(heurdata->objcons != NULL);
436 
437  SCIPdebugMessage("Freeing subproblem of proximity heuristic\n");
438  SCIPfreeBlockMemoryArray(scip, &heurdata->subvars, heurdata->nsubvars);
439  SCIPhashmapFree(&heurdata->varmapfw);
440  SCIP_CALL( SCIPreleaseCons(heurdata->subscip, &heurdata->objcons) );
441  SCIP_CALL( SCIPfree(&heurdata->subscip) );
442 
443  heurdata->subscip = NULL;
444  heurdata->varmapfw = NULL;
445  heurdata->subvars = NULL;
446  heurdata->objcons = NULL;
447  }
448  return SCIP_OKAY;
449 }
450 
451 /* ---------------- Callback methods of event handler ---------------- */
452 
453 /* exec the event handler
454  *
455  * we interrupt the solution process
456  */
457 static
458 SCIP_DECL_EVENTEXEC(eventExecProximity)
459 {
460  SCIP_HEURDATA* heurdata;
461 
462  assert(eventhdlr != NULL);
463  assert(eventdata != NULL);
464  assert(strcmp(SCIPeventhdlrGetName(eventhdlr), EVENTHDLR_NAME) == 0);
465  assert(event != NULL);
467 
468  heurdata = (SCIP_HEURDATA*)eventdata;
469  assert(heurdata != NULL);
470 
471  /* interrupt solution process of sub-SCIP
472  * todo adjust interruption limit */
473  if( SCIPgetLPSolstat(scip) == SCIP_LPSOLSTAT_ITERLIMIT || SCIPgetNLPIterations(scip) >= heurdata->maxlpiters )
474  {
475  SCIP_CALL( SCIPinterruptSolve(scip) );
476  }
477 
478  return SCIP_OKAY;
479 }
480 /* ---------------- Callback methods of primal heuristic ---------------- */
481 
482 /** copy method for primal heuristic plugins (called when SCIP copies plugins) */
483 static
484 SCIP_DECL_HEURCOPY(heurCopyProximity)
485 { /*lint --e{715}*/
486  assert(scip != NULL);
487  assert(heur != NULL);
488  assert(strcmp(SCIPheurGetName(heur), HEUR_NAME) == 0);
489 
490  /* call inclusion method of primal heuristic */
492 
493  return SCIP_OKAY;
494 }
495 
496 /** destructor of primal heuristic to free user data (called when SCIP is exiting) */
497 static
498 SCIP_DECL_HEURFREE(heurFreeProximity)
499 { /*lint --e{715}*/
500  SCIP_HEURDATA* heurdata;
501 
502  assert( heur != NULL );
503  assert( scip != NULL );
504 
505  /* get heuristic data */
506  heurdata = SCIPheurGetData(heur);
507  assert( heurdata != NULL );
508 
509  /* free heuristic data */
510  SCIPfreeMemory(scip, &heurdata);
511  SCIPheurSetData(heur, NULL);
512 
513  return SCIP_OKAY;
514 }
515 
516 
517 /** initialization method of primal heuristic (called after problem was transformed) */
518 static
519 SCIP_DECL_HEURINIT(heurInitProximity)
520 { /*lint --e{715}*/
521  SCIP_HEURDATA* heurdata;
522 
523  assert( heur != NULL );
524  assert( scip != NULL );
525 
526  /* get heuristic data */
527  heurdata = SCIPheurGetData(heur);
528  assert( heurdata != NULL );
529 
530  /* initialize data */
531  heurdata->usednodes = 0LL;
532  heurdata->lastsolidx = -1;
533  heurdata->nusedlpiters = 0LL;
534  heurdata->subprobidx = 0;
535 
536  heurdata->subscip = NULL;
537  heurdata->varmapfw = NULL;
538  heurdata->subvars = NULL;
539  heurdata->objcons = NULL;
540 
541  heurdata->nsubvars = 0;
542 
543  return SCIP_OKAY;
544 }
545 
546 /* solution process exiting method of proximity heuristic */
547 static
548 SCIP_DECL_HEUREXITSOL(heurExitsolProximity)
549 {
550  SCIP_HEURDATA* heurdata;
551 
552  assert( heur != NULL );
553  assert( scip != NULL );
554 
555  /* get heuristic data */
556  heurdata = SCIPheurGetData(heur);
557  assert( heurdata != NULL );
558 
559  SCIP_CALL( deleteSubproblem(scip, heurdata) );
560 
561  assert(heurdata->subscip == NULL && heurdata->varmapfw == NULL
562  && heurdata->subvars == NULL && heurdata->objcons == NULL);
563 
564  return SCIP_OKAY;
565 }
566 
567 /** execution method of primal heuristic */
568 static
569 SCIP_DECL_HEUREXEC(heurExecProximity)
570 { /*lint --e{715}*/
571 
572  SCIP_HEURDATA* heurdata; /* heuristic's data */
573  SCIP_Longint nnodes; /* number of stalling nodes for the subproblem */
574  SCIP_Longint nlpiters; /* lp iteration limit for the subproblem */
575  SCIP_Bool foundsol;
576 
577  assert(heur != NULL);
578  assert(scip != NULL);
579  assert(result != NULL);
580 
581  *result = SCIP_DIDNOTRUN;
582 
583  /* get heuristic data */
584  heurdata = SCIPheurGetData(heur);
585  assert(heurdata != NULL);
586 
587  /* do not run heuristic when there are only few binary varables */
588  if( SCIPgetNBinVars(scip) < heurdata->binvarquot * SCIPgetNVars(scip) )
589  return SCIP_OKAY;
590 
591  /* calculate branching node limit for sub problem */
592  /* todo maybe treat root node differently */
593  nnodes = (SCIP_Longint) (heurdata->nodesquot * SCIPgetNNodes(scip));
594  nnodes += heurdata->nodesofs;
595 
596  /* determine the node and LP iteration limit for the solve of the sub-SCIP */
597  nnodes -= heurdata->usednodes;
598  nnodes = MIN(nnodes, heurdata->maxnodes);
599 
600  nlpiters = (SCIP_Longint) heurdata->lpitersquot * SCIPgetNRootFirstLPIterations(scip);
601  nlpiters = MIN(nlpiters, heurdata->maxlpiters);
602 
603  /* check whether we have enough nodes left to call subproblem solving */
604  if( nnodes < heurdata->minnodes )
605  {
606  SCIPdebugMessage("skipping proximity: nnodes=%"SCIP_LONGINT_FORMAT", minnodes=%"SCIP_LONGINT_FORMAT"\n", nnodes, heurdata->minnodes);
607  return SCIP_OKAY;
608  }
609 
610  /* do not run proximity, if the problem does not have an objective function anyway */
611  if( SCIPgetNObjVars(scip) == 0 )
612  {
613  SCIPdebugMessage("skipping proximity: pure feasibility problem anyway\n");
614  return SCIP_OKAY;
615  }
616 
617  foundsol = FALSE;
618 
619  do
620  {
621  /* main loop of proximity: in every iteration, a new subproblem is set up and solved until no improved solution
622  * is found or one of the heuristic limits on nodes or LP iterations is hit
623  * heuristic performs only one iteration if restart parameter is set to FALSE
624  */
625  SCIP_Longint nusednodes;
626  SCIP_Longint nusedlpiters;
627 
628  nusednodes = 0LL;
629  nusedlpiters = 0LL;
630 
631  nlpiters = MAX(nlpiters, heurdata->minlpiters);
632 
633  /* define and solve the proximity subproblem */
634  SCIP_CALL( SCIPapplyProximity(scip, heur, result, heurdata->minimprove, nnodes, nlpiters, &nusednodes, &nusedlpiters) );
635 
636  /* adjust node limit and LP iteration limit for future iterations */
637  assert(nusednodes <= nnodes);
638  heurdata->usednodes += nusednodes;
639  nnodes -= nusednodes;
640 
641  nlpiters -= nusedlpiters;
642  heurdata->nusedlpiters += nusedlpiters;
643 
644  /* memorize if a new solution has been found in at least one iteration */
645  if( *result == SCIP_FOUNDSOL )
646  foundsol = TRUE;
647  }
648  while( *result == SCIP_FOUNDSOL && heurdata->restart && !SCIPisStopped(scip) && nnodes > 0 );
649 
650  /* reset result pointer if solution has been found in previous iteration */
651  if( foundsol )
652  *result = SCIP_FOUNDSOL;
653 
654  if( SCIPgetNActivePricers(scip) > 0 )
655  {
656  SCIP_CALL( deleteSubproblem(scip, heurdata) );
657  }
658  return SCIP_OKAY;
659 }
660 
661 
662 /*
663  * primal heuristic specific interface methods
664  */
665 
666 
667 /** main procedure of the proximity heuristic, creates and solves a sub-SCIP */
669  SCIP* scip, /**< original SCIP data structure */
670  SCIP_HEUR* heur, /**< heuristic data structure */
671  SCIP_RESULT* result, /**< result data structure */
672  SCIP_Real minimprove, /**< factor by which proximity should at least improve the incumbent */
673  SCIP_Longint nnodes, /**< node limit for the subproblem */
674  SCIP_Longint nlpiters, /**< LP iteration limit for the subproblem */
675  SCIP_Longint* nusednodes, /**< pointer to store number of used nodes in subscip */
676  SCIP_Longint* nusedlpiters /**< pointer to store number of used LP iterations in subscip */
677  )
678 {
679  SCIP* subscip; /* the subproblem created by proximity */
680  SCIP_HASHMAP* varmapfw; /* mapping of SCIP variables to sub-SCIP variables */
681  SCIP_VAR** vars; /* original problem's variables */
682  SCIP_VAR** subvars; /* subproblem's variables */
683  SCIP_HEURDATA* heurdata; /* heuristic's private data structure */
684  SCIP_EVENTHDLR* eventhdlr; /* event handler for LP events */
685 
686  SCIP_SOL* incumbent;
687  SCIP_CONS* objcons;
688  SCIP_RETCODE retcode;
689  SCIP_Longint iterlim;
690 
691  SCIP_Real timelimit; /* time limit for proximity subproblem */
692  SCIP_Real memorylimit; /* memory limit for proximity subproblem */
693 
694  SCIP_Real large;
695  SCIP_Real inf;
696 
697  SCIP_Real bestobj;
698  SCIP_Real objcutoff;
699  SCIP_Real lowerbound;
700 
701  int nvars; /* number of original problem's variables */
702  int nfixedvars;
703  int nsubsols;
704  int solidx;
705  int i;
706 
707  SCIP_Bool valid;
708 
709  assert(scip != NULL);
710  assert(heur != NULL);
711  assert(result != NULL);
712 
713  assert(nnodes >= 0);
714  assert(0.0 <= minimprove && minimprove <= 1.0);
715 
716  *result = SCIP_DIDNOTRUN;
717 
718  /* get heuristic data */
719  heurdata = SCIPheurGetData(heur);
720  assert(heurdata != NULL);
721 
722  /* only call the heuristic if we have an incumbent */
723  if( SCIPgetNSolsFound(scip) == 0 )
724  return SCIP_OKAY;
725 
726  /* do not use heuristic on problems without binary variables */
727  if( SCIPgetNBinVars(scip) == 0 )
728  return SCIP_OKAY;
729 
730  incumbent = SCIPgetBestSol(scip);
731  assert(incumbent != NULL);
732 
733  /* make sure that the incumbent is valid for the transformed space, otherwise terminate */
734  if( SCIPsolIsOriginal(incumbent) )
735  return SCIP_OKAY;
736 
737  solidx = SCIPsolGetIndex(incumbent);
738 
739  if( heurdata->lastsolidx == solidx )
740  return SCIP_OKAY;
741 
742  /* only call heuristic, if the best solution does not come from trivial heuristic */
743  if( SCIPsolGetHeur(incumbent) != NULL && strcmp(SCIPheurGetName(SCIPsolGetHeur(incumbent)), "trivial") == 0 )
744  return SCIP_OKAY;
745 
746  /* waitingnodes parameter defines the minimum number of nodes to wait before a new incumbent is processed */
747  if( SCIPgetNNodes(scip) > 1 && SCIPgetNNodes(scip) - SCIPsolGetNodenum(incumbent) < heurdata->waitingnodes )
748  return SCIP_OKAY;
749 
750  bestobj = SCIPgetSolTransObj(scip, incumbent);
751  lowerbound = SCIPgetLowerbound(scip);
752 
753  /* use knowledge about integrality of objective to round up lower bound */
754  if( SCIPisObjIntegral(scip) )
755  {
756  SCIPdebugMessage(" Rounding up lower bound: %f --> %f \n", lowerbound, SCIPfeasCeil(scip, lowerbound));
757  lowerbound = SCIPfeasCeil(scip, lowerbound);
758  }
759 
760  /* do not trigger heuristic if primal and dual bound are already close together */
761  if( SCIPisFeasLE(scip, bestobj, lowerbound) || SCIPgetGap(scip) <= heurdata->mingap )
762  return SCIP_OKAY;
763 
764  /* calculate the minimum improvement for a heuristic solution in terms of the distance between incumbent objective
765  * and the lower bound
766  */
767  objcutoff = lowerbound + (1 - minimprove) * (bestobj - lowerbound);
768 
769  /* use integrality of the objective function to round down (and thus strengthen) the objective cutoff */
770  if( SCIPisObjIntegral(scip) )
771  objcutoff = SCIPfeasFloor(scip, objcutoff);
772 
773  if( SCIPisFeasLT(scip, objcutoff, lowerbound) )
774  objcutoff = lowerbound;
775 
776  /* exit execution if the right hand side of the objective constraint does not change (suggests that the heuristic
777  * was not successful in a previous iteration) */
778  if( heurdata->objcons != NULL && SCIPisFeasEQ(scip, SCIPgetRhsLinear(heurdata->subscip, heurdata->objcons), objcutoff) )
779  return SCIP_OKAY;
780 
781  /* check whether there is enough time and memory left */
782  timelimit = 0.0;
783  memorylimit = 0.0;
784  SCIP_CALL( SCIPgetRealParam(scip, "limits/time", &timelimit) );
785  if( !SCIPisInfinity(scip, timelimit) )
786  timelimit -= SCIPgetSolvingTime(scip);
787  SCIP_CALL( SCIPgetRealParam(scip, "limits/memory", &memorylimit) );
788 
789  /* substract the memory already used by the main SCIP and the estimated memory usage of external software */
790  if( !SCIPisInfinity(scip, memorylimit) )
791  {
792  memorylimit -= SCIPgetMemUsed(scip)/1048576.0;
793  memorylimit -= SCIPgetMemExternEstim(scip)/1048576.0;
794  }
795 
796  /* abort if no time is left or not enough memory to create a copy of SCIP, including external memory usage */
797  if( timelimit <= 0.0 || memorylimit <= 2.0 * SCIPgetMemExternEstim(scip) / 1048576.0 )
798  return SCIP_OKAY;
799 
800  *result = SCIP_DIDNOTFIND;
801 
802  heurdata->lastsolidx = solidx;
803 
804  /* get variable data */
805  SCIP_CALL( SCIPgetVarsData(scip, &vars, &nvars, NULL, NULL, NULL, NULL) );
806 
807  /* create a subscip and copy the original scip instance into it */
808  if( heurdata->subscip == NULL )
809  {
810  assert(heurdata->varmapfw == NULL);
811  assert(heurdata->objcons == NULL);
812 
813  /* initialize the subproblem */
814  SCIP_CALL( SCIPcreate(&subscip) );
815 
816  /* create the variable mapping hash map */
817  SCIP_CALL( SCIPhashmapCreate(&varmapfw, SCIPblkmem(subscip), SCIPcalcHashtableSize(5 * nvars)) );
818  SCIP_CALL( SCIPallocBlockMemoryArray(scip, &subvars, nvars) );
819 
820  /* copy complete SCIP instance */
821  valid = FALSE;
822  if( !heurdata->uselprows )
823  {
824  SCIP_CALL( SCIPcopy(scip, subscip, varmapfw, NULL, "proximity", TRUE, FALSE, TRUE, &valid) );
825  }
826  else
827  {
828  /* create the subproblem step by step, adding plugins and variables first, and finally creating
829  * linear constraints based on current LP rows */
830  SCIP_CALL( SCIPcopyPlugins(scip, subscip, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
831  TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, &valid) );
832  SCIP_CALL( SCIPcreateProbBasic(subscip, "proximitysub") );
833 
834  SCIP_CALL( SCIPcopyVars(scip, subscip, varmapfw, NULL, TRUE) );
835  for( i = 0; i < nvars; i++ )
836  subvars[i] = (SCIP_VAR*) (size_t) SCIPhashmapGetImage(varmapfw, vars[i]);
837 
838  SCIP_CALL( createRows(scip, subscip, subvars) );
839  }
840  SCIPdebugMessage("Copying the SCIP instance was %s complete.\n", valid ? "" : "not ");
841 
842  /* create event handler for LP events */
843  eventhdlr = NULL;
844  SCIP_CALL( SCIPincludeEventhdlrBasic(subscip, &eventhdlr, EVENTHDLR_NAME, EVENTHDLR_DESC, eventExecProximity, NULL) );
845  if( eventhdlr == NULL )
846  {
847  SCIPerrorMessage("event handler for "HEUR_NAME" heuristic not found.\n");
848  return SCIP_PLUGINNOTFOUND;
849  }
850 
851  /* set up parameters for the copied instance */
852  SCIP_CALL( setupSubproblem(subscip) );
853 
854  /* create the objective constraint in the sub scip, first without variables and values which will be added later */
855  SCIP_CALL( SCIPcreateConsBasicLinear(subscip, &objcons, "objbound_of_origscip", 0, NULL, NULL, -SCIPinfinity(subscip), SCIPinfinity(subscip)) );
856 
857  /* determine large value to set variable bounds to, safe-guard to avoid fixings to infinite values */
858  large = SCIPinfinity(scip);
859  if( !SCIPisInfinity(scip, 0.1 / SCIPfeastol(scip)) )
860  large = 0.1 / SCIPfeastol(scip);
861  inf = SCIPinfinity(subscip);
862 
863  /* get variable image and change objective to proximity function (Manhattan distance) in sub-SCIP */
864  for( i = 0; i < nvars; i++ )
865  {
866  SCIP_Real adjustedbound;
867  SCIP_Real lb;
868  SCIP_Real ub;
869 
870  subvars[i] = (SCIP_VAR*) SCIPhashmapGetImage(varmapfw, vars[i]);
871 
872  SCIP_CALL( SCIPchgVarObj(subscip, subvars[i], 0.0) );
873 
874  lb = SCIPvarGetLbGlobal(subvars[i]);
875  ub = SCIPvarGetUbGlobal(subvars[i]);
876 
877  /* adjust infinite bounds in order to avoid that variables with non-zero objective
878  * get fixed to infinite value in proximity subproblem
879  */
880  if( SCIPisInfinity(subscip, ub ) )
881  {
882  adjustedbound = MAX(large, lb+large);
883  adjustedbound = MIN(adjustedbound, inf);
884  SCIP_CALL( SCIPchgVarUbGlobal(subscip, subvars[i], adjustedbound) );
885  }
886  if( SCIPisInfinity(subscip, -lb ) )
887  {
888  adjustedbound = MIN(-large, ub-large);
889  adjustedbound = MAX(adjustedbound, -inf);
890  SCIP_CALL( SCIPchgVarLbGlobal(subscip, subvars[i], adjustedbound) );
891  }
892 
893  /* add all nonzero objective coefficients to the objective constraint */
894  if( !SCIPisFeasZero(subscip, SCIPvarGetObj(vars[i])) )
895  {
896  SCIP_CALL( SCIPaddCoefLinear(subscip, objcons, subvars[i], SCIPvarGetObj(vars[i])) );
897  }
898  }
899 
900  /* add objective constraint to the subscip */
901  SCIP_CALL( SCIPaddCons(subscip, objcons) );
902  }
903  else
904  {
905  /* the instance, event handler, hash map and variable array were already copied in a previous iteration
906  * and stored in heuristic data
907  */
908  assert(heurdata->varmapfw != NULL);
909  assert(heurdata->subvars != NULL);
910  assert(heurdata->objcons != NULL);
911 
912  subscip = heurdata->subscip;
913  varmapfw = heurdata->varmapfw;
914  subvars = heurdata->subvars;
915  objcons = heurdata->objcons;
916 
917  eventhdlr = SCIPfindEventhdlr(subscip, EVENTHDLR_NAME);
918  assert(eventhdlr != NULL);
919  }
920 
921  SCIP_CALL( SCIPchgRhsLinear(subscip, objcons, objcutoff) );
922 
923  for( i = 0; i < SCIPgetNBinVars(scip); ++i )
924  {
925  SCIP_Real solval;
926 
927  /* objective coefficients are only set for binary variables of the problem */
928  assert(SCIPvarIsBinary(subvars[i]));
929 
930  solval = SCIPgetSolVal(scip, incumbent, vars[i]);
931  assert(SCIPisFeasEQ(scip, solval, 1.0) || SCIPisFeasEQ(scip, solval, 0.0));
932 
933  if( solval < 0.5 )
934  {
935  SCIP_CALL( SCIPchgVarObj(subscip, subvars[i], 1.0) );
936  }
937  else
938  {
939  SCIP_CALL( SCIPchgVarObj(subscip, subvars[i], -1.0) );
940  }
941  }
942 
943  /* set limits for the subproblem */
944  SCIP_CALL( SCIPsetLongintParam(subscip, "limits/nodes", nnodes) );
945  SCIP_CALL( SCIPsetIntParam(subscip, "limits/solutions", 1) );
946  SCIP_CALL( SCIPsetRealParam(subscip, "limits/time", timelimit) );
947  SCIP_CALL( SCIPsetRealParam(subscip, "limits/memory", memorylimit) );
948 
949  /* restrict LP iterations */
950  /*todo set iterations limit depending on the number of iterations of the original problem root */
951  iterlim = nlpiters;
952  SCIP_CALL( SCIPsetLongintParam(subscip, "lp/iterlim", MAX(1, iterlim / MIN(10, nnodes))) );
953  SCIP_CALL( SCIPsetLongintParam(subscip, "lp/rootiterlim", iterlim) );
954 
955  /* catch LP events of sub-SCIP */
956  SCIP_CALL( SCIPtransformProb(subscip) );
957  SCIP_CALL( SCIPcatchEvent(subscip, SCIP_EVENTTYPE_NODESOLVED, eventhdlr, (SCIP_EVENTDATA*) heurdata, NULL) );
958 
959  SCIPstatisticMessage("solving subproblem at Node: %"SCIP_LONGINT_FORMAT" "
960  "nnodes: %"SCIP_LONGINT_FORMAT" "
961  "iterlim: %"SCIP_LONGINT_FORMAT"\n", SCIPgetNNodes(scip), nnodes, iterlim);
962 
963  /* solve the subproblem with all previously adjusted parameters */
964  nfixedvars = SCIPgetNFixedVars(subscip);
965 
966  SCIP_CALL( SCIPpresolve(subscip) );
967 
968  nfixedvars = SCIPgetNFixedVars(subscip) - nfixedvars;
969  assert(nfixedvars >= 0);
970  SCIPstatisticMessage("presolve fixings %d: %d\n", ++(heurdata->subprobidx), nfixedvars);
971  retcode = SCIPsolve(subscip);
972 
973  SCIPstatisticMessage("solve of subscip %d:"
974  "usednodes: %"SCIP_LONGINT_FORMAT" "
975  "lp iters: %"SCIP_LONGINT_FORMAT" "
976  "root iters: %"SCIP_LONGINT_FORMAT" "
977  "Presolving Time: %.2f\n", heurdata->subprobidx,
979 
980  SCIPstatisticMessage("Solving Time %d: %.2f\n", heurdata->subprobidx, SCIPgetSolvingTime(subscip) );
981  /* drop LP events of sub-SCIP */
982  SCIP_CALL( SCIPdropEvent(subscip, SCIP_EVENTTYPE_NODESOLVED, eventhdlr, (SCIP_EVENTDATA*) heurdata, -1) );
983 
984  /* errors in solving the subproblem should not kill the overall solving process;
985  * hence, the return code is caught and a warning is printed, only in debug mode, SCIP will stop.
986  */
987  if( retcode != SCIP_OKAY )
988  {
989 #ifndef NDEBUG
990  SCIP_CALL( retcode );
991 #endif
992  SCIPwarningMessage(scip, "Error while solving subproblem in proximity heuristic; sub-SCIP terminated with code <%d>\n",retcode);
993  }
994 
995  /* print solving statistics of subproblem if we are in SCIP's debug mode */
997 
998  /* keep track of relevant information for future runs of heuristic */
999  if( nusednodes != NULL )
1000  *nusednodes = SCIPgetNNodes(subscip);
1001  if( nusedlpiters != NULL )
1002  *nusedlpiters = SCIPgetNLPIterations(subscip);
1003 
1004  /* check whether a solution was found */
1005  nsubsols = SCIPgetNSols(subscip);
1006  incumbent = SCIPgetBestSol(subscip);
1007  assert(nsubsols == 0 || incumbent != NULL);
1008 
1009  SCIPstatisticMessage("primal bound before subproblem %d: %g\n", heurdata->subprobidx, SCIPgetPrimalbound(scip));
1010  if( nsubsols > 0 )
1011  {
1012  /* try to translate the sub problem solution to the original scip instance */
1013  SCIP_Bool success;
1014 
1015  success = FALSE;
1016  SCIP_CALL( createNewSol(scip, subscip, subvars, heur, incumbent, heurdata->usefinallp, &success) );
1017 
1018  if( success )
1019  *result = SCIP_FOUNDSOL;
1020  }
1021  SCIPstatisticMessage("primal bound after subproblem %d: %g\n", heurdata->subprobidx, SCIPgetPrimalbound(scip));
1022 
1023  /* free the transformed subproblem data */
1024  SCIP_CALL( SCIPfreeTransform(subscip) );
1025 
1026  /* save subproblem in heuristic data for subsequent runs if it has been successful, otherwise free subproblem */
1027  heurdata->subscip = subscip;
1028  heurdata->varmapfw = varmapfw;
1029  heurdata->subvars = subvars;
1030  heurdata->objcons = objcons;
1031  heurdata->nsubvars = nvars;
1032 
1033  return SCIP_OKAY;
1034 }
1035 
1036 
1037 /** creates the proximity primal heuristic and includes it in SCIP */
1039  SCIP* scip /**< SCIP data structure */
1040  )
1041 {
1042  SCIP_HEURDATA* heurdata;
1043  SCIP_HEUR* heur;
1044 
1045  /* create heuristic data */
1046  SCIP_CALL( SCIPallocMemory(scip, &heurdata) );
1047 
1048  /* include primal heuristic */
1049  heur = NULL;
1050  SCIP_CALL( SCIPincludeHeurBasic(scip, &heur,
1052  HEUR_MAXDEPTH, HEUR_TIMING, HEUR_USESSUBSCIP, heurExecProximity, heurdata) );
1053  assert(heur != NULL);
1054 
1055  /* set non-NULL pointers to callback methods */
1056  SCIP_CALL( SCIPsetHeurCopy(scip, heur, heurCopyProximity) );
1057  SCIP_CALL( SCIPsetHeurFree(scip, heur, heurFreeProximity) );
1058  SCIP_CALL( SCIPsetHeurInit(scip, heur, heurInitProximity) );
1059  SCIP_CALL( SCIPsetHeurExitsol(scip, heur, heurExitsolProximity) );
1060 
1061  /* add proximity primal heuristic parameters */
1062  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/"HEUR_NAME"/uselprows", "should subproblem be constructed based on LP row information?",
1063  &heurdata->uselprows, TRUE, DEFAULT_USELPROWS, NULL, NULL) );
1064 
1065  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/"HEUR_NAME"/restart", "should the heuristic immediately run again on its newly found solution?",
1066  &heurdata->restart, TRUE, DEFAULT_RESTART, NULL, NULL) );
1067 
1068  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/"HEUR_NAME"/usefinallp", "should the heuristic solve a final LP in case of continuous objective variables?",
1069  &heurdata->usefinallp, TRUE, DEFAULT_USEFINALLP, NULL, NULL) );
1070 
1071  SCIP_CALL( SCIPaddLongintParam(scip, "heuristics/"HEUR_NAME"/maxnodes",
1072  "maximum number of nodes to regard in the subproblem",
1073  &heurdata->maxnodes, TRUE,DEFAULT_MAXNODES, 0LL, SCIP_LONGINT_MAX, NULL, NULL) );
1074 
1075  SCIP_CALL( SCIPaddLongintParam(scip, "heuristics/"HEUR_NAME"/nodesofs",
1076  "number of nodes added to the contingent of the total nodes",
1077  &heurdata->nodesofs, TRUE, DEFAULT_NODESOFS, 0LL, SCIP_LONGINT_MAX, NULL, NULL) );
1078 
1079  SCIP_CALL( SCIPaddLongintParam(scip, "heuristics/"HEUR_NAME"/minnodes",
1080  "minimum number of nodes required to start the subproblem",
1081  &heurdata->minnodes, TRUE, DEFAULT_MINNODES, 0LL, SCIP_LONGINT_MAX, NULL, NULL) );
1082 
1083  SCIP_CALL( SCIPaddLongintParam(scip, "heuristics/"HEUR_NAME"/maxlpiters",
1084  "maximum number of LP iterations to be performed in the subproblem",
1085  &heurdata->maxlpiters, TRUE, DEFAULT_MAXLPITERS, -1LL, SCIP_LONGINT_MAX, NULL, NULL) );
1086 
1087  SCIP_CALL( SCIPaddLongintParam(scip, "heuristics/"HEUR_NAME"/minlpiters", "minimum number of LP iterations performed in "
1088  "subproblem", &heurdata->minlpiters, TRUE, DEFAULT_MINLPITERS, 0LL, SCIP_LONGINT_MAX, NULL, NULL) );
1089 
1090  SCIP_CALL( SCIPaddLongintParam(scip, "heuristics/"HEUR_NAME"/waitingnodes",
1091  "waiting nodes since last incumbent before heuristic is executed", &heurdata->waitingnodes, TRUE, DEFAULT_WAITINGNODES,
1092  0LL, SCIP_LONGINT_MAX, NULL, NULL) );
1093 
1094  SCIP_CALL( SCIPaddRealParam(scip, "heuristics/"HEUR_NAME"/minimprove",
1095  "factor by which proximity should at least improve the incumbent",
1096  &heurdata->minimprove, TRUE, DEFAULT_MINIMPROVE, 0.0, 1.0, NULL, NULL) );
1097 
1098  SCIP_CALL( SCIPaddRealParam(scip, "heuristics/"HEUR_NAME"/nodesquot", "sub-MIP node limit w.r.t number of original nodes",
1099  &heurdata->nodesquot, TRUE, DEFAULT_NODESQUOT, 0.0, SCIPinfinity(scip), NULL, NULL) );
1100 
1101  SCIP_CALL( SCIPaddRealParam(scip, "heuristics/"HEUR_NAME"/binvarquot",
1102  "threshold for percentage of binary variables required to start",
1103  &heurdata->binvarquot, TRUE, DEFAULT_BINVARQUOT, 0.0, 1.0, NULL, NULL) );
1104 
1105  SCIP_CALL( SCIPaddRealParam(scip, "heuristics/"HEUR_NAME"/lpitersquot",
1106  "quotient of sub-MIP LP iterations with respect to LP iterations so far",
1107  &heurdata->lpitersquot, TRUE, DEFAULT_LPITERSQUOT, 0.0, 1.0, NULL, NULL) );
1108 
1109  SCIP_CALL( SCIPaddRealParam(scip, "heuristics/"HEUR_NAME"/mingap",
1110  "minimum primal-dual gap for which the heuristic is executed",
1111  &heurdata->mingap, TRUE, DEFAULT_MINGAP, 0.0, SCIPinfinity(scip), NULL, NULL) );
1112 
1113  return SCIP_OKAY;
1114 }
1115