Scippy

SCIP

Solving Constraint Integer Programs

heur_dins.c
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the program and library */
4 /* SCIP --- Solving Constraint Integer Programs */
5 /* */
6 /* Copyright (C) 2002-2022 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SCIP is distributed under the terms of the ZIB Academic License. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SCIP; see the file COPYING. If not visit scipopt.org. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file heur_dins.c
17  * @ingroup DEFPLUGINS_HEUR
18  * @brief DINS primal heuristic (according to Ghosh)
19  * @author Timo Berthold
20  * @author Robert Waniek
21  */
22 
23 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
24 
25 #include "blockmemshell/memory.h"
26 #include "scip/cons_linear.h"
27 #include "scip/heur_dins.h"
28 #include "scip/heuristics.h"
29 #include "scip/pub_event.h"
30 #include "scip/pub_heur.h"
31 #include "scip/pub_message.h"
32 #include "scip/pub_misc.h"
33 #include "scip/pub_var.h"
34 #include "scip/scip_branch.h"
35 #include "scip/scip_cons.h"
36 #include "scip/scip_copy.h"
37 #include "scip/scip_event.h"
38 #include "scip/scip_general.h"
39 #include "scip/scip_heur.h"
40 #include "scip/scip_lp.h"
41 #include "scip/scip_mem.h"
42 #include "scip/scip_message.h"
43 #include "scip/scip_nodesel.h"
44 #include "scip/scip_numerics.h"
45 #include "scip/scip_param.h"
46 #include "scip/scip_prob.h"
47 #include "scip/scip_sol.h"
48 #include "scip/scip_solve.h"
49 #include "scip/scip_solvingstats.h"
50 #include "scip/scip_var.h"
51 #include <string.h>
52 
53 #define HEUR_NAME "dins"
54 #define HEUR_DESC "distance induced neighborhood search by Ghosh"
55 #define HEUR_DISPCHAR SCIP_HEURDISPCHAR_LNS
56 #define HEUR_PRIORITY -1105000
57 #define HEUR_FREQ -1
58 #define HEUR_FREQOFS 0
59 #define HEUR_MAXDEPTH -1
60 #define HEUR_TIMING SCIP_HEURTIMING_AFTERLPNODE
61 #define HEUR_USESSUBSCIP TRUE /**< does the heuristic use a secondary SCIP instance? */
62 
63 #define DEFAULT_NODESOFS 5000LL /* number of nodes added to the contingent of the total nodes */
64 #define DEFAULT_MAXNODES 5000LL /* maximum number of nodes to regard in the subproblem */
65 #define DEFAULT_MINNODES 50LL /* minimum number of nodes to regard in the subproblem */
66 #define DEFAULT_MINIMPROVE 0.01 /* factor by which DINS should at least improve the incumbent */
67 #define DEFAULT_NODESQUOT 0.05 /* subproblem nodes in relation to nodes of the original problem */
68 #define DEFAULT_LPLIMFAC 1.5 /* factor by which the limit on the number of LP depends on the node limit */
69 #define DEFAULT_MINFIXINGRATE 0.3 /* minimum percentage of integer variables that have to be fixed */
70 #define DEFAULT_NWAITINGNODES 200LL /* number of nodes without incumbent change that heuristic should wait */
71 #define DEFAULT_NEIGHBORHOODSIZE 18 /* radius of the incumbents neighborhood to be searched */
72 #define DEFAULT_SOLNUM 5 /* number of pool-solutions to be checked for flag array update */
73 #define DEFAULT_USELPROWS FALSE /* should subproblem be created out of the rows in the LP rows,
74  * otherwise, the copy constructors of the constraints handlers are used */
75 #define DEFAULT_COPYCUTS TRUE /* if DEFAULT_USELPROWS is FALSE, then should all active cuts from the cutpool
76  * of the original scip be copied to constraints of the subscip */
77 
78 #define DEFAULT_BESTSOLLIMIT 3 /* limit on number of improving incumbent solutions in sub-CIP */
79 #define DEFAULT_USEUCT FALSE /* should uct node selection be used at the beginning of the search? */
80 
81 
82 /* event handler properties */
83 #define EVENTHDLR_NAME "Dins"
84 #define EVENTHDLR_DESC "LP event handler for " HEUR_NAME " heuristic"
85 
86 /*
87  * Data structures
88  */
89 
90 /** DINS primal heuristic data */
91 struct SCIP_HeurData
92 {
93  SCIP_Longint nodesofs; /**< number of nodes added to the contingent of the total nodes */
94  SCIP_Longint maxnodes; /**< maximum number of nodes to regard in the subproblem */
95  SCIP_Longint minnodes; /**< minimum number of nodes to regard in the subproblem */
96  SCIP_Real minfixingrate; /**< minimum percentage of integer variables that have to be fixed */
97  SCIP_Longint nwaitingnodes; /**< number of nodes without incumbent change that heuristic should wait */
98  SCIP_Real minimprove; /**< factor by which DINS should at least improve the incumbent */
99  SCIP_Longint usednodes; /**< nodes already used by DINS in earlier calls */
100  SCIP_Longint lastnsolsfound; /**< total number of found solutions at previous execution of DINS */
101  SCIP_Real nodesquot; /**< subproblem nodes in relation to nodes of the original problem */
102  SCIP_Real nodelimit; /**< the nodelimit employed in the current sub-SCIP, for the event handler*/
103  SCIP_Real lplimfac; /**< factor by which the limit on the number of LP depends on the node limit */
104  int neighborhoodsize; /**< radius of the incumbent's neighborhood to be searched */
105  SCIP_Bool* delta; /**< stores whether a variable kept its value from root LP all the time */
106  int deltalength; /**< if there are no binary variables, we need no flag array */
107  int solnum; /**< number of pool-solutions to be checked for flag array update */
108  SCIP_Bool uselprows; /**< should subproblem be created out of the rows in the LP rows? */
109  SCIP_Bool copycuts; /**< if uselprows == FALSE, should all active cuts from cutpool be copied
110  * to constraints in subproblem?
111  */
112  int bestsollimit; /**< limit on number of improving incumbent solutions in sub-CIP */
113  SCIP_Bool useuct; /**< should uct node selection be used at the beginning of the search? */
114 };
115 
116 
117 /*
118  * Local methods
119  */
120 
121 /** compute tightened bounds for integer variables depending on how much the LP and the incumbent solution values differ */
122 static
124  SCIP* scip, /**< SCIP data structure of the original problem */
125  SCIP_VAR* var, /**< the variable for which bounds should be computed */
126  SCIP_Real* lbptr, /**< pointer to store the lower bound in the DINS sub-SCIP */
127  SCIP_Real* ubptr /**< pointer to store the upper bound in the DINS sub-SCIP */
128  )
129 {
130  SCIP_Real mipsol;
131  SCIP_Real lpsol;
132 
133  SCIP_Real lbglobal;
134  SCIP_Real ubglobal;
135  SCIP_SOL* bestsol;
136 
137  /* get the bounds for each variable */
138  lbglobal = SCIPvarGetLbGlobal(var);
139  ubglobal = SCIPvarGetUbGlobal(var);
140 
141  assert(SCIPvarGetType(var) == SCIP_VARTYPE_INTEGER);
142  /* get the current LP solution for each variable */
143  lpsol = SCIPvarGetLPSol(var);
144 
145  /* get the current MIP solution for each variable */
146  bestsol = SCIPgetBestSol(scip);
147  mipsol = SCIPgetSolVal(scip, bestsol, var);
148 
149  /* if the solution values differ by 0.5 or more, the variable is rebounded, otherwise it is just copied */
150  if( REALABS(lpsol - mipsol) >= 0.5 )
151  {
152  SCIP_Real range;
153 
154  *lbptr = lbglobal;
155  *ubptr = ubglobal;
156 
157  /* create a equally sized range around lpsol for general integers: bounds are lpsol +- (mipsol-lpsol) */
158  range = 2*lpsol-mipsol;
159 
160  if( mipsol >= lpsol )
161  {
162  range = SCIPfeasCeil(scip, range);
163  *lbptr = MAX(*lbptr, range);
164 
165  /* when the bound new upper bound is equal to the current MIP solution, we set both bounds to the integral bound (without eps) */
166  if( SCIPisFeasEQ(scip, mipsol, *lbptr) )
167  *ubptr = *lbptr;
168  else
169  *ubptr = mipsol;
170  }
171  else
172  {
173  range = SCIPfeasFloor(scip, range);
174  *ubptr = MIN(*ubptr, range);
175 
176  /* when the bound new upper bound is equal to the current MIP solution, we set both bounds to the integral bound (without eps) */
177  if( SCIPisFeasEQ(scip, mipsol, *ubptr) )
178  *lbptr = *ubptr;
179  else
180  *lbptr = mipsol;
181  }
182 
183  /* the global domain of variables might have been reduced since incumbent was found: adjust lb and ub accordingly */
184  *lbptr = MAX(*lbptr, lbglobal);
185  *ubptr = MIN(*ubptr, ubglobal);
186  }
187  else
188  {
189  /* the global domain of variables might have been reduced since incumbent was found: adjust it accordingly */
190  *lbptr = MAX(mipsol, lbglobal);
191  *ubptr = MIN(mipsol, ubglobal);
192  }
193 }
194 
195 /** creates a subproblem for subscip by fixing a number of variables */
196 static
198  SCIP* scip, /**< SCIP data structure of the original problem */
199  SCIP_HEUR* heur, /**< DINS heuristic structure */
200  SCIP_HEURDATA* heurdata, /**< heuristic data structure */
201  SCIP_VAR** vars, /**< variables of the original problem */
202  SCIP_VAR** fixedvars, /**< array to store variables that should be fixed in the sub-SCIP */
203  SCIP_Real* fixedvals, /**< array to store fixing values for fixed variables */
204  int nbinvars, /**< number of binary variables of problem and subproblem */
205  int nintvars, /**< number of general integer variables of problem and subproblem */
206  int* binfixings, /**< pointer to store number of binary variables that should be fixed */
207  int* intfixings /**< pointer to store number of integer variables that should be fixed */
208  )
209 {
210  SCIP_SOL* bestsol;
211  SCIP_SOL** sols;
212  SCIP_Bool* delta;
213  int i;
214  int nsols;
215  SCIP_Longint nsolsfound;
216  int checklength;
217  int nfixedvars;
218 
219  assert(scip != NULL);
220  assert(vars != NULL);
221  assert(fixedvars != NULL);
222  assert(fixedvals != NULL);
223  assert(binfixings != NULL);
224  assert(intfixings != NULL);
225  assert(heur != NULL);
226 
227  /* get the best MIP-solution known so far */
228  bestsol = SCIPgetBestSol(scip);
229  assert(bestsol != NULL);
230 
231  /* get solution pool and number of solutions in pool */
232  sols = SCIPgetSols(scip);
233  nsols = SCIPgetNSols(scip);
234  nsolsfound = SCIPgetNSolsFound(scip);
235  checklength = MIN(nsols, heurdata->solnum);
236  assert(sols != NULL);
237  assert(nsols > 0);
238 
239  /* if new binary variables have been created, e.g., due to column generation, reallocate the delta array */
240  if( heurdata->deltalength < nbinvars )
241  {
242  int newsize;
243 
244  newsize = SCIPcalcMemGrowSize(scip, nbinvars);
245  assert(newsize >= nbinvars);
246 
247  SCIP_CALL( SCIPreallocBlockMemoryArray(scip, &heurdata->delta, heurdata->deltalength, newsize) );
248 
249  /* initialize new part of delta array */
250  for( i = heurdata->deltalength; i < newsize; i++ )
251  heurdata->delta[i] = TRUE;
252 
253  heurdata->deltalength = newsize;
254  }
255 
256  delta = heurdata->delta;
257  /* fixing for binary variables */
258  /* hard fixing for some with mipsol(s)=lpsolval=rootlpsolval and preparation for soft fixing for the remaining */
259  nfixedvars = 0;
260  *intfixings = *binfixings = 0;
261  for( i = 0; i < nbinvars; i++ )
262  {
263  SCIP_Real lpsolval;
264  SCIP_Real mipsolval;
265  SCIP_Real rootlpsolval;
266  int j;
267 
268  /* get the current LP solution for each variable */
269  lpsolval = SCIPvarGetLPSol(vars[i]);
270  /* get the current MIP solution for each variable */
271  mipsolval = SCIPgetSolVal(scip, bestsol, vars[i]);
272  /* get the root LP solution for each variable */
273  rootlpsolval = SCIPvarGetRootSol(vars[i]);
274 
275  if( SCIPisFeasEQ(scip, lpsolval, mipsolval) && SCIPisFeasEQ(scip, mipsolval, rootlpsolval) )
276  {
277  /* update delta */
278  if( nsols > 1 && heurdata->lastnsolsfound != nsolsfound && delta[i] ) /* no need to update delta[i] if already FALSE */
279  {
280  /* no need to update delta[i] if already FALSE or sols[i] already checked on previous run or worse than DINS-solution of last run */
281  for( j = 1; delta[i] && j < checklength && SCIPgetSolHeur(scip, sols[j]) != heur ; j++ )
282  {
283  SCIP_Real solval;
284  solval = SCIPgetSolVal(scip, sols[j], vars[i]);
285  delta[i] = delta[i] && SCIPisFeasEQ(scip, mipsolval, solval);
286  }
287  }
288 
289  /* hard fixing if rootlpsolval=nodelpsolval=mipsolval(s) and delta (is TRUE) */
290  if( delta[i] )
291  {
292  fixedvars[nfixedvars] = vars[i];
293  fixedvals[nfixedvars] = mipsolval;
294  ++nfixedvars;
295  }
296  }
297  }
298 
299  *binfixings = nfixedvars;
300 
301  /* store the number of found solutions for next run */
302  heurdata->lastnsolsfound = nsolsfound;
303 
304  /* compute a tighter bound for the variable in the subproblem; */
305  for( i = nbinvars; i < nbinvars + nintvars; ++i )
306  {
307  SCIP_Real lb;
308  SCIP_Real ub;
309  computeIntegerVariableBounds(scip, vars[i], &lb, &ub);
310 
311  /* hard fixing if heuristic bounds coincide */
312  if( ub - lb < 0.5 )
313  {
314  fixedvars[(nfixedvars)] = vars[i];
315  fixedvals[(nfixedvars)] = lb;
316  ++nfixedvars;
317  }
318  }
319 
320  *intfixings = nfixedvars - *binfixings;
321 
322  return SCIP_OKAY;
323 }
324 
325 /** creates a subproblem for subscip by fixing a number of variables */
326 static
328  SCIP* scip, /**< SCIP data structure of the original problem */
329  SCIP* subscip, /**< SCIP data structure of the subproblem */
330  SCIP_VAR** vars, /**< variables of the original problem */
331  SCIP_VAR** subvars, /**< variables of the DINS sub-SCIP */
332  int nbinvars, /**< number of binary variables of problem and subproblem */
333  int nintvars /**< number of general integer variables of problem and subproblem */
334  )
335 {
336  int i;
337  /* compute a tighter bound for the variable in the subproblem; */
338  for( i = nbinvars; i < nbinvars + nintvars; ++i )
339  {
340  SCIP_Real lb;
341  SCIP_Real ub;
342 
343  if( subvars[i] == NULL )
344  continue;
345 
346  computeIntegerVariableBounds(scip, vars[i], &lb, &ub);
347 
348  /* change variable bounds in the DINS subproblem; if bounds coincide, variable should already be fixed */
349  if( ub - lb >= 0.5 )
350  {
351  SCIP_CALL( SCIPchgVarLbGlobal(subscip, subvars[i], lb) );
352  SCIP_CALL( SCIPchgVarUbGlobal(subscip, subvars[i], ub) );
353  }
354  else
355  {
356  assert(SCIPisFeasEQ(scip, SCIPvarGetLbGlobal(subvars[i]), SCIPvarGetUbGlobal(subvars[i])));
357  }
358  }
359 
360  return SCIP_OKAY;
361 }
362 
363 /** create the extra constraint of local branching and add it to subscip */
364 static
366  SCIP* scip, /**< SCIP data structure of the original problem */
367  SCIP* subscip, /**< SCIP data structure of the subproblem */
368  SCIP_VAR** subvars, /**< variables of the subproblem */
369  SCIP_HEURDATA* heurdata /**< heuristic's data structure */
370  )
371 {
372  SCIP_CONS* cons; /* local branching constraint to create */
373  SCIP_VAR** vars;
374  SCIP_SOL* bestsol;
375 
376  SCIP_VAR** consvars;
377  SCIP_Real* consvals;
378  SCIP_Real solval;
379  SCIP_Real lhs;
380  SCIP_Real rhs;
381 
382  char consname[SCIP_MAXSTRLEN];
383 
384  int nbinvars;
385  int i;
386  int nconsvars;
387 
388  (void) SCIPsnprintf(consname, SCIP_MAXSTRLEN, "%s_dinsLBcons", SCIPgetProbName(scip));
389 
390  /* get the data of the variables and the best solution */
391  SCIP_CALL( SCIPgetVarsData(scip, &vars, NULL, &nbinvars, NULL, NULL, NULL) );
392  bestsol = SCIPgetBestSol(scip);
393  assert(bestsol != NULL);
394 
395  /* memory allocation */
396  SCIP_CALL( SCIPallocBufferArray(scip, &consvals, nbinvars) );
397  SCIP_CALL( SCIPallocBufferArray(scip, &consvars, nbinvars) );
398  nconsvars = 0;
399 
400  /* set initial left and right hand sides of local branching constraint */
401  lhs = 0.0;
402  rhs = (SCIP_Real) heurdata->neighborhoodsize;
403 
404  /* create the distance function of the binary variables (to incumbent solution) */
405  for( i = 0; i < nbinvars; i++ )
406  {
407  if( subvars[i] == NULL )
408  continue;
409 
410  assert(SCIPvarGetType(subvars[i]) == SCIP_VARTYPE_BINARY);
411  if( SCIPvarGetUbGlobal(subvars[i]) - SCIPvarGetLbGlobal(subvars[i]) < 0.5 )
412  continue;
413 
414  solval = SCIPgetSolVal(scip, bestsol, vars[i]);
415  assert(SCIPisFeasIntegral(scip, solval));
416 
417  /* is variable i part of the binary support of the current solution? */
418  if( SCIPisFeasEQ(scip, solval, 1.0) )
419  {
420  consvals[nconsvars] = -1.0;
421  rhs -= 1.0;
422  lhs -= 1.0;
423  }
424  else
425  consvals[nconsvars] = 1.0;
426  consvars[nconsvars++] = subvars[i];
427  }
428 
429  /* creates local branching constraint and adds it to subscip */
430  SCIP_CALL( SCIPcreateConsLinear(subscip, &cons, consname, nconsvars, consvars, consvals,
431  lhs, rhs, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE) );
432  SCIP_CALL( SCIPaddCons(subscip, cons) );
433  SCIP_CALL( SCIPreleaseCons(subscip, &cons) );
434 
435  /* free local memory */
436  SCIPfreeBufferArray(scip, &consvars);
437  SCIPfreeBufferArray(scip, &consvals);
438 
439  return SCIP_OKAY;
440 }
441 
442 static
443 SCIP_DECL_EVENTEXEC(eventExecDins);
444 
445 /** wrapper for the part of heuristic that runs a subscip. Wrapper is needed to avoid possible ressource leaks */
446 static
448  SCIP* scip, /**< original SCIP data structure */
449  SCIP* subscip, /**< SCIP structure of the subproblem */
450  SCIP_HEUR* heur, /**< Heuristic pointer */
451  SCIP_HEURDATA* heurdata, /**< Heuristic's data */
452  SCIP_VAR** vars, /**< original problem's variables */
453  SCIP_VAR** fixedvars, /**< Fixed variables of original SCIP */
454  SCIP_Real* fixedvals, /**< Fixed values of original SCIP */
455  SCIP_RESULT* result, /**< Result pointer */
456  int nvars, /**< Number of variables */
457  int nbinvars, /**< Number of binary variables in original SCIP */
458  int nintvars, /**< Number of integer variables in original SCIP */
459  int binfixings, /**< Number of binary fixing in original SCIP */
460  int intfixings, /**< Number of integer fixings in original SCIP */
461  SCIP_Longint nsubnodes /**< Number of nodes in the subscip */
462  )
463 {
464  SCIP_VAR** subvars; /* variables of the subscip */
465  SCIP_HASHMAP* varmapfw; /* hashmap for mapping between vars of scip and subscip */
466  SCIP_EVENTHDLR* eventhdlr; /* event handler for LP events */
467  SCIP_Real upperbound; /* upperbound of the original SCIP */
468  SCIP_Real cutoff; /* objective cutoff for the subproblem */
469 
470  SCIP_Bool success;
471 
472  int i;
473  int nsubsols;
474 
475  /* create the variable mapping hash map */
476  SCIP_CALL( SCIPallocBufferArray(scip, &subvars, nvars) );
477  SCIP_CALL( SCIPhashmapCreate(&varmapfw, SCIPblkmem(subscip), nvars) );
478 
479  success = FALSE;
480  eventhdlr = NULL;
481 
482  /* create a problem copy as sub SCIP */
483  SCIP_CALL( SCIPcopyLargeNeighborhoodSearch(scip, subscip, varmapfw, "dins", fixedvars, fixedvals, binfixings + intfixings,
484  heurdata->uselprows, heurdata->copycuts, &success, NULL) );
485 
486  /* create event handler for LP events */
487  SCIP_CALL( SCIPincludeEventhdlrBasic(subscip, &eventhdlr, EVENTHDLR_NAME, EVENTHDLR_DESC, eventExecDins, NULL) );
488  if( eventhdlr == NULL )
489  {
490  SCIPerrorMessage("event handler for " HEUR_NAME " heuristic not found.\n");
491  return SCIP_PLUGINNOTFOUND;
492  }
493 
494  SCIPdebugMsg(scip, "Copying the SCIP instance was %ssuccessful.\n", success ? "" : "not ");
495 
496  SCIPdebugMsg(scip, "DINS subproblem: %d vars (%d binvars & %d intvars), %d cons\n",
497  SCIPgetNVars(subscip), SCIPgetNBinVars(subscip) , SCIPgetNIntVars(subscip) , SCIPgetNConss(subscip));
498 
499  /* store subproblem variables that correspond to original variables */
500  for( i = 0; i < nvars; i++ )
501  subvars[i] = (SCIP_VAR*) SCIPhashmapGetImage(varmapfw, vars[i]);
502 
503  /* free hash map */
504  SCIPhashmapFree(&varmapfw);
505 
506  /* perform prepared softfixing for all unfixed vars if the number of unfixed vars is larger than the neighborhoodsize (otherwise it will be useless) */
507  if( nbinvars - binfixings > heurdata->neighborhoodsize )
508  {
509  SCIP_CALL( addLocalBranchingConstraint(scip, subscip, subvars, heurdata) );
510  }
511 
512  /* rebound integer variables if not all were fixed */
513  if( intfixings < nintvars )
514  {
515  assert(nintvars > 0);
516  SCIP_CALL( reboundIntegerVariables(scip, subscip, vars, subvars, nbinvars, nintvars) );
517  }
518 
519  /* do not abort subproblem on CTRL-C */
520  SCIP_CALL( SCIPsetBoolParam(subscip, "misc/catchctrlc", FALSE) );
521 
522 #ifdef SCIP_DEBUG
523  /* for debugging, enable full output */
524  SCIP_CALL( SCIPsetIntParam(subscip, "display/verblevel", 5) );
525  SCIP_CALL( SCIPsetIntParam(subscip, "display/freq", 100000000) );
526 #else
527  /* disable statistic timing inside sub SCIP and output to console */
528  SCIP_CALL( SCIPsetIntParam(subscip, "display/verblevel", 0) );
529  SCIP_CALL( SCIPsetBoolParam(subscip, "timing/statistictiming", FALSE) );
530 #endif
531 
532  /* set limits for the subproblem */
533  SCIP_CALL( SCIPcopyLimits(scip, subscip) );
534  heurdata->nodelimit = nsubnodes;
535  SCIP_CALL( SCIPsetLongintParam(subscip, "limits/nodes", nsubnodes) );
536  SCIP_CALL( SCIPsetLongintParam(subscip, "limits/stallnodes", MAX(10, nsubnodes/10)) );
537  SCIP_CALL( SCIPsetIntParam(subscip, "limits/bestsol", heurdata->bestsollimit) );
538 
539  /* forbid recursive call of heuristics and separators solving subMIPs */
540  SCIP_CALL( SCIPsetSubscipsOff(subscip, TRUE) );
541 
542  /* disable cutting plane separation */
544 
545  /* disable expensive presolving */
547 
548  /* use best estimate node selection */
549  if( SCIPfindNodesel(subscip, "estimate") != NULL && !SCIPisParamFixed(subscip, "nodeselection/estimate/stdpriority") )
550  {
551  SCIP_CALL( SCIPsetIntParam(subscip, "nodeselection/estimate/stdpriority", INT_MAX/4) );
552  }
553 
554  /* activate uct node selection at the top of the tree */
555  if( heurdata->useuct && SCIPfindNodesel(subscip, "uct") != NULL && !SCIPisParamFixed(subscip, "nodeselection/uct/stdpriority") )
556  {
557  SCIP_CALL( SCIPsetIntParam(subscip, "nodeselection/uct/stdpriority", INT_MAX/2) );
558  }
559 
560  /* use inference branching */
561  if( SCIPfindBranchrule(subscip, "inference") != NULL && !SCIPisParamFixed(subscip, "branching/inference/priority") )
562  {
563  SCIP_CALL( SCIPsetIntParam(subscip, "branching/inference/priority", INT_MAX/4) );
564  }
565 
566  /* enable conflict analysis, disable analysis of boundexceeding LPs, and restrict conflict pool */
567  if( !SCIPisParamFixed(subscip, "conflict/enable") )
568  {
569  SCIP_CALL( SCIPsetBoolParam(subscip, "conflict/enable", TRUE) );
570  }
571  if( !SCIPisParamFixed(subscip, "conflict/useboundlp") )
572  {
573  SCIP_CALL( SCIPsetCharParam(subscip, "conflict/useboundlp", 'o') );
574  }
575  if( !SCIPisParamFixed(subscip, "conflict/maxstoresize") )
576  {
577  SCIP_CALL( SCIPsetIntParam(subscip, "conflict/maxstoresize", 100) );
578  }
579 
580  /* speed up sub-SCIP by not checking dual LP feasibility */
581  SCIP_CALL( SCIPsetBoolParam(subscip, "lp/checkdualfeas", FALSE) );
582 
583  /* add an objective cutoff */
584  assert(!SCIPisInfinity(scip, SCIPgetUpperbound(scip)));
585 
586  if( !SCIPisInfinity(scip, -1.0*SCIPgetLowerbound(scip)) )
587  {
588  cutoff = (1 - heurdata->minimprove) * SCIPgetUpperbound(scip) + heurdata->minimprove * SCIPgetLowerbound(scip);
589  upperbound = SCIPgetUpperbound(scip) - SCIPsumepsilon(scip);
590  cutoff = MIN(upperbound, cutoff);
591  }
592  else
593  {
594  if( SCIPgetUpperbound(scip) >= 0 )
595  cutoff = (1 - heurdata->minimprove) * SCIPgetUpperbound(scip);
596  else
597  cutoff = (1 + heurdata->minimprove) * SCIPgetUpperbound(scip);
598  upperbound = SCIPgetUpperbound(scip) - SCIPsumepsilon(scip);
599  cutoff = MIN(upperbound, cutoff);
600  }
601  SCIP_CALL( SCIPsetObjlimit(subscip, cutoff) );
602 
603  /* catch LP events of sub-SCIP */
604  if( !heurdata->uselprows )
605  {
606  assert(eventhdlr != NULL);
607 
608  SCIP_CALL( SCIPtransformProb(subscip) );
609  SCIP_CALL( SCIPcatchEvent(subscip, SCIP_EVENTTYPE_LPSOLVED, eventhdlr, (SCIP_EVENTDATA*) heurdata, NULL) );
610  }
611 
612  /* solve the subproblem */
613  SCIPdebugMsg(scip, "solving DINS sub-MIP with neighborhoodsize %d and maxnodes %" SCIP_LONGINT_FORMAT "\n", heurdata->neighborhoodsize, nsubnodes);
614 
615  /* Errors in solving the subproblem should not kill the overall solving process
616  * Hence, the return code is caught and a warning is printed, only in debug mode, SCIP will stop.
617  */
618  SCIP_CALL_ABORT( SCIPsolve(subscip) );
619 
620  /* drop LP events of sub-SCIP */
621  if( !heurdata->uselprows )
622  {
623  assert(eventhdlr != NULL);
624 
625  SCIP_CALL( SCIPdropEvent(subscip, SCIP_EVENTTYPE_LPSOLVED, eventhdlr, (SCIP_EVENTDATA*) heurdata, -1) );
626  }
627 
628  /* print solving statistics of subproblem if we are in SCIP's debug mode */
630 
631  heurdata->usednodes += SCIPgetNNodes(subscip);
632  nsubsols = SCIPgetNSols(subscip);
633  SCIPdebugMsg(scip, "DINS used %" SCIP_LONGINT_FORMAT "/%" SCIP_LONGINT_FORMAT " nodes and found %d solutions\n", SCIPgetNNodes(subscip), nsubnodes, nsubsols);
634 
635  /* check, whether a (new) solution was found */
636  if( nsubsols > 0 )
637  {
638  /* check, whether a solution was found; due to numerics, it might happen that not all solutions are feasible -> try all solutions until one was accepted */
639  SCIP_CALL( SCIPtranslateSubSols(scip, subscip, heur, subvars, &success, NULL) );
640  if( success )
641  {
642  SCIPdebugMsg(scip, "DINS successfully found new solution\n");
643  *result = SCIP_FOUNDSOL;
644  }
645  }
646 
647  /* free subproblem */
648  SCIPfreeBufferArray(scip, &subvars);
649 
650  return SCIP_OKAY;
651 }
652 
653 
654 /* ---------------- Callback methods of event handler ---------------- */
655 
656 /* exec the event handler
657  *
658  * we interrupt the solution process
659  */
660 static
661 SCIP_DECL_EVENTEXEC(eventExecDins)
662 {
663  SCIP_HEURDATA* heurdata;
664 
665  assert(eventhdlr != NULL);
666  assert(eventdata != NULL);
667  assert(strcmp(SCIPeventhdlrGetName(eventhdlr), EVENTHDLR_NAME) == 0);
668  assert(event != NULL);
669  assert(SCIPeventGetType(event) & SCIP_EVENTTYPE_LPSOLVED);
670 
671  heurdata = (SCIP_HEURDATA*)eventdata;
672  assert(heurdata != NULL);
673 
674  /* interrupt solution process of sub-SCIP */
675  if( SCIPgetNLPs(scip) > heurdata->lplimfac * heurdata->nodelimit )
676  {
677  SCIPdebugMsg(scip, "interrupt after %" SCIP_LONGINT_FORMAT " LPs\n",SCIPgetNLPs(scip));
679  }
680 
681  return SCIP_OKAY;
682 }
683 
684 
685 /*
686  * Callback methods of primal heuristic
687  */
688 
689 /** copy method for primal heuristic plugins (called when SCIP copies plugins) */
690 static
691 SCIP_DECL_HEURCOPY(heurCopyDins)
692 { /*lint --e{715}*/
693  assert(scip != NULL);
694  assert(heur != NULL);
695  assert(strcmp(SCIPheurGetName(heur), HEUR_NAME) == 0);
696 
697  /* call inclusion method of primal heuristic */
699 
700  return SCIP_OKAY;
701 }
702 
703 /** destructor of primal heuristic to free user data (called when SCIP is exiting) */
704 static
705 SCIP_DECL_HEURFREE(heurFreeDins)
706 { /*lint --e{715}*/
707  SCIP_HEURDATA* heurdata;
708 
709  assert(heur != NULL);
710  assert(scip != NULL);
711 
712  /* get heuristic data */
713  heurdata = SCIPheurGetData(heur);
714  assert(heurdata != NULL);
715 
716  /* free heuristic data */
717  SCIPfreeBlockMemory(scip, &heurdata);
718  SCIPheurSetData(heur, NULL);
719 
720  return SCIP_OKAY;
721 }
722 
723 
724 /** solving process initialization method of primal heuristic (called when branch and bound process is about to begin) */
725 static
726 SCIP_DECL_HEURINITSOL(heurInitsolDins)
727 {
728  SCIP_HEURDATA* heurdata;
729  int i;
730 
731  assert(heur != NULL);
732  assert(scip != NULL);
733 
734  /* get heuristic's data */
735  heurdata = SCIPheurGetData(heur);
736  assert(heurdata != NULL);
737 
738  /* initialize data */
739  heurdata->usednodes = 0;
740  heurdata->lastnsolsfound = 0;
741 
742  /* create flag array */
743  heurdata->deltalength = SCIPgetNBinVars(scip);
744 
745  /* no binvars => no flag array needed */
746  if( heurdata->deltalength > 0 )
747  {
748  SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(heurdata->delta), heurdata->deltalength) );
749  for( i = 0; i < heurdata->deltalength; i++ )
750  heurdata->delta[i] = TRUE;
751  }
752  return SCIP_OKAY;
753 }
754 
755 /** solving process deinitialization method of primal heuristic (called before branch and bound process data is freed) */
756 static
757 SCIP_DECL_HEUREXITSOL(heurExitsolDins)
758 { /*lint --e{715}*/
759  SCIP_HEURDATA* heurdata;
760 
761  assert(heur != NULL);
762  assert(scip != NULL);
763 
764  /* get heuristic data */
765  heurdata = SCIPheurGetData(heur);
766  assert(heurdata != NULL);
767 
768  /* free flag array if exist */
769  if( heurdata->deltalength > 0 )
770  {
771  SCIPfreeBlockMemoryArray(scip, &(heurdata->delta), heurdata->deltalength);
772  }
773  return SCIP_OKAY;
774 }
775 
776 /** execution method of primal heuristic */
777 static
778 SCIP_DECL_HEUREXEC(heurExecDins)
779 { /*lint --e{715}*/
780  SCIP_HEURDATA* heurdata;
781  SCIP* subscip; /* the subproblem created by DINS */
782  SCIP_VAR** vars; /* variables of the original problem */
783  SCIP_VAR** fixedvars;
784  SCIP_Real* fixedvals;
785 
786  SCIP_Longint maxnnodes; /* maximum number of subnodes */
787  SCIP_Longint nsubnodes; /* nodelimit for subscip */
788 
789  SCIP_RETCODE retcode;
790 
791  int nvars; /* number of variables in original SCIP */
792  int nbinvars; /* number of binary variables in original SCIP */
793  int nintvars; /* number of general integer variables in original SCIP */
794  int binfixings;
795  int intfixings;
796 
797  SCIP_Bool success; /* used to store whether new solution was found or not */
798 
799  assert(heur != NULL);
800  assert(scip != NULL);
801  assert(result != NULL);
802  assert(SCIPhasCurrentNodeLP(scip));
803 
804  *result = SCIP_DELAYED;
805 
806  /* do not call heuristic of node was already detected to be infeasible */
807  if( nodeinfeasible )
808  return SCIP_OKAY;
809 
810  /* only call heuristic, if a CIP solution is at hand */
811  if( SCIPgetNSols(scip) <= 0 )
812  return SCIP_OKAY;
813 
814  /* only call heuristic, if an optimal LP solution is at hand */
816  return SCIP_OKAY;
817 
818  /* only call heuristic, if the LP objective value is smaller than the cutoff bound */
820  return SCIP_OKAY;
821 
822  /* get heuristic's data */
823  heurdata = SCIPheurGetData(heur);
824  assert(heurdata != NULL);
825 
826  /* only call heuristic, if enough nodes were processed since last incumbent */
827  if( SCIPgetNNodes(scip) - SCIPgetSolNodenum(scip, SCIPgetBestSol(scip)) < heurdata->nwaitingnodes )
828  return SCIP_OKAY;
829 
830  *result = SCIP_DIDNOTRUN;
831 
832  /* determine the node limit for the current process */
833  maxnnodes = (SCIP_Longint) (heurdata->nodesquot * SCIPgetNNodes(scip));
834 
835  /* reward DINS if it succeeded often */
836  maxnnodes = (SCIP_Longint) (maxnnodes * (1.0 + 2.0 * (SCIPheurGetNBestSolsFound(heur)+1.0) / (SCIPheurGetNCalls(heur) + 1.0)));
837 
838  /* count the setup costs for the sub-MIP as 100 nodes */
839  maxnnodes -= 100 * SCIPheurGetNCalls(heur);
840  maxnnodes += heurdata->nodesofs;
841 
842  /* determine the node limit for the current process */
843  nsubnodes = maxnnodes - heurdata->usednodes;
844  nsubnodes = MIN(nsubnodes , heurdata->maxnodes);
845 
846  /* check whether we have enough nodes left to call sub problem solving */
847  if( nsubnodes < heurdata->minnodes )
848  return SCIP_OKAY;
849 
850  if( SCIPisStopped(scip) )
851  return SCIP_OKAY;
852 
853  /* get required data of the original problem */
854  SCIP_CALL( SCIPgetVarsData(scip, &vars, &nvars, &nbinvars, &nintvars, NULL, NULL) );
855  assert(nbinvars <= nvars);
856 
857  /* do not run heuristic if only continuous variables are present */
858  if( nbinvars == 0 && nintvars == 0 )
859  return SCIP_OKAY;
860 
861  /* check whether there is enough time and memory left */
862  SCIP_CALL( SCIPcheckCopyLimits(scip, &success) );
863 
864  /* abort if no time is left or not enough memory to create a copy of SCIP */
865  if( !success )
866  return SCIP_OKAY;
867 
868  assert(vars != NULL);
869 
870  SCIP_CALL( SCIPallocBufferArray(scip, &fixedvars, nbinvars + nintvars) );
871  SCIP_CALL( SCIPallocBufferArray(scip, &fixedvals, nbinvars + nintvars) );
872 
873  /* collect variables that should be fixed in the DINS subproblem */
874  binfixings = intfixings = 0;
875  SCIP_CALL( determineVariableFixings(scip, heur, heurdata, vars, fixedvars, fixedvals, nbinvars, nintvars, &binfixings, &intfixings) );
876 
877  /* abort, if all integer variables were fixed (which should not happen for MIP),
878  * but frequently happens for MINLPs using an LP relaxation */
879  if( binfixings + intfixings == nbinvars + nintvars )
880  goto TERMINATE;
881 
882  /* abort, if the amount of fixed variables is insufficient */
883  if( (binfixings + intfixings) / (SCIP_Real)(MAX(nbinvars + nintvars, 1)) < heurdata->minfixingrate )
884  goto TERMINATE;
885 
886  *result = SCIP_DIDNOTFIND;
887 
888  /* initialize the subproblem */
889  SCIP_CALL( SCIPcreate(&subscip) );
890 
891  retcode = wrapperDins(scip, subscip, heur, heurdata, vars, fixedvars, fixedvals, result, nvars, nbinvars, nintvars, binfixings, intfixings, nsubnodes);
892  SCIP_CALL( SCIPfree(&subscip) );
893 
894  SCIP_CALL( retcode );
895 
896  TERMINATE:
897  SCIPfreeBufferArray(scip, &fixedvals);
898  SCIPfreeBufferArray(scip, &fixedvars);
899 
900  return SCIP_OKAY;
901 }
902 
903 
904 /*
905  * primal heuristic specific interface methods
906  */
907 
908 /** creates the DINS primal heuristic and includes it in SCIP */
910  SCIP* scip /**< SCIP data structure */
911  )
912 {
913  SCIP_HEURDATA* heurdata;
914  SCIP_HEUR* heur;
915 
916  /* create Dins primal heuristic data */
917  SCIP_CALL( SCIPallocBlockMemory(scip, &heurdata) );
918 
919  /* include primal heuristic */
920  SCIP_CALL( SCIPincludeHeurBasic(scip, &heur,
922  HEUR_MAXDEPTH, HEUR_TIMING, HEUR_USESSUBSCIP, heurExecDins, heurdata) );
923 
924  assert(heur != NULL);
925 
926  /* set non-NULL pointers to callback methods */
927  SCIP_CALL( SCIPsetHeurCopy(scip, heur, heurCopyDins) );
928  SCIP_CALL( SCIPsetHeurFree(scip, heur, heurFreeDins) );
929  SCIP_CALL( SCIPsetHeurInitsol(scip, heur, heurInitsolDins) );
930  SCIP_CALL( SCIPsetHeurExitsol(scip, heur, heurExitsolDins) );
931 
932  /* add DINS primal heuristic parameters */
933  SCIP_CALL( SCIPaddLongintParam(scip, "heuristics/" HEUR_NAME "/nodesofs",
934  "number of nodes added to the contingent of the total nodes",
935  &heurdata->nodesofs, FALSE, DEFAULT_NODESOFS, 0LL, SCIP_LONGINT_MAX, NULL, NULL) );
936  SCIP_CALL( SCIPaddRealParam(scip, "heuristics/" HEUR_NAME "/nodesquot",
937  "contingent of sub problem nodes in relation to the number of nodes of the original problem",
938  &heurdata->nodesquot, FALSE, DEFAULT_NODESQUOT, 0.0, 1.0, NULL, NULL) );
939  SCIP_CALL( SCIPaddLongintParam(scip, "heuristics/" HEUR_NAME "/minnodes",
940  "minimum number of nodes required to start the subproblem",
941  &heurdata->minnodes, FALSE, DEFAULT_MINNODES, 0LL, SCIP_LONGINT_MAX, NULL, NULL) );
942  SCIP_CALL( SCIPaddIntParam(scip, "heuristics/" HEUR_NAME "/solnum",
943  "number of pool-solutions to be checked for flag array update (for hard fixing of binary variables)",
944  &heurdata->solnum, FALSE, DEFAULT_SOLNUM, 1, INT_MAX, NULL, NULL) );
945  SCIP_CALL( SCIPaddIntParam(scip, "heuristics/" HEUR_NAME "/neighborhoodsize",
946  "radius (using Manhattan metric) of the incumbent's neighborhood to be searched",
947  &heurdata->neighborhoodsize, FALSE, DEFAULT_NEIGHBORHOODSIZE, 1, INT_MAX, NULL, NULL) );
948  SCIP_CALL( SCIPaddLongintParam(scip, "heuristics/" HEUR_NAME "/maxnodes",
949  "maximum number of nodes to regard in the subproblem",
950  &heurdata->maxnodes,TRUE,DEFAULT_MAXNODES, 0LL, SCIP_LONGINT_MAX, NULL, NULL) );
951  SCIP_CALL( SCIPaddRealParam(scip, "heuristics/" HEUR_NAME "/minimprove",
952  "factor by which " HEUR_NAME " should at least improve the incumbent",
953  &heurdata->minimprove, TRUE, DEFAULT_MINIMPROVE, 0.0, 1.0, NULL, NULL) );
954  SCIP_CALL( SCIPaddLongintParam(scip, "heuristics/" HEUR_NAME "/nwaitingnodes",
955  "number of nodes without incumbent change that heuristic should wait",
956  &heurdata->nwaitingnodes, TRUE, DEFAULT_NWAITINGNODES, 0LL, SCIP_LONGINT_MAX, NULL, NULL) );
957 
958  SCIP_CALL( SCIPaddRealParam(scip, "heuristics/" HEUR_NAME "/lplimfac",
959  "factor by which the limit on the number of LP depends on the node limit",
960  &heurdata->lplimfac, TRUE, DEFAULT_LPLIMFAC, 1.0, SCIP_REAL_MAX, NULL, NULL) );
961 
962  SCIP_CALL( SCIPaddRealParam(scip, "heuristics/" HEUR_NAME "/minfixingrate",
963  "minimum percentage of integer variables that have to be fixable",
964  &heurdata->minfixingrate, FALSE, DEFAULT_MINFIXINGRATE, 0.0, 1.0, NULL, NULL) );
965 
966  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/" HEUR_NAME "/uselprows",
967  "should subproblem be created out of the rows in the LP rows?",
968  &heurdata->uselprows, TRUE, DEFAULT_USELPROWS, NULL, NULL) );
969 
970  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/" HEUR_NAME "/copycuts",
971  "if uselprows == FALSE, should all active cuts from cutpool be copied to constraints in subproblem?",
972  &heurdata->copycuts, TRUE, DEFAULT_COPYCUTS, NULL, NULL) );
973 
974  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/" HEUR_NAME "/useuct",
975  "should uct node selection be used at the beginning of the search?",
976  &heurdata->useuct, TRUE, DEFAULT_USEUCT, NULL, NULL) );
977 
978  SCIP_CALL( SCIPaddIntParam(scip, "heuristics/" HEUR_NAME "/bestsollimit",
979  "limit on number of improving incumbent solutions in sub-CIP",
980  &heurdata->bestsollimit, FALSE, DEFAULT_BESTSOLLIMIT, -1, INT_MAX, NULL, NULL) );
981 
982  return SCIP_OKAY;
983 }
enum SCIP_Result SCIP_RESULT
Definition: type_result.h:52
SCIP_RETCODE SCIPsetHeurExitsol(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEUREXITSOL((*heurexitsol)))
Definition: scip_heur.c:233
#define SCIPfreeBlockMemoryArray(scip, ptr, num)
Definition: scip_mem.h:101
int SCIPgetNIntVars(SCIP *scip)
Definition: scip_prob.c:2081
#define SCIPreallocBlockMemoryArray(scip, ptr, oldnum, newnum)
Definition: scip_mem.h:90
SCIP_RETCODE SCIPchgVarLbGlobal(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
Definition: scip_var.c:4940
#define SCIP_EVENTTYPE_LPSOLVED
Definition: type_event.h:92
SCIP_RETCODE SCIPsetSeparating(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
Definition: scip_param.c:949
#define SCIPallocBlockMemoryArray(scip, ptr, num)
Definition: scip_mem.h:84
SCIP_Bool SCIPisFeasEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
public methods for SCIP parameter handling
#define DEFAULT_LPLIMFAC
Definition: heur_dins.c:68
static SCIP_RETCODE wrapperDins(SCIP *scip, SCIP *subscip, SCIP_HEUR *heur, SCIP_HEURDATA *heurdata, SCIP_VAR **vars, SCIP_VAR **fixedvars, SCIP_Real *fixedvals, SCIP_RESULT *result, int nvars, int nbinvars, int nintvars, int binfixings, int intfixings, SCIP_Longint nsubnodes)
Definition: heur_dins.c:447
#define HEUR_FREQ
Definition: heur_dins.c:57
public methods for node selector plugins
public methods for memory management
SCIP_Real SCIPgetCutoffbound(SCIP *scip)
#define EVENTHDLR_NAME
Definition: heur_dins.c:83
SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
Definition: var.c:17910
#define SCIP_MAXSTRLEN
Definition: def.h:293
SCIP_Longint SCIPheurGetNBestSolsFound(SCIP_HEUR *heur)
Definition: heur.c:1587
SCIP_Longint SCIPgetNSolsFound(SCIP *scip)
#define DEFAULT_NODESOFS
Definition: heur_dins.c:63
int SCIPcalcMemGrowSize(SCIP *scip, int num)
Definition: scip_mem.c:130
SCIP_Bool SCIPisGE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
public solving methods
SCIP_RETCODE SCIPincludeEventhdlrBasic(SCIP *scip, SCIP_EVENTHDLR **eventhdlrptr, const char *name, const char *desc, SCIP_DECL_EVENTEXEC((*eventexec)), SCIP_EVENTHDLRDATA *eventhdlrdata)
Definition: scip_event.c:95
static SCIP_RETCODE determineVariableFixings(SCIP *scip, SCIP_HEUR *heur, SCIP_HEURDATA *heurdata, SCIP_VAR **vars, SCIP_VAR **fixedvars, SCIP_Real *fixedvals, int nbinvars, int nintvars, int *binfixings, int *intfixings)
Definition: heur_dins.c:197
#define EVENTHDLR_DESC
Definition: heur_dins.c:84
SCIP_Real SCIPvarGetRootSol(SCIP_VAR *var)
Definition: var.c:13349
SCIP_RETCODE SCIPgetVarsData(SCIP *scip, SCIP_VAR ***vars, int *nvars, int *nbinvars, int *nintvars, int *nimplvars, int *ncontvars)
Definition: scip_prob.c:1865
SCIP_SOL ** SCIPgetSols(SCIP *scip)
Definition: scip_sol.c:2254
#define FALSE
Definition: def.h:87
SCIP_RETCODE SCIPhashmapCreate(SCIP_HASHMAP **hashmap, BMS_BLKMEM *blkmem, int mapsize)
Definition: misc.c:3014
const char * SCIPeventhdlrGetName(SCIP_EVENTHDLR *eventhdlr)
Definition: event.c:315
SCIP_RETCODE SCIPaddLongintParam(SCIP *scip, const char *name, const char *desc, SCIP_Longint *valueptr, SCIP_Bool isadvanced, SCIP_Longint defaultvalue, SCIP_Longint minvalue, SCIP_Longint maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
Definition: scip_param.c:102
#define DEFAULT_MAXNODES
Definition: heur_dins.c:64
SCIP_RETCODE SCIPcopyLimits(SCIP *sourcescip, SCIP *targetscip)
Definition: scip_copy.c:3278
int SCIPsnprintf(char *t, int len, const char *s,...)
Definition: misc.c:10755
#define DEFAULT_MINFIXINGRATE
Definition: heur_dins.c:69
#define TRUE
Definition: def.h:86
#define SCIPdebug(x)
Definition: pub_message.h:84
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:54
methods commonly used by primal heuristics
#define HEUR_DISPCHAR
Definition: heur_dins.c:55
SCIP_RETCODE SCIPsetPresolving(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
Definition: scip_param.c:923
SCIP_BRANCHRULE * SCIPfindBranchrule(SCIP *scip, const char *name)
Definition: scip_branch.c:288
struct SCIP_HeurData SCIP_HEURDATA
Definition: type_heur.h:67
public methods for problem variables
static SCIP_DECL_HEURFREE(heurFreeDins)
Definition: heur_dins.c:705
#define SCIPfreeBlockMemory(scip, ptr)
Definition: scip_mem.h:99
SCIP_RETCODE SCIPincludeHeurBasic(SCIP *scip, SCIP_HEUR **heur, const char *name, const char *desc, char dispchar, int priority, int freq, int freqofs, int maxdepth, SCIP_HEURTIMING timingmask, SCIP_Bool usessubscip, SCIP_DECL_HEUREXEC((*heurexec)), SCIP_HEURDATA *heurdata)
Definition: scip_heur.c:108
SCIP_RETCODE SCIPtranslateSubSols(SCIP *scip, SCIP *subscip, SCIP_HEUR *heur, SCIP_VAR **subvars, SCIP_Bool *success, int *solindex)
Definition: scip_copy.c:1439
void * SCIPhashmapGetImage(SCIP_HASHMAP *hashmap, void *origin)
Definition: misc.c:3201
#define SCIP_LONGINT_MAX
Definition: def.h:163
#define SCIPfreeBufferArray(scip, ptr)
Definition: scip_mem.h:127
SCIP_RETCODE SCIPcreate(SCIP **scip)
Definition: scip_general.c:283
void SCIPheurSetData(SCIP_HEUR *heur, SCIP_HEURDATA *heurdata)
Definition: heur.c:1362
public methods for SCIP variables
SCIP_RETCODE SCIPchgVarUbGlobal(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
Definition: scip_var.c:5029
#define SCIPdebugMsg
Definition: scip_message.h:69
SCIP_RETCODE SCIPaddIntParam(SCIP *scip, const char *name, const char *desc, int *valueptr, SCIP_Bool isadvanced, int defaultvalue, int minvalue, int maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
Definition: scip_param.c:74
SCIP_RETCODE SCIPprintStatistics(SCIP *scip, FILE *file)
static SCIP_DECL_HEURINITSOL(heurInitsolDins)
Definition: heur_dins.c:726
SCIP_Real SCIPfeasCeil(SCIP *scip, SCIP_Real val)
public methods for numerical tolerances
SCIP_Real SCIPfeasFloor(SCIP *scip, SCIP_Real val)
public methods for querying solving statistics
const char * SCIPgetProbName(SCIP *scip)
Definition: scip_prob.c:1066
SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
Definition: var.c:17920
SCIP_RETCODE SCIPsetHeurInitsol(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURINITSOL((*heurinitsol)))
Definition: scip_heur.c:217
SCIP_RETCODE SCIPsolve(SCIP *scip)
Definition: scip_solve.c:2613
const char * SCIPheurGetName(SCIP_HEUR *heur)
Definition: heur.c:1441
#define SCIPerrorMessage
Definition: pub_message.h:55
SCIP_Bool SCIPisParamFixed(SCIP *scip, const char *name)
Definition: scip_param.c:210
SCIP_RETCODE SCIPaddCons(SCIP *scip, SCIP_CONS *cons)
Definition: scip_prob.c:2769
SCIP_RETCODE SCIPsetHeurFree(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURFREE((*heurfree)))
Definition: scip_heur.c:169
#define HEUR_NAME
Definition: heur_dins.c:53
public methods for event handler plugins and event handlers
#define DEFAULT_NEIGHBORHOODSIZE
Definition: heur_dins.c:71
SCIP_RETCODE SCIPsetBoolParam(SCIP *scip, const char *name, SCIP_Bool value)
Definition: scip_param.c:420
BMS_BLKMEM * SCIPblkmem(SCIP *scip)
Definition: scip_mem.c:48
static SCIP_DECL_HEUREXITSOL(heurExitsolDins)
Definition: heur_dins.c:757
struct SCIP_EventData SCIP_EVENTDATA
Definition: type_event.h:164
void SCIPhashmapFree(SCIP_HASHMAP **hashmap)
Definition: misc.c:3048
#define NULL
Definition: lpi_spx1.cpp:155
#define DEFAULT_NODESQUOT
Definition: heur_dins.c:67
#define REALABS(x)
Definition: def.h:201
SCIP_Real SCIPvarGetLPSol(SCIP_VAR *var)
Definition: var.c:18284
public methods for problem copies
#define SCIP_CALL(x)
Definition: def.h:384
SCIP_Real SCIPgetLowerbound(SCIP *scip)
#define HEUR_FREQOFS
Definition: heur_dins.c:58
SCIP_Longint SCIPheurGetNCalls(SCIP_HEUR *heur)
Definition: heur.c:1567
SCIP_Bool SCIPhasCurrentNodeLP(SCIP *scip)
Definition: scip_lp.c:74
public methods for primal heuristic plugins and divesets
public methods for constraint handler plugins and constraints
SCIP_RETCODE SCIPincludeHeurDins(SCIP *scip)
Definition: heur_dins.c:909
static SCIP_DECL_HEURCOPY(heurCopyDins)
Definition: heur_dins.c:691
#define SCIPallocBufferArray(scip, ptr, num)
Definition: scip_mem.h:115
public data structures and miscellaneous methods
#define DEFAULT_BESTSOLLIMIT
Definition: heur_dins.c:78
#define SCIP_Bool
Definition: def.h:84
SCIP_RETCODE SCIPcatchEvent(SCIP *scip, SCIP_EVENTTYPE eventtype, SCIP_EVENTHDLR *eventhdlr, SCIP_EVENTDATA *eventdata, int *filterpos)
Definition: scip_event.c:277
SCIP_LPSOLSTAT SCIPgetLPSolstat(SCIP *scip)
Definition: scip_lp.c:159
#define DEFAULT_MINNODES
Definition: heur_dins.c:65
SCIP_EVENTTYPE SCIPeventGetType(SCIP_EVENT *event)
Definition: event.c:1021
#define DEFAULT_USELPROWS
Definition: heur_dins.c:73
SCIP_RETCODE SCIPsetObjlimit(SCIP *scip, SCIP_Real objlimit)
Definition: scip_prob.c:1421
static void computeIntegerVariableBounds(SCIP *scip, SCIP_VAR *var, SCIP_Real *lbptr, SCIP_Real *ubptr)
Definition: heur_dins.c:123
#define MAX(x, y)
Definition: tclique_def.h:83
static SCIP_RETCODE reboundIntegerVariables(SCIP *scip, SCIP *subscip, SCIP_VAR **vars, SCIP_VAR **subvars, int nbinvars, int nintvars)
Definition: heur_dins.c:327
SCIP_RETCODE SCIPsetIntParam(SCIP *scip, const char *name, int value)
Definition: scip_param.c:478
#define DEFAULT_COPYCUTS
Definition: heur_dins.c:75
#define HEUR_PRIORITY
Definition: heur_dins.c:56
SCIP_RETCODE SCIPdropEvent(SCIP *scip, SCIP_EVENTTYPE eventtype, SCIP_EVENTHDLR *eventhdlr, SCIP_EVENTDATA *eventdata, int filterpos)
Definition: scip_event.c:311
int SCIPgetNSols(SCIP *scip)
Definition: scip_sol.c:2205
Constraint handler for linear constraints in their most general form, .
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
static SCIP_DECL_HEUREXEC(heurExecDins)
Definition: heur_dins.c:778
int SCIPgetNBinVars(SCIP *scip)
Definition: scip_prob.c:2036
public methods for the LP relaxation, rows and columns
SCIP_RETCODE SCIPsetCharParam(SCIP *scip, const char *name, char value)
Definition: scip_param.c:652
int SCIPgetNVars(SCIP *scip)
Definition: scip_prob.c:1991
#define SCIP_REAL_MAX
Definition: def.h:178
static SCIP_RETCODE addLocalBranchingConstraint(SCIP *scip, SCIP *subscip, SCIP_VAR **subvars, SCIP_HEURDATA *heurdata)
Definition: heur_dins.c:365
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)
public methods for branching rule plugins and branching
DINS primal heuristic.
#define DEFAULT_SOLNUM
Definition: heur_dins.c:72
public methods for managing events
#define HEUR_TIMING
Definition: heur_dins.c:60
general public methods
#define DEFAULT_MINIMPROVE
Definition: heur_dins.c:66
SCIP_Real SCIPgetLPObjval(SCIP *scip)
Definition: scip_lp.c:238
SCIP_SOL * SCIPgetBestSol(SCIP *scip)
Definition: scip_sol.c:2304
public methods for solutions
int SCIPgetNConss(SCIP *scip)
Definition: scip_prob.c:3041
SCIP_RETCODE SCIPreleaseCons(SCIP *scip, SCIP_CONS **cons)
Definition: scip_cons.c:1110
public methods for message output
SCIP_NODESEL * SCIPfindNodesel(SCIP *scip, const char *name)
Definition: scip_nodesel.c:225
SCIP_RETCODE SCIPcopyLargeNeighborhoodSearch(SCIP *sourcescip, SCIP *subscip, SCIP_HASHMAP *varmap, const char *suffix, SCIP_VAR **fixedvars, SCIP_Real *fixedvals, int nfixedvars, SCIP_Bool uselprows, SCIP_Bool copycuts, SCIP_Bool *success, SCIP_Bool *valid)
Definition: heuristics.c:916
SCIP_HEUR * SCIPgetSolHeur(SCIP *scip, SCIP_SOL *sol)
Definition: scip_sol.c:1675
#define SCIP_Real
Definition: def.h:177
SCIP_Bool SCIPisStopped(SCIP *scip)
Definition: scip_general.c:694
public methods for message handling
#define SCIP_Longint
Definition: def.h:162
#define HEUR_MAXDEPTH
Definition: heur_dins.c:59
SCIP_RETCODE SCIPcheckCopyLimits(SCIP *sourcescip, SCIP_Bool *success)
Definition: scip_copy.c:3235
SCIP_VARTYPE SCIPvarGetType(SCIP_VAR *var)
Definition: var.c:17416
SCIP_RETCODE SCIPtransformProb(SCIP *scip)
Definition: scip_solve.c:358
SCIP_RETCODE SCIPsetHeurCopy(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURCOPY((*heurcopy)))
Definition: scip_heur.c:153
#define DEFAULT_NWAITINGNODES
Definition: heur_dins.c:70
SCIP_Bool SCIPisFeasIntegral(SCIP *scip, SCIP_Real val)
SCIP_Real SCIPsumepsilon(SCIP *scip)
SCIP_RETCODE SCIPinterruptSolve(SCIP *scip)
Definition: scip_solve.c:3516
SCIP_Real SCIPgetUpperbound(SCIP *scip)
public methods for primal heuristics
SCIPallocBlockMemory(scip, subsol))
#define SCIP_CALL_ABORT(x)
Definition: def.h:363
SCIP_HEURDATA * SCIPheurGetData(SCIP_HEUR *heur)
Definition: heur.c:1352
SCIP_Longint SCIPgetNNodes(SCIP *scip)
SCIP_Longint SCIPgetNLPs(SCIP *scip)
public methods for global and local (sub)problems
#define DEFAULT_USEUCT
Definition: heur_dins.c:79
SCIP_Real SCIPgetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var)
Definition: scip_sol.c:1352
#define HEUR_DESC
Definition: heur_dins.c:54
SCIP_RETCODE SCIPaddRealParam(SCIP *scip, const char *name, const char *desc, SCIP_Real *valueptr, SCIP_Bool isadvanced, SCIP_Real defaultvalue, SCIP_Real minvalue, SCIP_Real maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
Definition: scip_param.c:130
SCIP_RETCODE SCIPsetSubscipsOff(SCIP *scip, SCIP_Bool quiet)
Definition: scip_param.c:874
static SCIP_DECL_EVENTEXEC(eventExecDins)
Definition: heur_dins.c:661
#define HEUR_USESSUBSCIP
Definition: heur_dins.c:61
SCIP_RETCODE SCIPsetLongintParam(SCIP *scip, const char *name, SCIP_Longint value)
Definition: scip_param.c:536
SCIP_RETCODE SCIPaddBoolParam(SCIP *scip, const char *name, const char *desc, SCIP_Bool *valueptr, SCIP_Bool isadvanced, SCIP_Bool defaultvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
Definition: scip_param.c:48
SCIP_RETCODE SCIPfree(SCIP **scip)
Definition: scip_general.c:315
SCIP_Longint SCIPgetSolNodenum(SCIP *scip, SCIP_SOL *sol)
Definition: scip_sol.c:1648
memory allocation routines