Scippy

SCIP

Solving Constraint Integer Programs

heur_completesol.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-2018 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_completesol.c
17  * @brief COMPLETESOL - primal heuristic trying to complete given partial solutions
18  * @author Jakob Witzig
19  */
20 
21 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
22 
23 #include <assert.h>
24 #include <string.h>
25 #include <stdio.h>
26 
27 #include "scip/heur_completesol.h"
28 #include "scip/scipdefplugins.h" /* needed for the secondary SCIP instance */
29 #include "scip/pub_misc.h"
30 #include "scip/def.h"
31 
32 #define HEUR_NAME "completesol"
33 #define HEUR_DESC "primal heuristic trying to complete given partial solutions"
34 #define HEUR_DISPCHAR 'h'
35 #define HEUR_PRIORITY 0
36 #define HEUR_FREQ 1
37 #define HEUR_FREQOFS 0
38 #define HEUR_MAXDEPTH 0
39 #define HEUR_TIMING SCIP_HEURTIMING_BEFOREPRESOL | SCIP_HEURTIMING_BEFORENODE
40 #define HEUR_USESSUBSCIP TRUE /**< does the heuristic use a secondary SCIP instance? */
41 
42 /* default values for heuristic plugins */
43 #define DEFAULT_MAXNODES 5000LL /**< maximum number of nodes to regard in the subproblem */
44 #define DEFAULT_MAXUNKRATE 0.85 /**< maximum percentage of unknown solution values */
45 #define DEFAULT_ADDALLSOLS FALSE /**< should all subproblem solutions be added to the original SCIP? */
46 #define DEFAULT_MINNODES 50LL /**< minimum number of nodes to regard in the subproblem */
47 #define DEFAULT_NODESOFS 500LL /**< number of nodes added to the contingent of the total nodes */
48 #define DEFAULT_NODESQUOT 0.1 /**< subproblem nodes in relation to nodes of the original problem */
49 #define DEFAULT_LPLIMFAC 2.0 /**< factor by which the limit on the number of LP depends on the node limit */
50 #define DEFAULT_OBJWEIGHT 1.0 /**< weight of the original objective function (1: only original objective) */
51 #define DEFAULT_BOUNDWIDENING 0.1 /**< bound widening factor applied to continuous variables
52  * (0: round bounds to next integer, 1: relax to global bounds)
53  */
54 #define DEFAULT_MINIMPROVE 0.01 /**< factor by which the incumbent should be improved at least */
55 #define DEFAULT_MINOBJWEIGHT 1e-3 /**< minimal weight for original objective function (zero could lead to infinite solutions) */
56 #define DEFAULT_IGNORECONT FALSE /**< should solution values for continuous variables be ignored? */
57 #define DEFAULT_BESTSOLS 5 /**< heuristic stops, if the given number of improving solutions were found (-1: no limit) */
58 #define DEFAULT_MAXPROPROUNDS 10 /**< maximal number of iterations in propagation (-1: no limit) */
59 #define DEFAULT_MAXLPITER -1LL /**< maximal number of LP iterations (-1: no limit) */
60 #define DEFAULT_MAXCONTVARS -1 /**< maximal number of continuous variables after presolving (-1: no limit) */
61 #define DEFAULT_BEFOREPRESOL TRUE /**< should the heuristic run before presolving? */
62 
63 /* event handler properties */
64 #define EVENTHDLR_NAME "Completesol"
65 #define EVENTHDLR_DESC "LP event handler for " HEUR_NAME " heuristic"
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 nodesofs; /**< number of nodes added to the contingent of the total nodes */
74  SCIP_Longint maxlpiter; /**< maximal number of LP iterations (-1: no limit) */
75  SCIP_Real maxunknownrate; /**< maximal rate of changed coefficients in the objective function */
76  SCIP_Real nodesquot; /**< subproblem nodes in relation to nodes of the original problem */
77  SCIP_Real nodelimit; /**< the nodelimit employed in the current sub-SCIP, for the event handler*/
78  SCIP_Real lplimfac; /**< factor by which the limit on the number of LP depends on the node limit */
79  SCIP_Real objweight; /**< weight of the original objective function (1: only original obj, 0: try to keep to given solution) */
80  SCIP_Real boundwidening; /**< bound widening factor applied to continuous variables
81  * (0: fix variables to given solution values, 1: relax to global bounds)
82  */
83  SCIP_Real minimprove; /**< factor by which the incumbent should be improved at least */
84  SCIP_Bool addallsols; /**< should all subproblem solutions be added to the original SCIP? */
85  SCIP_Bool ignorecont; /**< should solution values for continuous variables be ignored? */
86  SCIP_Bool beforepresol; /**< should the heuristic run before presolving? */
87  int bestsols; /**< heuristic stops, if the given number of improving solutions were found (-1: no limit) */
88  int maxcontvars; /**< maximal number of continuous variables after presolving (-1: no limit) */
89  int maxproprounds; /**< maximal number of iterations in propagation (-1: no limit) */
90 };
91 
92 /* ---------------- Callback methods of event handler ---------------- */
93 
94 /* exec the event handler
95  *
96  * we interrupt the solution process
97  */
98 static
99 SCIP_DECL_EVENTEXEC(eventExecCompletesol)
100 {
101  SCIP_HEURDATA* heurdata;
102 
103  assert(eventhdlr != NULL);
104  assert(eventdata != NULL);
105  assert(strcmp(SCIPeventhdlrGetName(eventhdlr), EVENTHDLR_NAME) == 0);
106  assert(event != NULL);
107  assert(SCIPeventGetType(event) & SCIP_EVENTTYPE_LPSOLVED);
108 
109  heurdata = (SCIP_HEURDATA*)eventdata;
110  assert(heurdata != NULL);
111 
112  /* interrupt solution process of sub-SCIP */
113  if( SCIPgetNLPs(scip) > heurdata->lplimfac * heurdata->nodelimit )
114  {
115  SCIPdebugMsg(scip, "interrupt after %" SCIP_LONGINT_FORMAT " LPs\n",SCIPgetNLPs(scip));
117  }
118 
119  return SCIP_OKAY;
120 }
121 
122 /** creates a subproblem by fixing a number of variables */
123 static
125  SCIP* scip, /**< original SCIP data structure */
126  SCIP* subscip, /**< SCIP data structure for the subproblem */
127  SCIP_HEURDATA* heurdata, /**< heuristic's private data structure */
128  SCIP_VAR** subvars, /**< the variables of the subproblem */
129  SCIP_SOL* partialsol, /**< partial solution */
130  SCIP_Bool* tightened, /**< array to store for which variables we have found bound tightenings */
131  SCIP_Bool* success /**< pointer to store whether the creation was successful */
132  )
133 {
134  SCIP_VAR** vars;
135  SCIP_CONS* objcons;
136  SCIP_Real epsobj;
137  SCIP_Real cutoff;
138  SCIP_Real upperbound;
139  char consobjname[SCIP_MAXSTRLEN];
140  int nvars;
141  int i;
142 
143  assert(scip != NULL);
144  assert(subscip != NULL);
145  assert(subvars != NULL);
146  assert(heurdata != NULL);
147 
148  *success = TRUE;
149 
150  /* if there is already a solution, add an objective cutoff */
151  if( SCIPgetNSols(scip) > 0 )
152  {
153  assert(!SCIPisInfinity(scip, SCIPgetUpperbound(scip)));
154 
155  upperbound = SCIPgetUpperbound(scip) - SCIPsumepsilon(scip);
156 
157  if( !SCIPisInfinity(scip, -1.0 * SCIPgetLowerbound(scip)) )
158  cutoff = (1 - heurdata->minimprove) * SCIPgetUpperbound(scip) + heurdata->minimprove * SCIPgetLowerbound(scip);
159  else
160  {
161  if( SCIPgetUpperbound(scip) >= 0 )
162  cutoff = (1 - heurdata->minimprove) * SCIPgetUpperbound(scip);
163  else
164  cutoff = (1 + heurdata->minimprove) * SCIPgetUpperbound(scip);
165  }
166  cutoff = MIN(upperbound, cutoff);
167  SCIPdebugMsg(scip, "set cutoff=%g for sub-SCIP\n", cutoff);
168  }
169  else
170  cutoff = SCIPinfinity(scip);
171 
172  /* calculate objective coefficients for all potential epsilons */
173  if( SCIPisEQ(scip, heurdata->objweight, 1.0) )
174  return SCIP_OKAY;
175  else if( !SCIPisInfinity(scip, cutoff) )
176  epsobj = 1.0;
177  else
178  {
179  /* divide by objweight to avoid changing objective coefficient of original problem variables */
180  epsobj = (1.0 - heurdata->objweight)/heurdata->objweight;
181 
182  /* scale with -1 if we have a maximization problem */
184  epsobj *= -1.0;
185  }
186 
187  /* get active variables */
188  vars = SCIPgetVars(scip);
189  nvars = SCIPgetNVars(scip);
190 
191  objcons = NULL;
192 
193  /* add constraints to measure the distance to the given partial solution */
194  for( i = 0; i < nvars; i++ )
195  {
196  SCIP_Real solval;
197  int idx;
198 
199  assert(SCIPvarIsActive(vars[i]));
200 
201  /* add objective function as a constraint, if a primal bound exists */
202  if( SCIPisInfinity(scip, cutoff) )
203  {
204  /* create the constraints */
205  if( objcons == NULL )
206  {
207  SCIP_Real lhs;
208  SCIP_Real rhs;
209 
210  if( SCIPgetObjsense(subscip) == SCIP_OBJSENSE_MINIMIZE )
211  {
212  lhs = -SCIPinfinity(subscip);
213  rhs = cutoff;
214  }
215  else
216  {
217  lhs = cutoff;
218  rhs = SCIPinfinity(subscip);
219  }
220 
221  (void)SCIPsnprintf(consobjname, SCIP_MAXSTRLEN, "obj");
222  SCIP_CALL( SCIPcreateConsBasicLinear(subscip, &objcons, consobjname, 0, NULL, NULL, lhs, rhs) );
223  }
224 
225  /* add the variable to the constraints */
226  SCIP_CALL( SCIPaddCoefLinear(subscip, objcons, subvars[i], SCIPvarGetObj(subvars[i])) );
227 
228  /* set objective coefficient to 0.0 */
229  SCIP_CALL( SCIPchgVarObj(subscip, subvars[i], 0.0) );
230  }
231 
232  solval = SCIPgetSolVal(scip, partialsol, vars[i]);
233 
234  /* skip variables with unknown solution value */
235  if( solval == SCIP_UNKNOWN ) /*lint !e777*/
236  continue;
237 
238  idx = SCIPvarGetProbindex(vars[i]);
239  assert(idx >= 0);
240 
241  /* skip variables where we already found some bound tightenings */
242  if( tightened[idx] == FALSE )
243  {
244  /* special case: vars[i] is binary; we do not add an extra variable, but we mimic the behavior we would get with it.
245  * E.g., if the solval is 0.3, setting the variable to 0 would give a cost of 0.3 * epsobj, setting it to 1 gives
246  * 0.7 * epsobj. Thus, 0.3 * epsobj can be treated as a constant in the objective function and the variable gets
247  * an objective coefficient of 0.4 * epsobj.
248  */
249  if( SCIPvarIsBinary(vars[i]) )
250  {
251  SCIP_Real frac = SCIPfeasFrac(scip, solval);
252  SCIP_Real objcoef;
253 
254  frac = MIN(frac, 1-frac);
255  objcoef = (1 - 2*frac) * epsobj * (int)SCIPgetObjsense(scip);
256 
257  if( solval > 0.5 )
258  {
259  SCIP_CALL( SCIPchgVarObj(scip, vars[i], -objcoef) );
260  }
261  else
262  {
263  SCIP_CALL( SCIPchgVarObj(scip, vars[i], objcoef) );
264  }
265  }
266  else
267  {
268  SCIP_CONS* conspos;
269  SCIP_CONS* consneg;
270  SCIP_VAR* eps;
271  char consnamepos[SCIP_MAXSTRLEN];
272  char consnameneg[SCIP_MAXSTRLEN];
273  char epsname[SCIP_MAXSTRLEN];
274 
275  /* create two new variables */
276  (void)SCIPsnprintf(epsname, SCIP_MAXSTRLEN, "eps_%s", SCIPvarGetName(subvars[i]));
277 
278  SCIP_CALL( SCIPcreateVarBasic(subscip, &eps, epsname, 0.0, SCIPinfinity(scip), epsobj, SCIP_VARTYPE_CONTINUOUS) );
279  SCIP_CALL( SCIPaddVar(subscip, eps) );
280 
281  /* create two constraints */
282  (void)SCIPsnprintf(consnamepos, SCIP_MAXSTRLEN, "cons_%s_pos", SCIPvarGetName(subvars[i]));
283  (void)SCIPsnprintf(consnameneg, SCIP_MAXSTRLEN, "cons_%s_neq", SCIPvarGetName(subvars[i]));
284 
285  /* x_{i} - s_{i} <= e_{i} <==> x_{i} - e_{i} <= s_{i} */
286  SCIP_CALL( SCIPcreateConsBasicLinear(subscip, &conspos, consnamepos, 0, NULL, NULL, -SCIPinfinity(scip), solval) );
287  SCIP_CALL( SCIPaddCoefLinear(subscip, conspos, subvars[i], 1.0) );
288  SCIP_CALL( SCIPaddCoefLinear(subscip, conspos, eps, -1.0) );
289  SCIP_CALL( SCIPaddCons(subscip, conspos) );
290  SCIP_CALL( SCIPreleaseCons(subscip, &conspos) );
291 
292  /* s_{i} - x_{i} <= e_{i} <==> e_{i} - x_{i} >= s_{i} */
293  SCIP_CALL( SCIPcreateConsBasicLinear(subscip, &consneg, consnameneg, 0, NULL, NULL, solval, SCIPinfinity(scip)) );
294  SCIP_CALL( SCIPaddCoefLinear(subscip, consneg, subvars[i], -1.0) );
295  SCIP_CALL( SCIPaddCoefLinear(subscip, consneg, eps, 1.0) );
296  SCIP_CALL( SCIPaddCons(subscip, consneg) );
297  SCIP_CALL( SCIPreleaseCons(subscip, &consneg) );
298 
299  /* release the variables */
300  SCIP_CALL( SCIPreleaseVar(subscip, &eps) );
301  }
302  }
303  }
304 
305  /* add and release the constraint representing the original objective function */
306  if( objcons != NULL )
307  {
308  SCIP_CALL( SCIPaddCons(subscip, objcons) );
309  SCIP_CALL( SCIPreleaseCons(subscip, &objcons) );
310  }
311 
312  return SCIP_OKAY;
313 }
314 
315 /** creates a new solution for the original problem by copying the solution of the subproblem */
316 static
318  SCIP* scip, /**< original SCIP data structure */
319  SCIP* subscip, /**< SCIP structure of the subproblem */
320  SCIP_VAR** subvars, /**< the variables of the subproblem */
321  SCIP_HEUR* heur, /**< Completesol heuristic structure */
322  SCIP_SOL* subsol, /**< solution of the subproblem or the partial */
323  SCIP_Bool* success /**< used to store whether new solution was found or not */
324  )
325 {
326  SCIP_VAR** vars; /* the original problem's variables */
327  int nvars; /* the original problem's number of variables */
328  SCIP_SOL* newsol; /* solution to be created for the original problem */
329  int v;
330 
331  assert(scip != NULL);
332  assert(subscip != NULL);
333  assert(subvars != NULL);
334  assert(subsol != NULL);
335 
336  /* get variables' data */
337  SCIP_CALL( SCIPgetVarsData(scip, &vars, &nvars, NULL, NULL, NULL, NULL) );
338 
339  /* sub-SCIP may have more variables than the number of active (transformed) variables in the main SCIP
340  * since constraint copying may have required the copy of variables that are fixed in the main SCIP
341  */
342  assert(nvars <= SCIPgetNOrigVars(subscip));
343 
344  /* create new solution for the original problem */
345  SCIP_CALL( SCIPcreateSol(scip, &newsol, heur) );
346 
347  for( v = 0; v < nvars; v++ )
348  {
349  SCIP_Real solval = SCIPgetSolVal(subscip, subsol, subvars[v]);
350 
351  assert(!SCIPisInfinity(subscip, solval) && !SCIPisInfinity(subscip, -solval));
352  assert(solval != SCIP_UNKNOWN); /*lint !e777*/
353 
354  SCIP_CALL( SCIPsetSolVal(scip, newsol, vars[v], solval) );
355  }
356 
357  /* try to add new solution to SCIP and free it immediately */
358  SCIP_CALL( SCIPtrySolFree(scip, &newsol, FALSE, FALSE, TRUE, TRUE, TRUE, success) );
359 
360  return SCIP_OKAY;
361 }
362 
363 /** perform a probing bound change or fixes the variable */
364 static
366  SCIP* scip, /**< original SCIP data structure */
367  SCIP_VAR* var, /**< problem variable */
368  SCIP_Real newval, /**< new bound */
369  SCIP_BRANCHDIR branchdir, /**< bound change direction */
370  SCIP_Bool* success /**< pointer to store whether the bound could be tightened */
371  )
372 {
373  SCIP_Real ub;
374  SCIP_Real lb;
375 
376  assert(scip != NULL);
377  assert(var != NULL);
378 
379  (*success) = FALSE;
380 
381  ub = SCIPvarGetUbLocal(var);
382  lb = SCIPvarGetLbLocal(var);
383 
384  switch (branchdir) {
386  if( SCIPisLT(scip, newval, ub) && SCIPisGE(scip, newval, lb) )
387  {
388  SCIP_CALL( SCIPchgVarUbProbing(scip, var, newval) );
389  (*success) = TRUE;
390  }
391  break;
393  if( SCIPisLE(scip, newval, ub) && SCIPisGT(scip, newval, lb) )
394  {
395  SCIP_CALL( SCIPchgVarLbProbing(scip, var, newval) );
396  (*success) = TRUE;
397  }
398  break;
400  if( SCIPisLE(scip, newval, ub) && SCIPisGE(scip, newval, lb) )
401  {
402  SCIP_CALL( SCIPfixVarProbing(scip, var, newval) );
403  (*success) = TRUE;
404  }
405  break;
406  default:
407  return SCIP_INVALIDDATA;
408  }/*lint !e788*/
409 
410  return SCIP_OKAY;
411 }
412 
413 /** tries variables bound changes guided by the given solution */
414 static
416  SCIP* scip, /**< original SCIP data structure */
417  SCIP_HEURDATA* heurdata, /**< heuristic's private data structure */
418  SCIP_VAR** vars, /**< problem variables */
419  int nvars, /**< number of problem variables */
420  SCIP_SOL* sol, /**< solution to guide the bound changes */
421  SCIP_Bool* tightened, /**< array to store if variable bound could be tightened */
422  SCIP_Bool* success /**< pointer to store the success */
423  )
424 {
425 #ifndef NDEBUG
426  SCIP_Bool incontsection;
427 #endif
428  SCIP_Bool abortearly;
429  SCIP_Bool cutoff;
430  SCIP_Bool probingsuccess;
431  SCIP_Longint ndomreds;
432  SCIP_Longint ndomredssum;
433  int nbndtightenings;
434  int v;
435 
436  assert(scip != NULL);
437  assert(heurdata != NULL);
438  assert(vars != NULL);
439  assert(nvars >= 0);
440  assert(sol != NULL);
441  assert(tightened != NULL);
442 
444 
445  SCIPdebugMsg(scip, "> start probing along the solution values\n");
446 
447  *success = TRUE;
448  abortearly = FALSE;
449  nbndtightenings = 0;
450  ndomredssum = 0;
451 #ifndef NDEBUG
452  incontsection = FALSE;
453 #endif
454 
455  /* there is at least one integral variable; open one probing node for all non-continuous variables */
456  if( nvars - SCIPgetNContVars(scip) > 0 )
457  {
458  SCIP_CALL( SCIPnewProbingNode(scip) );
459  }
460 
461  for( v = 0; v < nvars && !abortearly; v++ )
462  {
463  SCIP_Real solval;
464 
465  assert(SCIPvarIsActive(vars[v]));
466 
467  cutoff = FALSE;
468  ndomreds = 0;
469 
470 #ifndef NDEBUG
471  incontsection |= (!SCIPvarIsIntegral(vars[v])); /*lint !e514*/
472  assert(!incontsection || !SCIPvarIsIntegral(vars[v]));
473 #endif
474 
475  /* return if we have found enough domain reductions tightenings */
476  if( ndomredssum > 0.3*nvars )
477  break;
478 
479  solval = SCIPgetSolVal(scip, sol, vars[v]);
480 
481  /* skip unknown variables */
482  if( solval == SCIP_UNKNOWN ) /*lint !e777*/
483  continue;
484  assert(!SCIPisInfinity(scip, solval) && !SCIPisInfinity(scip, -solval));
485 
486  /* variable is binary or integer */
487  if( SCIPvarIsIntegral(vars[v]) )
488  {
489  /* the solution value is integral, try to fix them */
490  if( SCIPisIntegral(scip, solval) )
491  {
492  SCIP_CALL( chgProbingBound(scip, vars[v], solval, SCIP_BRANCHDIR_FIXED, &probingsuccess) );
493  tightened[SCIPvarGetProbindex(vars[v])] = TRUE;
494  ++nbndtightenings;
495 
496 #ifdef SCIP_MORE_DEBUG
497  SCIPdebugMsg(scip, "> fix variable <%s> = [%g,%g] to %g \n", SCIPvarGetName(vars[v]),
498  SCIPvarGetLbGlobal(vars[v]), SCIPvarGetUbGlobal(vars[v]), solval);
499 #endif
500  }
501  else
502  {
503  SCIP_Real ub = SCIPceil(scip, solval) + 1.0;
504  SCIP_Real lb = SCIPfloor(scip, solval) - 1.0;
505 
506  /* try tightening of upper bound */
507  if( SCIPisLT(scip, ub, SCIPvarGetUbLocal(vars[v])) )
508  {
509  SCIP_CALL( chgProbingBound(scip, vars[v], solval, SCIP_BRANCHDIR_DOWNWARDS, &probingsuccess) );
510  tightened[SCIPvarGetProbindex(vars[v])] = TRUE;
511  ++nbndtightenings;
512 
513 #ifdef SCIP_MORE_DEBUG
514  SCIPdebugMsg(scip, "> tighten upper bound of variable <%s>: %g to %g\n", SCIPvarGetName(vars[v]),
515  SCIPvarGetUbGlobal(vars[v]), ub);
516 #endif
517  }
518 
519  /* try tightening of lower bound */
520  if( SCIPisGT(scip, lb, SCIPvarGetLbLocal(vars[v])) )
521  {
522  SCIP_CALL( chgProbingBound(scip, vars[v], solval, SCIP_BRANCHDIR_UPWARDS, &probingsuccess) );
523  tightened[SCIPvarGetProbindex(vars[v])] = TRUE;
524  ++nbndtightenings;
525 
526 #ifdef SCIP_MORE_DEBUG
527  SCIPdebugMsg(scip, "> tighten lower bound of variable <%s>: %g to %g\n", SCIPvarGetName(vars[v]),
528  SCIPvarGetLbGlobal(vars[v]), ub);
529 #endif
530  }
531  }
532  }
533  /* variable is continuous */
534  else
535  {
536  /* fix to lb or ub */
537  if( SCIPisEQ(scip, solval, SCIPvarGetLbLocal(vars[v])) || SCIPisEQ(scip, solval, SCIPvarGetUbLocal(vars[v])) )
538  {
539  /* open a new probing node */
540  if( SCIPgetProbingDepth(scip) < SCIP_MAXTREEDEPTH-10 )
541  {
542  SCIP_CALL( SCIPnewProbingNode(scip) );
543 
544  SCIP_CALL( chgProbingBound(scip, vars[v], solval, SCIP_BRANCHDIR_FIXED, &probingsuccess) );
545 
546  /* skip propagation if the bound could not be changed, e.g., already tightened due to previous
547  * domain propagation
548  */
549  if( probingsuccess )
550  {
551  SCIP_CALL( SCIPpropagateProbing(scip, heurdata->maxproprounds, &cutoff, &ndomreds) );
552  }
553 
554  if( cutoff )
555  {
556  ndomreds = 0;
558  }
559  else
560  {
561  assert(SCIPvarGetProbindex(vars[v]) >= 0);
562  tightened[SCIPvarGetProbindex(vars[v])] = TRUE;
563  ++nbndtightenings;
564 #ifdef SCIP_MORE_DEBUG
565  SCIPdebugMsg(scip, "> fix variable <%s> = [%g,%g] to %g (ndomreds=%lld)\n", SCIPvarGetName(vars[v]),
566  SCIPvarGetLbGlobal(vars[v]), SCIPvarGetUbGlobal(vars[v]), solval, ndomreds);
567 #endif
568  }
569  }
570  else
571  /* abort probing */
572  abortearly = TRUE;
573  }
574  else
575  {
576  SCIP_Real offset;
577  SCIP_Real newub = SCIPvarGetUbGlobal(vars[v]);
578  SCIP_Real newlb = SCIPvarGetLbGlobal(vars[v]);
579 
580  /* both bound are finite */
581  if( !SCIPisInfinity(scip, -newlb) && !SCIPisInfinity(scip, newub) )
582  offset = REALABS(heurdata->boundwidening * (newub-newlb));
583  else
584  {
585  /* if one bound is finite, widen bound w.r.t. solution value and finite bound */
586  if( !SCIPisInfinity(scip, -newlb) )
587  offset = REALABS(heurdata->boundwidening * (solval-newlb));
588  else
589  {
590  assert(!SCIPisInfinity(scip, newub));
591  offset = REALABS(heurdata->boundwidening * (newub-solval));
592  }
593  }
594 
595  /* update bounds */
596  newub = SCIPceil(scip, solval) + offset;
597  newlb = SCIPfloor(scip, solval) - offset;
598 
599  /* try tightening of upper bound */
600  if( SCIPisLT(scip, newub, SCIPvarGetUbLocal(vars[v])) )
601  {
602  /* open a new probing node */
603  if( SCIPgetProbingDepth(scip) < SCIP_MAXTREEDEPTH-10 )
604  {
605  SCIP_CALL( SCIPnewProbingNode(scip) );
606  SCIP_CALL( chgProbingBound(scip, vars[v], newub, SCIP_BRANCHDIR_DOWNWARDS, &probingsuccess) );
607 
608  /* skip propagation if the bound could not be changed, e.g., already tightened due to previous
609  * domain propagation
610  */
611  if( probingsuccess )
612  {
613  SCIP_CALL( SCIPpropagateProbing(scip, heurdata->maxproprounds, &cutoff, &ndomreds) );
614  }
615 
616  if( cutoff )
617  {
618  ndomreds = 0;
619 
620  /* backtrack to last feasible probing node */
622 
623  /* we can tighten the lower bound by newub */
624  SCIP_CALL( chgProbingBound(scip, vars[v], newub, SCIP_BRANCHDIR_UPWARDS, &probingsuccess) );
625 
626  /* propagate the new bound */
627  SCIP_CALL( SCIPpropagateProbing(scip, heurdata->maxproprounds, &cutoff, &ndomreds) );
628 
629  /* there is no feasible solution w.r.t. the current bounds */
630  if( cutoff )
631  {
632  SCIPdebugMsg(scip, "> subproblem is infeasible within the local bounds\n");
633  *success = FALSE;
634  return SCIP_OKAY;
635  }
636 #ifdef SCIP_MORE_DEBUG
637  SCIPdebugMsg(scip, "> tighten lower bound of variable <%s>: %g to %g\n",
638  SCIPvarGetName(vars[v]), SCIPvarGetLbGlobal(vars[v]), newub);
639 #endif
640  }
641  else
642  {
643  assert(SCIPvarGetProbindex(vars[v]) >= 0);
644  tightened[SCIPvarGetProbindex(vars[v])] = TRUE;
645  ++nbndtightenings;
646 #ifdef SCIP_MORE_DEBUG
647  SCIPdebugMsg(scip, "> tighten upper bound of variable <%s>: %g to %g (ndomreds=%lld)\n",
648  SCIPvarGetName(vars[v]), SCIPvarGetUbGlobal(vars[v]), newub, ndomreds);
649 #endif
650  }
651  }
652  else
653  /* abort probing */
654  abortearly = TRUE;
655  }
656 
657  /* try tightening of lower bound */
658  if( SCIPisGT(scip, newlb, SCIPvarGetLbLocal(vars[v])) )
659  {
660  /* open a new probing node */
661  if( SCIPgetProbingDepth(scip) < SCIP_MAXTREEDEPTH-10 )
662  {
663  SCIP_CALL( SCIPnewProbingNode(scip) );
664  SCIP_CALL( chgProbingBound(scip, vars[v], newlb, SCIP_BRANCHDIR_UPWARDS, &probingsuccess) );
665 
666  /* skip propagation if the bound could not be changed, e.g., already tightened due to previous
667  * domain propagation
668  */
669  if( probingsuccess )
670  {
671  SCIP_CALL( SCIPpropagateProbing(scip, -1, &cutoff, &ndomreds) );
672  }
673 
674  if( cutoff )
675  {
676  ndomreds = 0;
677 
678  /* backtrack to last feasible probing node */
680 
681  /* we can tighten the upper bound by newlb */
682  SCIP_CALL( chgProbingBound(scip, vars[v], newlb, SCIP_BRANCHDIR_DOWNWARDS, &probingsuccess) );
683 
684  /* propagate the new bound */
685  SCIP_CALL( SCIPpropagateProbing(scip, heurdata->maxproprounds, &cutoff, &ndomreds) );
686 
687  /* there is no feasible solution w.r.t. the current bounds */
688  if( cutoff )
689  {
690  SCIPdebugMsg(scip, "> subproblem is infeasible within the local bounds\n");
691  *success = FALSE;
692  return SCIP_OKAY;
693  }
694 #ifdef SCIP_MORE_DEBUG
695  SCIPdebugMsg(scip, "> tighten upper bound of variable <%s>: %g to %g\n",
696  SCIPvarGetName(vars[v]), SCIPvarGetUbGlobal(vars[v]), newlb);
697 #endif
698  }
699  else
700  {
701  assert(SCIPvarGetProbindex(vars[v]) >= 0);
702  tightened[SCIPvarGetProbindex(vars[v])] = TRUE;
703  ++nbndtightenings;
704 #ifdef SCIP_MORE_DEBUG
705  SCIPdebugMsg(scip, "> tighten lower bound of variable <%s>: %g to %g (ndomreds=%lld)\n",
706  SCIPvarGetName(vars[v]), SCIPvarGetLbGlobal(vars[v]), newlb, ndomreds);
707 #endif
708  }
709  }
710  else
711  /* abort probing */
712  abortearly = TRUE;
713  }
714  }
715  }
716 
717  ndomredssum += ndomreds;
718  }
719 
720  SCIPdebugMsg(scip, "> found %d bound tightenings and %lld induced domain reductions (abort=%u).\n", nbndtightenings,
721  ndomredssum, abortearly);
722 
723  return SCIP_OKAY;
724 }
725 
726 /* setup and solve the sub-SCIP */
727 static
729  SCIP* scip, /**< original SCIP data structure */
730  SCIP* subscip, /**< sub-SCIP data structure */
731  SCIP_HEUR* heur, /**< heuristic data structure */
732  SCIP_HEURDATA* heurdata, /**< heuristic's private data structure */
733  SCIP_RESULT* result, /**< result data structure */
734  SCIP_Longint nstallnodes, /**< number of stalling nodes for the subproblem */
735  SCIP_SOL* partialsol, /**< partial solution */
736  SCIP_Bool* tightened /**< array to store whether a variable was already tightened */
737  )
738 {
739  SCIP_HASHMAP* varmapf;
740  SCIP_VAR** vars;
741  SCIP_VAR** subvars = NULL;
742  SCIP_EVENTHDLR* eventhdlr;
743  int nvars;
744  int i;
745 
746  SCIP_SOL** subsols;
747  int nsubsols;
748 
749  SCIP_Bool valid;
750  SCIP_Bool success;
751  SCIP_RETCODE retcode;
752 
753  assert(scip != NULL);
754  assert(subscip != NULL);
755  assert(heur != NULL);
756  assert(heurdata != NULL);
757  assert(result != NULL);
758  assert(partialsol != NULL);
759 
760  vars = SCIPgetVars(scip);
761  nvars = SCIPgetNVars(scip);
762 
763  /* create the variable mapping hash map */
764  SCIP_CALL( SCIPhashmapCreate(&varmapf, SCIPblkmem(subscip), nvars) );
765 
766  eventhdlr = NULL;
767  valid = FALSE;
768 
769  /* copy complete SCIP instance */
770  SCIP_CALL( SCIPcopyConsCompression(scip, subscip, varmapf, NULL, "completesol", NULL, NULL, 0, FALSE, FALSE, TRUE, &valid) );
771  SCIPdebugMsg(scip, "Copying the SCIP instance returned with valid=%d.\n", valid);
772 
773  /* create event handler for LP events */
774  SCIP_CALL( SCIPincludeEventhdlrBasic(subscip, &eventhdlr, EVENTHDLR_NAME, EVENTHDLR_DESC, eventExecCompletesol, NULL) );
775  if( eventhdlr == NULL )
776  {
777  SCIPerrorMessage("event handler for " HEUR_NAME " heuristic not found.\n");
778  return SCIP_PLUGINNOTFOUND;
779  }
780 
781  /* allocate memory to align the SCIP and the sub-SCIP variables */
782  SCIP_CALL( SCIPallocBufferArray(scip, &subvars, nvars) );
783 
784  /* map all variables */
785  for( i = 0; i < nvars; i++ )
786  {
787  subvars[i] = (SCIP_VAR*) SCIPhashmapGetImage(varmapf, vars[i]);
788  assert(subvars[i] != NULL);
789  }
790 
791  /* free hash map */
792  SCIPhashmapFree(&varmapf);
793 
794  /* create a new problem, which fixes variables with same value in bestsol and LP relaxation */
795  SCIP_CALL( createSubproblem(scip, subscip, heurdata, subvars, partialsol, tightened, &success) );
796  if( !success )
797  {
798  SCIPdebugMsg(scip, "Error while creating completesol subproblem w.r.t. partial solution <%p>.\n", (void*)partialsol);
799  goto TERMINATE;
800  }
801  SCIPdebugMsg(scip, "Completesol subproblem: %d vars, %d cons\n", SCIPgetNVars(subscip), SCIPgetNConss(subscip));
802 
803  /* do not abort subproblem on CTRL-C */
804  SCIP_CALL( SCIPsetBoolParam(subscip, "misc/catchctrlc", FALSE) );
805 
806 #ifdef SCIP_DEBUG
807  /* for debugging, enable full output */
808  SCIP_CALL( SCIPsetIntParam(subscip, "display/verblevel", SCIP_VERBLEVEL_FULL) );
809  SCIP_CALL( SCIPsetIntParam(subscip, "display/freq", -1) );
810 #else
811  /* disable statistic timing inside sub SCIP and output to console */
812  SCIP_CALL( SCIPsetIntParam(subscip, "display/verblevel", (int) SCIP_VERBLEVEL_NONE) );
813  SCIP_CALL( SCIPsetBoolParam(subscip, "timing/statistictiming", FALSE) );
814 #endif
815 
816  /* set limits for the subproblem */
817  SCIP_CALL( SCIPcopyLimits(scip, subscip) );
818  heurdata->nodelimit = heurdata->maxnodes;
819  SCIP_CALL( SCIPsetLongintParam(subscip, "limits/stallnodes", nstallnodes) );
820  SCIP_CALL( SCIPsetLongintParam(subscip, "limits/nodes", heurdata->maxnodes) );
821  SCIP_CALL( SCIPsetIntParam(subscip, "limits/bestsol", heurdata->bestsols) );
822 
823  /* limit the number of LP iterations */
824  SCIP_CALL( SCIPsetLongintParam(subscip, "lp/iterlim", heurdata->maxlpiter) );
825  SCIP_CALL( SCIPsetLongintParam(subscip, "lp/rootiterlim", heurdata->maxlpiter) );
826 
827  /* forbid recursive call of heuristics and separators solving sub-SCIPs */
828  SCIP_CALL( SCIPsetSubscipsOff(subscip, TRUE) );
829 
830  /* disable cutting plane separation */
832 
833  /* disable expensive presolving */
835 
836  /* use best estimate node selection */
837  if( SCIPfindNodesel(subscip, "estimate") != NULL && !SCIPisParamFixed(subscip, "nodeselection/estimate/stdpriority") )
838  {
839  SCIP_CALL( SCIPsetIntParam(subscip, "nodeselection/estimate/stdpriority", INT_MAX/4) );
840  }
841 
842  /* use inference branching */
843  if( SCIPfindBranchrule(subscip, "inference") != NULL && !SCIPisParamFixed(subscip, "branching/inference/priority") )
844  {
845  SCIP_CALL( SCIPsetIntParam(subscip, "branching/inference/priority", INT_MAX/4) );
846  }
847 
848  /* disable conflict analysis */
849  if( !SCIPisParamFixed(subscip, "conflict/enable") )
850  {
851  SCIP_CALL( SCIPsetBoolParam(subscip, "conflict/enable", FALSE) );
852  }
853 
854  /* speed up sub-SCIP by not checking dual LP feasibility */
855  SCIP_CALL( SCIPsetBoolParam(subscip, "lp/checkdualfeas", FALSE) );
856 
857  SCIP_CALL( SCIPtransformProb(subscip) );
858  SCIP_CALL( SCIPcatchEvent(subscip, SCIP_EVENTTYPE_LPSOLVED, eventhdlr, (SCIP_EVENTDATA*) heurdata, NULL) );
859 
860  /* solve the subproblem */
861  SCIPdebugMsg(scip, "solving subproblem: nstallnodes=%" SCIP_LONGINT_FORMAT ", maxnodes=%" SCIP_LONGINT_FORMAT "\n", nstallnodes, heurdata->maxnodes);
862 
863  /* errors in solving the subproblem should not kill the overall solving process;
864  * hence, the return code is caught and a warning is printed, only in debug mode, SCIP will stop.
865  */
866 
867  retcode = SCIPpresolve(subscip);
868 
869  /* errors in presolving the subproblem should not kill the overall solving process;
870  * hence, the return code is caught and a warning is printed, only in debug mode, SCIP will stop.
871  */
872  if( retcode != SCIP_OKAY )
873  {
874  SCIPwarningMessage(scip, "Error while presolving subproblem in %s heuristic; sub-SCIP terminated with code <%d>\n", HEUR_NAME, retcode);
875 
876  SCIPABORT(); /*lint --e{527}*/
877 
878  goto TERMINATE;
879  }
880 
881  if( SCIPgetStage(subscip) == SCIP_STAGE_PRESOLVED )
882  {
883  SCIPdebugMsg(scip, "presolved instance has bin=%d, int=%d, cont=%d variables\n",
884  SCIPgetNBinVars(subscip), SCIPgetNIntVars(subscip), SCIPgetNContVars(subscip));
885 
886  /* check whether the presolved instance is small enough */
887  if( heurdata->maxcontvars >= 0 && SCIPgetNContVars(subscip) > heurdata->maxcontvars )
888  {
889  SCIPdebugMsg(scip, "presolved instance has too many continuous variables (maxcontvars: %d)\n", heurdata->maxcontvars);
890  goto TERMINATE;
891  }
892 
893  /* set node limit of 1 if the presolved problem is an LP, otherwise we would start branching if an LP iteration
894  * limit was set by the user.
895  */
896  if( !SCIPisNLPEnabled(subscip) && SCIPgetNContVars(subscip) == SCIPgetNVars(subscip) )
897  {
898  SCIP_CALL( SCIPsetLongintParam(subscip, "limits/nodes", 1LL) );
899  }
900 
901  retcode = SCIPsolve(subscip);
902 
903  /* errors in solving the subproblem should not kill the overall solving process;
904  * hence, the return code is caught and a warning is printed, only in debug mode, SCIP will stop.
905  */
906  if( retcode != SCIP_OKAY )
907  {
908  SCIPwarningMessage(scip, "Error while solving subproblem in %s heuristic; sub-SCIP terminated with code <%d>\n", HEUR_NAME, retcode);
909 
910  SCIPABORT(); /*lint --e{527}*/
911 
912  goto TERMINATE;
913  }
914  }
915 
916  SCIP_CALL( SCIPdropEvent(subscip, SCIP_EVENTTYPE_LPSOLVED, eventhdlr, (SCIP_EVENTDATA*) heurdata, -1) );
917 
918  /* print solving statistics of subproblem if we are in SCIP's debug mode */
919  SCIPdebug( SCIP_CALL( SCIPprintStatistics(subscip, NULL) ) );
920 
921  /* check, whether a solution was found;
922  * due to numerics, it might happen that not all solutions are feasible -> try all solutions until one was accepted
923  */
924  nsubsols = SCIPgetNSols(subscip);
925  subsols = SCIPgetSols(subscip);
926  success = FALSE;
927  for( i = 0; i < nsubsols && (!success || heurdata->addallsols); i++ )
928  {
929  SCIP_CALL( createNewSol(scip, subscip, subvars, heur, subsols[i], &success) );
930  if( success )
931  *result = SCIP_FOUNDSOL;
932  }
933 
934  SCIPstatisticPrintf("%s statistic: fixed %6.3f integer variables, needed %6.1f seconds, %" SCIP_LONGINT_FORMAT " nodes, solution %10.4f found at node %" SCIP_LONGINT_FORMAT "\n",
935  HEUR_NAME, 0.0, SCIPgetSolvingTime(subscip), SCIPgetNNodes(subscip), success ? SCIPgetPrimalbound(scip) : SCIPinfinity(scip),
936  nsubsols > 0 ? SCIPsolGetNodenum(SCIPgetBestSol(subscip)) : -1 );
937 
938  TERMINATE:
939  SCIPfreeBufferArray(scip, &subvars);
940 
941  return SCIP_OKAY;
942 }
943 
944 /** main procedure of the completesol heuristic, creates and solves a sub-SCIP */
945 static
947  SCIP* scip, /**< original SCIP data structure */
948  SCIP_HEUR* heur, /**< heuristic data structure */
949  SCIP_HEURDATA* heurdata, /**< heuristic's private data structure */
950  SCIP_RESULT* result, /**< result data structure */
951  SCIP_Longint nstallnodes, /**< number of stalling nodes for the subproblem */
952  SCIP_SOL* partialsol /**< partial solution */
953  )
954 {
955  SCIP* subscip;
956  SCIP_VAR** vars;
957  SCIP_Bool* tightened;
958  SCIP_Bool success;
959  SCIP_RETCODE retcode;
960  int nvars;
961 
962  assert(scip != NULL);
963  assert(heur != NULL);
964  assert(heurdata != NULL);
965  assert(result != NULL);
966  assert(partialsol != NULL);
967 
968  *result = SCIP_DIDNOTRUN;
969 
970  SCIPdebugMsg(scip, "+---+ Start Completesol heuristic +---+\n");
971 
972  /* check whether there is enough time and memory left */
973  SCIP_CALL( SCIPcheckCopyLimits(scip, &success) );
974 
975  if( !success )
976  return SCIP_OKAY;
977 
978  *result = SCIP_DIDNOTFIND;
979 
980  /* get variable data */
981  vars = SCIPgetVars(scip);
982  nvars = SCIPgetNVars(scip);
983 
984  /* get buffer memory and initialize it to FALSE */
985  SCIP_CALL( SCIPallocClearBufferArray(scip, &tightened, nvars) );
986 
987  SCIP_CALL( SCIPstartProbing(scip) );
988 
989  SCIP_CALL( tightenVariables(scip, heurdata, vars, nvars, partialsol, tightened, &success) );
990 
991  if( !success )
992  goto ENDPROBING;
993 
994  /* initialize the subproblem */
995  SCIP_CALL( SCIPcreate(&subscip) );
996 
997  retcode = setupAndSolve(scip, subscip, heur, heurdata, result, nstallnodes, partialsol, tightened);
998 
999  /* free subproblem */
1000  SCIP_CALL( SCIPfree(&subscip) );
1001 
1002  SCIP_CALL( retcode );
1003 
1004  ENDPROBING:
1005  SCIPfreeBufferArray(scip, &tightened);
1006  SCIP_CALL( SCIPendProbing(scip) );
1007 
1008 
1009 
1010  return SCIP_OKAY;
1011 }
1012 
1013 
1014 /*
1015  * Callback methods of primal heuristic
1016  */
1017 
1018 /** copy method for primal heuristic plugins (called when SCIP copies plugins) */
1019 static
1020 SCIP_DECL_HEURCOPY(heurCopyCompletesol)
1021 { /*lint --e{715}*/
1022  assert(scip != NULL);
1023  assert(heur != NULL);
1024  assert(strcmp(SCIPheurGetName(heur), HEUR_NAME) == 0);
1025 
1026  /* call inclusion method of primal heuristic */
1028 
1029  return SCIP_OKAY;
1030 }
1031 
1032 /** destructor of primal heuristic to free user data (called when SCIP is exiting) */
1033 static
1034 SCIP_DECL_HEURFREE(heurFreeCompletesol)
1035 { /*lint --e{715}*/
1036  SCIP_HEURDATA* heurdata;
1037 
1038  assert(heur != NULL);
1039  assert(scip != NULL);
1040 
1041  /* get heuristic data */
1042  heurdata = SCIPheurGetData(heur);
1043  assert(heurdata != NULL);
1044 
1045  /* free heuristic data */
1046  SCIPfreeBlockMemory(scip, &heurdata);
1047  SCIPheurSetData(heur, NULL);
1048 
1049  return SCIP_OKAY;
1050 }
1051 
1052 /** execution method of primal heuristic */
1053 static
1054 SCIP_DECL_HEUREXEC(heurExecCompletesol)
1055 {/*lint --e{715}*/
1056  SCIP_HEURDATA* heurdata;
1057  SCIP_VAR** vars;
1058  SCIP_SOL** partialsols;
1059  SCIP_Longint nstallnodes;
1060  int npartialsols;
1061  int nunknown;
1062  int nfracints;
1063  int nvars;
1064  int s;
1065  int v;
1066 
1067  assert( heur != NULL );
1068  assert( scip != NULL );
1069  assert( result != NULL );
1070 
1071  *result = SCIP_DELAYED;
1072 
1073  /* do not call heuristic of node was already detected to be infeasible */
1074  if( nodeinfeasible )
1075  return SCIP_OKAY;
1076 
1077  /* get heuristic data */
1078  heurdata = SCIPheurGetData(heur);
1079  assert( heurdata != NULL );
1080 
1081  *result = SCIP_DIDNOTRUN;
1082 
1083  if( SCIPisStopped(scip) )
1084  return SCIP_OKAY;
1085 
1086  /* do not run after restart */
1087  if( SCIPgetNRuns(scip) > 1 )
1088  return SCIP_OKAY;
1089 
1090  /* check whether we want to run before presolving */
1091  if( heurtiming == SCIP_HEURTIMING_BEFOREPRESOL && !heurdata->beforepresol )
1092  return SCIP_OKAY;
1093 
1094  /* only run before root node */
1096  return SCIP_OKAY;
1097 
1098  /* get variable data and return of no variables are left in the problem */
1099  vars = SCIPgetVars(scip);
1100  nvars = SCIPgetNVars(scip);
1101 
1102  if( nvars == 0 )
1103  return SCIP_OKAY;
1104 
1105  /* calculate the maximal number of branching nodes until heuristic is aborted */
1106  nstallnodes = (SCIP_Longint)(heurdata->nodesquot * SCIPgetNNodes(scip));
1107 
1108  /* reward Completesol if it succeeded often */
1109  nstallnodes = (SCIP_Longint)(nstallnodes * 3.0 * (SCIPheurGetNBestSolsFound(heur)+1.0)/(SCIPheurGetNCalls(heur) + 1.0));
1110  nstallnodes -= 100 * SCIPheurGetNCalls(heur); /* count the setup costs for the sub-SCIP as 100 nodes */
1111  nstallnodes += heurdata->nodesofs;
1112 
1113  /* determine the node limit for the current process */
1114  nstallnodes = MIN(nstallnodes, heurdata->maxnodes);
1115 
1116  /* check whether we have enough nodes left to call subproblem solving */
1117  if( nstallnodes < heurdata->minnodes )
1118  {
1119  SCIPdebugMsg(scip, "skipping Complete: nstallnodes=%" SCIP_LONGINT_FORMAT ", minnodes=%" SCIP_LONGINT_FORMAT "\n",
1120  nstallnodes, heurdata->minnodes);
1121  return SCIP_OKAY;
1122  }
1123 
1124  /* check the number of variables with unknown value and continuous variables with fractional value */
1125  nfracints = 0;
1126 
1127  /* get all partial sols */
1128  npartialsols = SCIPgetNPartialSols(scip);
1129  partialsols = SCIPgetPartialSols(scip);
1130 
1131  /* loop over all partial solutions */
1132  for( s = 0; s < npartialsols; s++ )
1133  {
1134  SCIP_SOL* sol;
1135  SCIP_Real solval;
1136  SCIP_Real unknownrate;
1137 
1138  sol = partialsols[s];
1139  assert(sol != NULL);
1140  assert(SCIPsolIsPartial(sol));
1141 
1142  nunknown = 0;
1143  /* loop over all variables */
1144  for( v = 0; v < nvars; v++ )
1145  {
1146  assert(SCIPvarIsActive(vars[v]));
1147 
1148  /* skip continuous variables if they should ignored */
1149  if( !SCIPvarIsIntegral(vars[v]) && heurdata->ignorecont )
1150  continue;
1151 
1152  solval = SCIPgetSolVal(scip, sol, vars[v]);
1153 
1154  /* we only want to count variables that are unfixed after the presolving */
1155  if( solval == SCIP_UNKNOWN ) /*lint !e777*/
1156  ++nunknown;
1157  else if( SCIPvarIsIntegral(vars[v]) && !SCIPisIntegral(scip, solval) )
1158  ++nfracints;
1159  }
1160 
1161  if( heurdata->ignorecont )
1162  unknownrate = nunknown/((SCIP_Real)SCIPgetNBinVars(scip) + SCIPgetNIntVars(scip) + SCIPgetNImplVars(scip));
1163  else
1164  unknownrate = nunknown/((SCIP_Real)nvars);
1165  SCIPdebugMsg(scip, "%d (rate %.4f) unknown solution values\n", nunknown, unknownrate);
1166 
1167  /* run the heuristic, if not too many unknown variables exist */
1168  if( unknownrate > heurdata->maxunknownrate )
1169  continue;
1170 
1171  /* all variables have a finite/known solution value all integer variables have an integral solution value,
1172  * and there are no continuous variables
1173  * in the sub-SCIP, all variables would be fixed, so create a new solution without solving a sub-SCIP
1174  */
1175  if( nunknown == 0 && nfracints == 0 && SCIPgetNContVars(scip) == 0 && SCIPgetNImplVars(scip) == 0 )
1176  {
1177  SCIP_VAR** origvars;
1178  SCIP_SOL* newsol;
1179  SCIP_Bool stored;
1180  int norigvars;
1181 
1182  origvars = SCIPgetOrigVars(scip);
1183  norigvars = SCIPgetNOrigVars(scip);
1184 
1185  SCIP_CALL( SCIPcreateOrigSol(scip, &newsol, heur) );
1186 
1187  for( v = 0; v < norigvars; v++ )
1188  {
1189  solval = SCIPgetSolVal(scip, sol, origvars[v]);
1190  assert(solval != SCIP_UNKNOWN); /*lint !e777*/
1191 
1192  SCIP_CALL( SCIPsetSolVal(scip, newsol, origvars[v], solval) );
1193  }
1194 
1195  SCIP_CALL( SCIPtrySolFree(scip, &newsol, FALSE, FALSE, TRUE, TRUE, TRUE, &stored) );
1196  if( stored )
1197  *result = SCIP_FOUNDSOL;
1198  }
1199  else
1200  {
1201  /* run the heuristic */
1202  SCIP_CALL( applyCompletesol(scip, heur, heurdata, result, nstallnodes, sol) );
1203  }
1204  }
1205 
1206  return SCIP_OKAY;
1207 }
1208 
1209 
1210 /*
1211  * primal heuristic specific interface methods
1212  */
1213 
1214 /** creates the completesol primal heuristic and includes it in SCIP */
1216  SCIP* scip /**< SCIP data structure */
1217  )
1218 {
1219  SCIP_HEURDATA* heurdata;
1220  SCIP_HEUR* heur;
1221 
1222  /* create completesol primal heuristic data */
1223  SCIP_CALL( SCIPallocBlockMemory(scip, &heurdata) );
1224  assert(heurdata != NULL);
1225 
1226  /* include primal heuristic */
1229  HEUR_MAXDEPTH, HEUR_TIMING, HEUR_USESSUBSCIP, heurExecCompletesol, heurdata) );
1230 
1231  assert(heur != NULL);
1232 
1233  /* set non fundamental callbacks via setter functions */
1234  SCIP_CALL( SCIPsetHeurCopy(scip, heur, heurCopyCompletesol) );
1235  SCIP_CALL( SCIPsetHeurFree(scip, heur, heurFreeCompletesol) );
1236 
1237  /* add completesol primal heuristic parameters */
1238 
1239  SCIP_CALL( SCIPaddLongintParam(scip, "heuristics/" HEUR_NAME "/maxnodes",
1240  "maximum number of nodes to regard in the subproblem",
1241  &heurdata->maxnodes, TRUE, DEFAULT_MAXNODES, 0LL, SCIP_LONGINT_MAX, NULL, NULL) );
1242 
1243  SCIP_CALL( SCIPaddLongintParam(scip, "heuristics/" HEUR_NAME "/minnodes",
1244  "minimum number of nodes required to start the subproblem",
1245  &heurdata->minnodes, TRUE, DEFAULT_MINNODES, 0LL, SCIP_LONGINT_MAX, NULL, NULL) );
1246 
1247  SCIP_CALL( SCIPaddRealParam(scip, "heuristics/" HEUR_NAME "/maxunknownrate",
1248  "maximal rate of unknown solution values",
1249  &heurdata->maxunknownrate, FALSE, DEFAULT_MAXUNKRATE, 0.0, 1.0, NULL, NULL) );
1250 
1251  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/" HEUR_NAME "/addallsols",
1252  "should all subproblem solutions be added to the original SCIP?",
1253  &heurdata->addallsols, TRUE, DEFAULT_ADDALLSOLS, NULL, NULL) );
1254 
1255  SCIP_CALL( SCIPaddLongintParam(scip, "heuristics/" HEUR_NAME "/nodesofs",
1256  "number of nodes added to the contingent of the total nodes",
1257  &heurdata->nodesofs, FALSE, DEFAULT_NODESOFS, 0LL, SCIP_LONGINT_MAX, NULL, NULL) );
1258 
1259  SCIP_CALL( SCIPaddRealParam(scip, "heuristics/" HEUR_NAME "/nodesquot",
1260  "contingent of sub problem nodes in relation to the number of nodes of the original problem",
1261  &heurdata->nodesquot, FALSE, DEFAULT_NODESQUOT, 0.0, 1.0, NULL, NULL) );
1262 
1263  SCIP_CALL( SCIPaddRealParam(scip, "heuristics/" HEUR_NAME "/lplimfac",
1264  "factor by which the limit on the number of LP depends on the node limit",
1265  &heurdata->lplimfac, TRUE, DEFAULT_LPLIMFAC, 1.0, SCIP_REAL_MAX, NULL, NULL) );
1266 
1267  SCIP_CALL( SCIPaddRealParam(scip, "heuristics/" HEUR_NAME "/objweight",
1268  "weight of the original objective function (1: only original objective)",
1269  &heurdata->objweight, TRUE, DEFAULT_OBJWEIGHT, DEFAULT_MINOBJWEIGHT, 1.0, NULL, NULL) );
1270 
1271  SCIP_CALL( SCIPaddRealParam(scip, "heuristics/" HEUR_NAME "/boundwidening",
1272  "bound widening factor applied to continuous variables (0: fix variables to given solution values, 1: relax to global bounds)",
1273  &heurdata->boundwidening, TRUE, DEFAULT_BOUNDWIDENING, 0.0, 1.0, NULL, NULL) );
1274 
1275  SCIP_CALL( SCIPaddRealParam(scip, "heuristics/" HEUR_NAME "/minimprove",
1276  "factor by which the incumbent should be improved at least",
1277  &heurdata->minimprove, TRUE, DEFAULT_MINIMPROVE, 0.0, 1.0, NULL, NULL) );
1278 
1279  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/" HEUR_NAME "/ignorecont",
1280  "should number of continuous variables be ignored?",
1281  &heurdata->ignorecont, FALSE, DEFAULT_IGNORECONT, NULL, NULL) );
1282 
1283  SCIP_CALL( SCIPaddIntParam(scip, "heuristics/" HEUR_NAME "/solutions",
1284  "heuristic stops, if the given number of improving solutions were found (-1: no limit)",
1285  &heurdata->bestsols, FALSE, DEFAULT_BESTSOLS, -1, INT_MAX, NULL, NULL) );
1286 
1287  SCIP_CALL( SCIPaddIntParam(scip, "heuristics/" HEUR_NAME "/maxproprounds",
1288  "maximal number of iterations in propagation (-1: no limit)",
1289  &heurdata->maxproprounds, FALSE, DEFAULT_MAXPROPROUNDS, -1, INT_MAX, NULL, NULL) );
1290 
1291  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/" HEUR_NAME "/beforepresol",
1292  "should the heuristic run before presolving?",
1293  &heurdata->beforepresol, FALSE, DEFAULT_BEFOREPRESOL, NULL, NULL) );
1294 
1295  SCIP_CALL( SCIPaddLongintParam(scip, "heuristics/" HEUR_NAME "/maxlpiter",
1296  "maximal number of LP iterations (-1: no limit)",
1297  &heurdata->maxlpiter, FALSE, DEFAULT_MAXLPITER, -1LL, SCIP_LONGINT_MAX, NULL, NULL) );
1298 
1299  SCIP_CALL( SCIPaddIntParam(scip, "heuristics/" HEUR_NAME "/maxcontvars",
1300  "maximal number of continuous variables after presolving",
1301  &heurdata->maxcontvars, FALSE, DEFAULT_MAXCONTVARS, -1, INT_MAX, NULL, NULL) );
1302 
1303 
1304  return SCIP_OKAY;
1305 }
enum SCIP_Result SCIP_RESULT
Definition: type_result.h:52
int SCIPgetNIntVars(SCIP *scip)
Definition: scip.c:11902
#define EVENTHDLR_DESC
SCIP_Real SCIPgetSolvingTime(SCIP *scip)
Definition: scip.c:46306
#define SCIP_EVENTTYPE_LPSOLVED
Definition: type_event.h:84
SCIP_RETCODE SCIPsetSeparating(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
Definition: scip.c:5158
#define DEFAULT_NODESQUOT
static SCIP_RETCODE createSubproblem(SCIP *scip, SCIP *subscip, SCIP_HEURDATA *heurdata, SCIP_VAR **subvars, SCIP_SOL *partialsol, SCIP_Bool *tightened, SCIP_Bool *success)
SCIP_NODE * SCIPgetCurrentNode(SCIP *scip)
Definition: scip.c:41404
SCIP_STAGE SCIPgetStage(SCIP *scip)
Definition: scip.c:821
SCIP_RETCODE SCIPbacktrackProbing(SCIP *scip, int probingdepth)
Definition: scip.c:35964
SCIP_RETCODE SCIPcreateConsBasicLinear(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, SCIP_Real *vals, SCIP_Real lhs, SCIP_Real rhs)
int SCIPgetProbingDepth(SCIP *scip)
Definition: scip.c:35937
#define DEFAULT_MINOBJWEIGHT
SCIP_Real SCIPgetPrimalbound(SCIP *scip)
Definition: scip.c:43402
#define SCIPallocClearBufferArray(scip, ptr, num)
Definition: scip.h:22622
primal heuristic trying to complete given partial solutions
#define HEUR_MAXDEPTH
SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
Definition: var.c:17276
#define SCIP_MAXSTRLEN
Definition: def.h:259
SCIP_Longint SCIPheurGetNBestSolsFound(SCIP_HEUR *heur)
Definition: heur.c:1344
int SCIPgetNOrigVars(SCIP *scip)
Definition: scip.c:12252
SCIP_Real SCIPvarGetLbLocal(SCIP_VAR *var)
Definition: var.c:17332
#define SCIP_HEURTIMING_BEFORENODE
Definition: type_timing.h:70
SCIP_Bool SCIPisGE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
Definition: scip.c:47015
SCIP_RETCODE SCIPincludeEventhdlrBasic(SCIP *scip, SCIP_EVENTHDLR **eventhdlrptr, const char *name, const char *desc, SCIP_DECL_EVENTEXEC((*eventexec)), SCIP_EVENTHDLRDATA *eventhdlrdata)
Definition: scip.c:8611
SCIP_RETCODE SCIPreleaseVar(SCIP *scip, SCIP_VAR **var)
Definition: scip.c:18766
SCIP_Bool SCIPvarIsBinary(SCIP_VAR *var)
Definition: var.c:16842
#define DEFAULT_MINIMPROVE
SCIP_RETCODE SCIPgetVarsData(SCIP *scip, SCIP_VAR ***vars, int *nvars, int *nbinvars, int *nintvars, int *nimplvars, int *ncontvars)
Definition: scip.c:11686
#define DEFAULT_MAXPROPROUNDS
SCIP_SOL ** SCIPgetSols(SCIP *scip)
Definition: scip.c:39832
#define FALSE
Definition: def.h:64
SCIP_RETCODE SCIPhashmapCreate(SCIP_HASHMAP **hashmap, BMS_BLKMEM *blkmem, int mapsize)
Definition: misc.c:2793
const char * SCIPeventhdlrGetName(SCIP_EVENTHDLR *eventhdlr)
Definition: event.c:278
SCIP_RETCODE SCIPaddLongintParam(SCIP *scip, const char *name, const char *desc, SCIP_Longint *valueptr, SCIP_Bool isadvanced, SCIP_Longint defaultvalue, SCIP_Longint minvalue, SCIP_Longint maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
Definition: scip.c:4293
SCIP_RETCODE SCIPcopyLimits(SCIP *sourcescip, SCIP *targetscip)
Definition: scip.c:4192
int SCIPgetNPartialSols(SCIP *scip)
Definition: scip.c:40953
SCIP_RETCODE SCIPcopyConsCompression(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, const char *suffix, SCIP_VAR **fixedvars, SCIP_Real *fixedvals, int nfixedvars, SCIP_Bool global, SCIP_Bool enablepricing, SCIP_Bool passmessagehdlr, SCIP_Bool *valid)
Definition: scip.c:3884
static SCIP_DECL_HEURCOPY(heurCopyCompletesol)
SCIP_Real SCIPinfinity(SCIP *scip)
Definition: scip.c:47028
#define DEFAULT_ADDALLSOLS
int SCIPsnprintf(char *t, int len, const char *s,...)
Definition: misc.c:10011
#define DEFAULT_BOUNDWIDENING
#define TRUE
Definition: def.h:63
#define SCIPdebug(x)
Definition: pub_message.h:74
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
SCIP_RETCODE SCIPsetPresolving(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
Definition: scip.c:5132
SCIP_BRANCHRULE * SCIPfindBranchrule(SCIP *scip, const char *name)
Definition: scip.c:9269
int SCIPvarGetProbindex(SCIP_VAR *var)
Definition: var.c:16969
SCIP_RETCODE SCIPcreateVarBasic(SCIP *scip, SCIP_VAR **var, const char *name, SCIP_Real lb, SCIP_Real ub, SCIP_Real obj, SCIP_VARTYPE vartype)
Definition: scip.c:17699
SCIP_VAR ** SCIPgetOrigVars(SCIP *scip)
Definition: scip.c:12225
struct SCIP_HeurData SCIP_HEURDATA
Definition: type_heur.h:51
#define SCIPfreeBlockMemory(scip, ptr)
Definition: scip.h:22602
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.c:8084
SCIP_RETCODE SCIPchgVarLbProbing(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
Definition: scip.c:36040
#define DEFAULT_BESTSOLS
void * SCIPhashmapGetImage(SCIP_HASHMAP *hashmap, void *origin)
Definition: misc.c:2931
SCIP_Real SCIPfeasFrac(SCIP *scip, SCIP_Real val)
Definition: scip.c:47459
SCIP_Bool SCIPisEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
Definition: scip.c:46963
#define SCIP_LONGINT_MAX
Definition: def.h:135
#define SCIPfreeBufferArray(scip, ptr)
Definition: scip.h:22632
SCIP_RETCODE SCIPcreate(SCIP **scip)
Definition: scip.c:748
void SCIPheurSetData(SCIP_HEUR *heur, SCIP_HEURDATA *heurdata)
Definition: heur.c:1119
#define SCIPallocBlockMemory(scip, ptr)
Definition: scip.h:22585
#define HEUR_DISPCHAR
SCIP_NODE * SCIPgetRootNode(SCIP *scip)
Definition: scip.c:41423
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
Definition: scip.c:1267
SCIP_SOL ** SCIPgetPartialSols(SCIP *scip)
Definition: scip.c:40930
#define SCIPdebugMsg
Definition: scip.h:455
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.c:4265
SCIP_RETCODE SCIPprintStatistics(SCIP *scip, FILE *file)
Definition: scip.c:45651
SCIP_RETCODE SCIPaddCoefLinear(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Real val)
int SCIPgetNContVars(SCIP *scip)
Definition: scip.c:11992
SCIP_RETCODE SCIPcreateOrigSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
Definition: scip.c:38115
real eps
#define DEFAULT_MINNODES
#define EVENTHDLR_NAME
enum SCIP_BranchDir SCIP_BRANCHDIR
Definition: type_history.h:39
SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
Definition: var.c:17286
static SCIP_DECL_EVENTEXEC(eventExecCompletesol)
SCIP_RETCODE SCIPsolve(SCIP *scip)
Definition: scip.c:16115
const char * SCIPheurGetName(SCIP_HEUR *heur)
Definition: heur.c:1198
#define SCIPerrorMessage
Definition: pub_message.h:45
SCIP_Bool SCIPisParamFixed(SCIP *scip, const char *name)
Definition: scip.c:4401
SCIP_RETCODE SCIPaddCons(SCIP *scip, SCIP_CONS *cons)
Definition: scip.c:12591
SCIP_RETCODE SCIPsetHeurFree(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURFREE((*heurfree)))
Definition: scip.c:8145
SCIP_Bool SCIPisLT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
Definition: scip.c:46976
SCIP_RETCODE SCIPpropagateProbing(SCIP *scip, int maxproprounds, SCIP_Bool *cutoff, SCIP_Longint *ndomredsfound)
Definition: scip.c:36314
SCIP_RETCODE SCIPfixVarProbing(SCIP *scip, SCIP_VAR *var, SCIP_Real fixedval)
Definition: scip.c:36157
#define HEUR_USESSUBSCIP
SCIP_RETCODE SCIPsetBoolParam(SCIP *scip, const char *name, SCIP_Bool value)
Definition: scip.c:4630
SCIP_RETCODE SCIPpresolve(SCIP *scip)
Definition: scip.c:15954
BMS_BLKMEM * SCIPblkmem(SCIP *scip)
Definition: scip.c:46731
#define DEFAULT_MAXCONTVARS
SCIP_RETCODE SCIPendProbing(SCIP *scip)
Definition: scip.c:35999
struct SCIP_EventData SCIP_EVENTDATA
Definition: type_event.h:155
const char * SCIPvarGetName(SCIP_VAR *var)
Definition: var.c:16662
void SCIPhashmapFree(SCIP_HASHMAP **hashmap)
Definition: misc.c:2826
SCIP_Bool SCIPisNLPEnabled(SCIP *scip)
Definition: scip.c:31195
static SCIP_RETCODE tightenVariables(SCIP *scip, SCIP_HEURDATA *heurdata, SCIP_VAR **vars, int nvars, SCIP_SOL *sol, SCIP_Bool *tightened, SCIP_Bool *success)
static SCIP_RETCODE setupAndSolve(SCIP *scip, SCIP *subscip, SCIP_HEUR *heur, SCIP_HEURDATA *heurdata, SCIP_RESULT *result, SCIP_Longint nstallnodes, SCIP_SOL *partialsol, SCIP_Bool *tightened)
#define HEUR_TIMING
#define REALABS(x)
Definition: def.h:173
static SCIP_DECL_HEURFREE(heurFreeCompletesol)
#define SCIP_CALL(x)
Definition: def.h:350
SCIP_Real SCIPgetLowerbound(SCIP *scip)
Definition: scip.c:43277
static SCIP_RETCODE applyCompletesol(SCIP *scip, SCIP_HEUR *heur, SCIP_HEURDATA *heurdata, SCIP_RESULT *result, SCIP_Longint nstallnodes, SCIP_SOL *partialsol)
#define SCIPstatisticPrintf
Definition: pub_message.h:107
#define SCIP_HEURTIMING_BEFOREPRESOL
Definition: type_timing.h:86
SCIP_Longint SCIPheurGetNCalls(SCIP_HEUR *heur)
Definition: heur.c:1324
#define DEFAULT_MAXUNKRATE
#define DEFAULT_IGNORECONT
SCIP_RETCODE SCIPchgVarObj(SCIP *scip, SCIP_VAR *var, SCIP_Real newobj)
Definition: scip.c:21853
#define DEFAULT_MAXLPITER
#define HEUR_PRIORITY
#define SCIPallocBufferArray(scip, ptr, num)
Definition: scip.h:22620
#define SCIP_UNKNOWN
Definition: def.h:170
SCIP_RETCODE SCIPsetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var, SCIP_Real val)
Definition: scip.c:38771
public data structures and miscellaneous methods
#define SCIP_Bool
Definition: def.h:61
SCIP_RETCODE SCIPcatchEvent(SCIP *scip, SCIP_EVENTTYPE eventtype, SCIP_EVENTHDLR *eventhdlr, SCIP_EVENTDATA *eventdata, int *filterpos)
Definition: scip.c:41158
int SCIPgetNImplVars(SCIP *scip)
Definition: scip.c:11947
SCIP_EVENTTYPE SCIPeventGetType(SCIP_EVENT *event)
Definition: event.c:959
SCIP_Longint SCIPsolGetNodenum(SCIP_SOL *sol)
Definition: sol.c:2528
#define DEFAULT_OBJWEIGHT
SCIP_RETCODE SCIPtrySolFree(SCIP *scip, SCIP_SOL **sol, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *stored)
Definition: scip.c:40794
SCIP_RETCODE SCIPsetIntParam(SCIP *scip, const char *name, int value)
Definition: scip.c:4688
SCIP_RETCODE SCIPdropEvent(SCIP *scip, SCIP_EVENTTYPE eventtype, SCIP_EVENTHDLR *eventhdlr, SCIP_EVENTDATA *eventdata, int filterpos)
Definition: scip.c:41192
SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
Definition: var.c:17124
#define DEFAULT_NODESOFS
SCIP_RETCODE SCIPincludeHeurCompletesol(SCIP *scip)
int SCIPgetNSols(SCIP *scip)
Definition: scip.c:39783
int SCIPgetNRuns(SCIP *scip)
Definition: scip.c:42050
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
Definition: scip.c:47039
static SCIP_RETCODE createNewSol(SCIP *scip, SCIP *subscip, SCIP_VAR **subvars, SCIP_HEUR *heur, SCIP_SOL *subsol, SCIP_Bool *success)
#define SCIP_MAXTREEDEPTH
Definition: def.h:286
#define DEFAULT_BEFOREPRESOL
int SCIPgetNBinVars(SCIP *scip)
Definition: scip.c:11857
static SCIP_RETCODE chgProbingBound(SCIP *scip, SCIP_VAR *var, SCIP_Real newval, SCIP_BRANCHDIR branchdir, SCIP_Bool *success)
int SCIPgetNVars(SCIP *scip)
Definition: scip.c:11812
#define SCIP_REAL_MAX
Definition: def.h:150
#define HEUR_FREQ
static SCIP_DECL_HEUREXEC(heurExecCompletesol)
SCIP_SOL * SCIPgetBestSol(SCIP *scip)
Definition: scip.c:39882
SCIP_Bool SCIPisGT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
Definition: scip.c:47002
SCIP_Bool SCIPisIntegral(SCIP *scip, SCIP_Real val)
Definition: scip.c:47112
SCIP_RETCODE SCIPaddVar(SCIP *scip, SCIP_VAR *var)
Definition: scip.c:11492
int SCIPgetNConss(SCIP *scip)
Definition: scip.c:12862
#define DEFAULT_LPLIMFAC
SCIP_RETCODE SCIPreleaseCons(SCIP *scip, SCIP_CONS **cons)
Definition: scip.c:27761
#define HEUR_DESC
SCIP_SOLORIGIN SCIPsolGetOrigin(SCIP_SOL *sol)
Definition: sol.c:2455
SCIP_NODESEL * SCIPfindNodesel(SCIP *scip, const char *name)
Definition: scip.c:8957
SCIP_VAR ** SCIPgetVars(SCIP *scip)
Definition: scip.c:11767
#define SCIP_Real
Definition: def.h:149
SCIP_Bool SCIPisStopped(SCIP *scip)
Definition: scip.c:1145
#define SCIP_Longint
Definition: def.h:134
SCIP_RETCODE SCIPcheckCopyLimits(SCIP *sourcescip, SCIP_Bool *success)
Definition: scip.c:4156
SCIP_OBJSENSE SCIPgetObjsense(SCIP *scip)
Definition: scip.c:11049
SCIP_RETCODE SCIPtransformProb(SCIP *scip)
Definition: scip.c:13935
SCIP_Bool SCIPisLE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
Definition: scip.c:46989
#define HEUR_NAME
SCIP_RETCODE SCIPsetHeurCopy(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURCOPY((*heurcopy)))
Definition: scip.c:8129
SCIP_Real SCIPvarGetUbLocal(SCIP_VAR *var)
Definition: var.c:17342
SCIP_RETCODE SCIPnewProbingNode(SCIP *scip)
Definition: scip.c:35904
SCIP_Real SCIPsumepsilon(SCIP *scip)
Definition: scip.c:46429
SCIP_RETCODE SCIPinterruptSolve(SCIP *scip)
Definition: scip.c:17324
SCIP_Real SCIPgetUpperbound(SCIP *scip)
Definition: scip.c:43426
SCIP_RETCODE SCIPstartProbing(SCIP *scip)
Definition: scip.c:35858
SCIP_Bool SCIPsolIsPartial(SCIP_SOL *sol)
Definition: sol.c:2475
common defines and data types used in all packages of SCIP
SCIP_Real SCIPceil(SCIP *scip, SCIP_Real val)
Definition: scip.c:47161
SCIP_HEURDATA * SCIPheurGetData(SCIP_HEUR *heur)
Definition: heur.c:1109
SCIP_Longint SCIPgetNNodes(SCIP *scip)
Definition: scip.c:42133
SCIP_Longint SCIPgetNLPs(SCIP *scip)
Definition: scip.c:42314
#define SCIPABORT()
Definition: def.h:322
SCIP_Bool SCIPvarIsIntegral(SCIP_VAR *var)
Definition: var.c:16853
SCIP_RETCODE SCIPchgVarUbProbing(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
Definition: scip.c:36084
SCIP_Real SCIPgetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var)
Definition: scip.c:38911
default SCIP plugins
#define DEFAULT_MAXNODES
SCIP_RETCODE SCIPaddRealParam(SCIP *scip, const char *name, const char *desc, SCIP_Real *valueptr, SCIP_Bool isadvanced, SCIP_Real defaultvalue, SCIP_Real minvalue, SCIP_Real maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
Definition: scip.c:4321
SCIP_RETCODE SCIPsetSubscipsOff(SCIP *scip, SCIP_Bool quiet)
Definition: scip.c:5083
SCIP_Real SCIPfloor(SCIP *scip, SCIP_Real val)
Definition: scip.c:47149
#define HEUR_FREQOFS
SCIP_RETCODE SCIPsetLongintParam(SCIP *scip, const char *name, SCIP_Longint value)
Definition: scip.c:4746
SCIP_RETCODE SCIPaddBoolParam(SCIP *scip, const char *name, const char *desc, SCIP_Bool *valueptr, SCIP_Bool isadvanced, SCIP_Bool defaultvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
Definition: scip.c:4239
SCIP_Bool SCIPvarIsActive(SCIP_VAR *var)
Definition: var.c:16949
SCIP_RETCODE SCIPfree(SCIP **scip)
Definition: scip.c:780
SCIP_RETCODE SCIPcreateSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
Definition: scip.c:37878