Scippy

SCIP

Solving Constraint Integer Programs

sepa_rapidlearning.c
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the program and library */
4 /* SCIP --- Solving Constraint Integer Programs */
5 /* */
6 /* Copyright (C) 2002-2020 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SCIP is distributed under the terms of the ZIB Academic License. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SCIP; see the file COPYING. If not visit scipopt.org. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file sepa_rapidlearning.c
17  * @ingroup DEFPLUGINS_SEPA
18  * @brief rapidlearning separator
19  * @author Timo Berthold
20  * @author Jakob Witzig
21  */
22 
23 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
24 
25 #include <assert.h>
26 #ifndef NDEBUG
27 #include <string.h>
28 #endif
29 
31 #include "scip/scipdefplugins.h"
32 #include "scip/heuristics.h"
33 #include "scip/pub_var.h"
34 
35 #define SEPA_NAME "rapidlearning"
36 #define SEPA_DESC "rapid learning heuristic and separator"
37 #define SEPA_PRIORITY -1200000
38 #define SEPA_FREQ 5
39 #define SEPA_MAXBOUNDDIST 1.0
40 #define SEPA_USESSUBSCIP TRUE /**< does the separator use a secondary SCIP instance? */
41 #define SEPA_DELAY FALSE /**< should separation method be delayed, if other separators found cuts? */
42 
43 #define DEFAULT_APPLYCONFLICTS TRUE /**< should the found conflicts be applied in the original SCIP? */
44 #define DEFAULT_APPLYBDCHGS TRUE /**< should the found global bound deductions be applied in the original SCIP?
45  * apply only if conflicts and incumbent solution will be copied too
46  */
47 #define DEFAULT_APPLYINFERVALS TRUE /**< should the inference values be used as initialization in the original SCIP? */
48 #define DEFAULT_REDUCEDINFER FALSE /**< should the inference values only be used when rapid learning found other reductions? */
49 #define DEFAULT_APPLYPRIMALSOL TRUE /**< should the incumbent solution be copied to the original SCIP? */
50 #define DEFAULT_APPLYSOLVED TRUE /**< should a solved status be copied to the original SCIP? */
51 
52 #define DEFAULT_CHECKEXEC TRUE /**< check whether rapid learning should be executed */
53 #define DEFAULT_CHECKDEGANERACY TRUE /**< should local LP degeneracy be checked? */
54 #define DEFAULT_CHECKDUALBOUND FALSE /**< should the progress on the dual bound be checked? */
55 #define DEFAULT_CHECKLEAVES FALSE /**< should the ratio of leaves proven to be infeasible and exceeding the
56  * cutoff bound be checked? */
57 #define DEFAULT_CHECKOBJ FALSE /**< should the local objection function be checked? */
58 #define DEFAULT_CHECKNSOLS TRUE /**< should the number of solutions found so far be checked? */
59 #define DEFAULT_MINDEGENERACY 0.7 /**< minimal degeneracy threshold to allow local rapid learning */
60 #define DEFAULT_MININFLPRATIO 10.0 /**< minimal threshold of inf/obj leaves to allow local rapid learning */
61 #define DEFAULT_MINVARCONSRATIO 2.0 /**< minimal ratio of unfixed variables in relation to basis size to
62  * allow local rapid learning */
63 #define DEFAULT_NWAITINGNODES 100L /**< number of nodes that should be processed before rapid learning is
64  * executed locally based on the progress of the dualbound */
65 
66 #define DEFAULT_MAXNVARS 10000 /**< maximum problem size (variables) for which rapid learning will be called */
67 #define DEFAULT_MAXNCONSS 10000 /**< maximum problem size (constraints) for which rapid learning will be called */
68 #define DEFAULT_MAXCALLS 100 /**< maximum number of overall calls */
69 
70 #define DEFAULT_MINNODES 500 /**< minimum number of nodes considered in rapid learning run */
71 #define DEFAULT_MAXNODES 5000 /**< maximum number of nodes considered in rapid learning run */
72 
73 #define DEFAULT_CONTVARS FALSE /**< should rapid learning be applied when there are continuous variables? */
74 #define DEFAULT_CONTVARSQUOT 0.3 /**< maximal portion of continuous variables to apply rapid learning */
75 #define DEFAULT_LPITERQUOT 0.2 /**< maximal fraction of LP iterations compared to node LP iterations */
76 #define DEFAULT_COPYCUTS TRUE /**< should all active cuts from the cutpool of the
77  * original scip be copied to constraints of the subscip */
78 
79 
80 /*
81  * Data structures
82  */
83 
84 /** separator data */
85 struct SCIP_SepaData
86 {
87  SCIP_Real lpiterquot; /**< maximal fraction of LP iterations compared to node LP iterations */
88  SCIP_Real mindegeneracy; /**< minimal degeneracy threshold to allow local rapid learning */
89  SCIP_Real mininflpratio; /**< minimal threshold of inf/obj leaves to allow local rapid learning */
90  SCIP_Real minvarconsratio; /**< minimal ratio of unfixed variables in relation to basis size to
91  * allow local rapid learning */
92  int maxnvars; /**< maximum problem size (variables) for which rapid learning will be called */
93  int maxnconss; /**< maximum problem size (constraints) for which rapid learning will be called */
94  int maxcalls; /**< maximum number of overall calls */
95  int minnodes; /**< minimum number of nodes considered in rapid learning run */
96  int maxnodes; /**< maximum number of nodes considered in rapid learning run */
97  SCIP_Longint nwaitingnodes; /**< number of nodes that should be processed before rapid learning is executed locally
98  * based on the progress of the dualbound */
99  SCIP_Bool applybdchgs; /**< should the found global bound deductions be applied in the original SCIP? */
100  SCIP_Bool applyconflicts; /**< should the found conflicts be applied in the original SCIP? */
101  SCIP_Bool applyinfervals; /**< should the inference values be used as initialization in the original SCIP? */
102  SCIP_Bool applyprimalsol; /**< should the incumbent solution be copied to the original SCIP? */
103  SCIP_Bool applysolved; /**< should a solved status ba copied to the original SCIP? */
104  SCIP_Bool checkdegeneracy; /**< should local LP degeneracy be checked? */
105  SCIP_Bool checkdualbound; /**< should the progress on the dual bound be checked? */
106  SCIP_Bool checkleaves; /**< should the ratio of leaves proven to be infeasible and exceeding the
107  * cutoff bound be checked? */
108  SCIP_Bool checkexec; /**< check whether rapid learning should be executed */
109  SCIP_Bool checkobj; /**< should the (local) objective function be checked? */
110  SCIP_Bool checknsols; /**< should number if solutions found so far be checked? */
111  SCIP_Bool contvars; /**< should rapid learning be applied when there are continuous variables? */
112  SCIP_Real contvarsquot; /**< maximal portion of continuous variables to apply rapid learning */
113  SCIP_Bool copycuts; /**< should all active cuts from cutpool be copied to constraints in
114  * subproblem? */
115  SCIP_Bool reducedinfer; /**< should the inference values only be used when rapid learning found other reductions? */
116 };
117 
118 /*
119  * Callback methods of separator
120  */
121 
122 /** copy method for separator plugins (called when SCIP copies plugins) */
123 static
124 SCIP_DECL_SEPACOPY(sepaCopyRapidlearning)
125 { /*lint --e{715}*/
126  assert(scip != NULL);
127  assert(sepa != NULL);
128  assert(strcmp(SCIPsepaGetName(sepa), SEPA_NAME) == 0);
129 
130  /* call inclusion method of constraint handler */
132 
133  return SCIP_OKAY;
134 }
135 
136 /** destructor of separator to free user data (called when SCIP is exiting) */
137 static
138 SCIP_DECL_SEPAFREE(sepaFreeRapidlearning)
139 { /*lint --e{715}*/
140  SCIP_SEPADATA* sepadata;
141 
142  assert(sepa != NULL);
143  assert(strcmp(SCIPsepaGetName(sepa), SEPA_NAME) == 0);
144  assert(scip != NULL);
145 
146  /* free separator data */
147  sepadata = SCIPsepaGetData(sepa);
148  assert(sepadata != NULL);
149  SCIPfreeBlockMemory(scip, &sepadata);
150  SCIPsepaSetData(sepa, NULL);
151 
152  return SCIP_OKAY;
153 }
154 
155 
156 /** setup and solve sub-SCIP */
157 static
159  SCIP* scip, /**< SCIP data structure */
160  SCIP* subscip, /**< subSCIP data structure */
161  SCIP_SEPADATA* sepadata, /**< separator data */
162  int randseed, /**< global seed shift used in the sub-SCIP */
163  SCIP_Bool global, /**< should rapid learning run on the global problem? */
164  SCIP_RESULT* result /**< result pointer */
165  )
166 {
167  SCIP_VAR** vars; /* original problem's variables */
168  SCIP_VAR** subvars; /* subproblem's variables */
169  SCIP_HASHMAP* varmapfw; /* mapping of SCIP variables to sub-SCIP variables */
170  SCIP_HASHMAP* varmapbw = NULL; /* mapping of sub-SCIP variables to SCIP variables */
171 
172  SCIP_CONSHDLR** conshdlrs = NULL; /* array of constraint handler's that might that might obtain conflicts */
173  int* oldnconss = NULL; /* number of constraints without rapid learning conflicts */
174 
175  SCIP_Longint nodelimit; /* node limit for the subproblem */
176 
177  int nconshdlrs; /* size of conshdlr and oldnconss array */
178  int nvars; /* number of variables */
179  int nbinvars;
180  int nintvars;
181  int nimplvars;
182  int implstart;
183  int implend;
184  int restartnum; /* maximal number of conflicts that should be created */
185  int i; /* counter */
186 
187  SCIP_Bool success; /* was problem creation / copying constraint successful? */
188 
189  SCIP_Bool cutoff; /* detected infeasibility */
190  int nconflicts; /* statistic: number of conflicts applied */
191  int nbdchgs; /* statistic: number of bound changes applied */
192 
193  SCIP_Bool soladded = FALSE; /* statistic: was a new incumbent found? */
194  SCIP_Bool dualboundchg; /* statistic: was a new dual bound found? */
195  SCIP_Bool disabledualreductions; /* TRUE, if dual reductions in sub-SCIP are not valid for original SCIP,
196  * e.g., because a constraint could not be copied or a primal solution
197  * could not be copied back */
198  int initseed;
199  int seedshift;
200  SCIP_Bool valid;
201 
202 #ifdef SCIP_DEBUG
203  int n1startinfers = 0; /* statistic: number of one side infer values */
204  int n2startinfers = 0; /* statistic: number of both side infer values */
205 #endif
206 
207  SCIP_CALL( SCIPgetVarsData(scip, &vars, &nvars, &nbinvars, &nintvars, &nimplvars, NULL) );
208 
209  /* initializing the subproblem */
210  SCIP_CALL( SCIPallocBufferArray(scip, &subvars, nvars) );
211  SCIP_CALL( SCIPhashmapCreate(&varmapfw, SCIPblkmem(subscip), nvars) );
212  valid = FALSE;
213 
214  /* copy the subproblem */
215  SCIP_CALL( SCIPcopyConsCompression(scip, subscip, varmapfw, NULL, "rapid", NULL, NULL, 0, global, FALSE, FALSE, TRUE, &valid) );
216 
217  if( sepadata->copycuts )
218  {
219  /* copies all active cuts from cutpool of sourcescip to linear constraints in targetscip */
220  SCIP_CALL( SCIPcopyCuts(scip, subscip, varmapfw, NULL, global, NULL) );
221  }
222 
223  /* fill subvars array in the order of the variables of the main SCIP */
224  for( i = 0; i < nvars; i++ )
225  {
226  subvars[i] = (SCIP_VAR*) SCIPhashmapGetImage(varmapfw, vars[i]);
227  }
228  SCIPhashmapFree(&varmapfw);
229 
230  /* change implicit integer variables to integer type */
231  implstart = nbinvars + nintvars;
232  implend = nbinvars + nintvars + nimplvars;
233  for( i = implstart; i < implend; i++ )
234  {
235  SCIP_Bool infeasible;
236 
237  if( subvars[i] == NULL )
238  continue;
239 
240  assert(SCIPvarGetType(subvars[i]) == SCIP_VARTYPE_IMPLINT);
241  SCIP_CALL( SCIPchgVarType(subscip, subvars[i], SCIP_VARTYPE_INTEGER, &infeasible) );
242  assert(!infeasible);
243  }
244 
245  /* This avoids dual presolving.
246  *
247  * If the copy is not valid, it should be a relaxation of the problem (constraints might have failed to be copied,
248  * but no variables should be missing because we stop earlier anyway if pricers are present).
249  * By disabling dual presolving, conflicts and bound changes found in a relaxation are still valid for the original problem.
250  */
251  if( ! valid )
252  {
253  SCIP_CALL( SCIPsetBoolParam(subscip, "misc/allowweakdualreds", FALSE) );
254  SCIP_CALL( SCIPsetBoolParam(subscip, "misc/allowstrongdualreds", FALSE) );
255  }
256 
257  SCIPdebugMsg(scip, "Copying SCIP was%s valid.\n", valid ? "" : " not");
258 
259  /* mimic an FD solver: DFS, no LP solving, 1-FUIP instead of all-FUIP */
260  if( SCIPisParamFixed(subscip, "lp/solvefreq") )
261  {
262  SCIPwarningMessage(scip, "unfixing parameter lp/solvefreq in subscip of rapidlearning\n");
263  SCIP_CALL( SCIPunfixParam(subscip, "lp/solvefreq") );
264  }
265  SCIP_CALL( SCIPsetIntParam(subscip, "lp/solvefreq", -1) );
266  if( !SCIPisParamFixed(subscip, "conflict/fuiplevels") )
267  {
268  SCIP_CALL( SCIPsetIntParam(subscip, "conflict/fuiplevels", 1) );
269  }
270  if( SCIPisParamFixed(subscip, "nodeselection/dfs/stdpriority") )
271  {
272  SCIPwarningMessage(scip, "unfixing parameter nodeselection/dfs/stdpriority in subscip of rapidlearning\n");
273  SCIP_CALL( SCIPunfixParam(subscip, "nodeselection/dfs/stdpriority") );
274  }
275  SCIP_CALL( SCIPsetIntParam(subscip, "nodeselection/dfs/stdpriority", INT_MAX/4) );
276 
277  if( !SCIPisParamFixed(subscip, "propagating/pseudoobj/freq") )
278  {
279  SCIP_CALL( SCIPsetIntParam(subscip, "propagating/pseudoobj/freq", -1) );
280  }
281  if( !SCIPisParamFixed(subscip, "constraints/disableenfops") )
282  {
283  SCIP_CALL( SCIPsetBoolParam(subscip, "constraints/disableenfops", TRUE) );
284  }
285 
286  /* use inference branching */
287  if( !SCIPisParamFixed(subscip, "branching/inference/useweightedsum") )
288  {
289  SCIP_CALL( SCIPsetBoolParam(subscip, "branching/inference/useweightedsum", FALSE) );
290  }
291 
292  /* only create short conflicts */
293  if( !SCIPisParamFixed(subscip, "conflict/maxvarsfac") )
294  {
295  SCIP_CALL( SCIPsetRealParam(subscip, "conflict/maxvarsfac", 0.05) );
296  }
297 
298  /* set node limit for the subproblem based on the number of LP iterations per node,
299  * which are a determistic measure for the node processing time.
300  *
301  * Note: We scale by number of LPs + 1 because the counter is increased after solving the LP.
302  */
303  nodelimit = SCIPgetNLPIterations(scip) / (SCIPgetNLPs(scip) + 1);
304  nodelimit = MAX(sepadata->minnodes, nodelimit);
305  nodelimit = MIN(sepadata->maxnodes, nodelimit);
306 
307  /* change global random seed */
308  assert(randseed >= 0);
309  SCIP_CALL( SCIPgetIntParam(scip, "randomization/randomseedshift", &seedshift) );
310 
311  initseed = ((randseed + seedshift) % INT_MAX);
312  SCIP_CALL( SCIPsetIntParam(subscip, "randomization/randomseedshift", initseed) );
313 
314  restartnum = 1000;
315 
316  #ifdef SCIP_DEBUG
317  /* for debugging, enable full output */
318  SCIP_CALL( SCIPsetIntParam(subscip, "display/verblevel", 5) );
319  SCIP_CALL( SCIPsetIntParam(subscip, "display/freq", -1) );
320  #else
321  /* disable statistic timing inside sub SCIP and output to console */
322  SCIP_CALL( SCIPsetIntParam(subscip, "display/verblevel", 0) );
323  SCIP_CALL( SCIPsetBoolParam(subscip, "timing/statistictiming", FALSE) );
324  #endif
325 
326  /* set limits for the subproblem */
327  SCIP_CALL( SCIPcopyLimits(scip, subscip) );
328  SCIP_CALL( SCIPsetLongintParam(subscip, "limits/nodes", nodelimit/5) );
329  SCIP_CALL( SCIPsetIntParam(subscip, "limits/restarts", 0) );
330  SCIP_CALL( SCIPsetIntParam(subscip, "conflict/restartnum", restartnum) );
331 
332  /* forbid recursive call of heuristics and separators solving subMIPs */
333  SCIP_CALL( SCIPsetSubscipsOff(subscip, TRUE) );
334 
335  /* disable cutting plane separation */
337 
338  /* disable expensive presolving */
340 
341  /* do not abort subproblem on CTRL-C */
342  SCIP_CALL( SCIPsetBoolParam(subscip, "misc/catchctrlc", FALSE) );
343 
344  /* add an objective cutoff */
345  SCIP_CALL( SCIPsetObjlimit(subscip, SCIPgetUpperbound(scip)) );
346 
347  /* create the variable mapping hash map */
348  SCIP_CALL( SCIPhashmapCreate(&varmapbw, SCIPblkmem(scip), nvars) );
349 
350  /* store reversing mapping of variables */
351  SCIP_CALL( SCIPtransformProb(subscip) );
352  for( i = 0; i < nvars; ++i)
353  {
354  if( subvars[i] != NULL )
355  {
356  SCIP_CALL( SCIPhashmapInsert(varmapbw, SCIPvarGetTransVar(subvars[i]), vars[i]) );
357  }
358  }
359 
360  /* allocate memory for constraints storage. Each constraint that will be created from now on will be a conflict.
361  * Therefore, we need to remember oldnconss to get the conflicts from the FD search.
362  */
363  nconshdlrs = 4;
364  SCIP_CALL( SCIPallocBufferArray(scip, &conshdlrs, nconshdlrs) );
365  SCIP_CALL( SCIPallocBufferArray(scip, &oldnconss, nconshdlrs) );
366 
367  /* store number of constraints before rapid learning search */
368  conshdlrs[0] = SCIPfindConshdlr(subscip, "setppc");
369  conshdlrs[1] = SCIPfindConshdlr(subscip, "logicor");
370  conshdlrs[2] = SCIPfindConshdlr(subscip, "linear");
371  conshdlrs[3] = SCIPfindConshdlr(subscip, "bounddisjunction");
372 
373  /* redundant constraints might be eliminated in presolving */
374  SCIP_CALL( SCIPpresolve(subscip) );
375 
376  for( i = 0; i < nconshdlrs; ++i)
377  {
378  if( conshdlrs[i] != NULL )
379  oldnconss[i] = SCIPconshdlrGetNConss(conshdlrs[i]);
380  }
381 
382  /* solve the subproblem, abort after errors in debug mode */
383  SCIP_CALL_ABORT( SCIPsolve(subscip) );
384 
385  /* if problem was already solved do not increase limits to run again */
386  if( SCIPgetStage(subscip) == SCIP_STAGE_SOLVED )
387  {
388  SCIPdebugMsg(scip, "Subscip was completely solved, status %d.\n", SCIPgetStatus(subscip));
389  }
390  /* abort solving, if limit of applied conflicts is reached */
391  else if( SCIPgetNConflictConssApplied(subscip) >= restartnum )
392  {
393  SCIPdebugMsg(scip, "finish after %" SCIP_LONGINT_FORMAT " successful conflict calls.\n", SCIPgetNConflictConssApplied(subscip));
394  }
395  /* if the first 20% of the solution process were successful, proceed */
396  else if( (sepadata->applyprimalsol && SCIPgetNSols(subscip) > 0 && SCIPisFeasLT(scip, SCIPgetUpperbound(subscip), SCIPgetUpperbound(scip) ) )
397  || (sepadata->applybdchgs && SCIPgetNRootboundChgs(subscip) > 0 )
398  || (sepadata->applyconflicts && SCIPgetNConflictConssApplied(subscip) > 0) )
399  {
400  SCIPdebugMsg(scip, "proceed solving after the first 20%% of the solution process, since:\n");
401 
402  if( SCIPgetNSols(subscip) > 0 && SCIPisFeasLE(scip, SCIPgetUpperbound(subscip), SCIPgetUpperbound(scip) ) )
403  {
404  SCIPdebugMsg(scip, " - there was a better solution (%f < %f)\n",SCIPgetUpperbound(subscip), SCIPgetUpperbound(scip));
405  }
406  if( SCIPgetNRootboundChgs(subscip) > 0 )
407  {
408  SCIPdebugMsg(scip, " - there were %d changed variables bounds\n", SCIPgetNRootboundChgs(subscip) );
409  }
410  if( SCIPgetNConflictConssFound(subscip) > 0 )
411  {
412  SCIPdebugMsg(scip, " - there were %" SCIP_LONGINT_FORMAT " conflict constraints created\n", SCIPgetNConflictConssApplied(subscip));
413  }
414 
415  /* set node limit to 100% */
416  SCIP_CALL( SCIPsetLongintParam(subscip, "limits/nodes", nodelimit) );
417 
418  /* solve the subproblem, abort after errors in debug mode */
419  SCIP_CALL_ABORT( SCIPsolve(subscip) );
420  }
421  else
422  {
423  SCIPdebugMsg(scip, "do not proceed solving after the first 20%% of the solution process.\n");
424  }
425 
426  #ifdef SCIP_DEBUG
427  SCIP_CALL( SCIPprintStatistics(subscip, NULL) );
428  #endif
429 
430  disabledualreductions = FALSE;
431 
432  /* check, whether a solution was found */
433  if( sepadata->applyprimalsol && SCIPgetNSols(subscip) > 0 )
434  {
435  SCIP_SOL** subsols;
436  int nsubsols;
437 
438  /* check, whether a solution was found;
439  * due to numerics, it might happen that not all solutions are feasible -> try all solutions until was declared to be feasible
440  */
441  nsubsols = SCIPgetNSols(subscip);
442  subsols = SCIPgetSols(subscip);
443  soladded = FALSE;
444 
445  /* try adding solution from subSCIP to SCIP, until finding one that is accepted */
446  for( i = 0; i < nsubsols && !soladded; ++i )
447  {
448  SCIP_SOL* newsol;
449 
450  SCIP_CALL( SCIPtranslateSubSol(scip, subscip, subsols[i], NULL, subvars, &newsol) );
451  SCIP_CALL( SCIPtrySolFree(scip, &newsol, FALSE, FALSE, TRUE, TRUE, TRUE, &soladded) );
452  }
453  if( !soladded || !SCIPisEQ(scip, SCIPgetSolOrigObj(subscip, subsols[i-1]), SCIPgetSolOrigObj(subscip, subsols[0])) )
454  disabledualreductions = TRUE;
455  }
456 
457  /* if the sub problem was solved completely, we update the dual bound */
458  dualboundchg = FALSE;
459  if( sepadata->applysolved && !disabledualreductions
461  {
462  /* we need to multiply the dualbound with the scaling factor and add the offset,
463  * because this information has been disregarded in the sub-SCIP
464  */
465  SCIPdebugMsg(scip, "Update old dualbound %g to new dualbound %g.\n",
466  SCIPgetDualbound(scip), SCIPretransformObj(scip, SCIPgetDualbound(subscip)));
467 
469  dualboundchg = TRUE;
470  }
471 
472  /* check, whether conflicts were created */
473  nconflicts = 0;
474  if( sepadata->applyconflicts && !disabledualreductions && SCIPgetNConflictConssApplied(subscip) > 0 )
475  {
476  SCIP_HASHMAP* consmap;
477  int hashtablesize;
478  int nmaxconfs;
479 
480  assert(SCIPgetNConflictConssApplied(subscip) < (SCIP_Longint) INT_MAX);
481  hashtablesize = (int) SCIPgetNConflictConssApplied(subscip);
482  assert(hashtablesize < INT_MAX/5);
483 
484  /* create the variable mapping hash map */
485  SCIP_CALL( SCIPhashmapCreate(&consmap, SCIPblkmem(scip), hashtablesize) );
486 
487  SCIP_CALL( SCIPgetIntParam(scip, "conflict/maxconss", &nmaxconfs) );
488  if( global )
489  nmaxconfs *= 20;
490 
491  /* loop over all constraint handlers that might contain conflict constraints
492  * @todo select promising constraints and not greedy
493  */
494  for( i = 0; i < nconshdlrs && nconflicts < nmaxconfs; ++i)
495  {
496  /* copy constraints that have been created in FD run */
497  if( conshdlrs[i] != NULL && SCIPconshdlrGetNConss(conshdlrs[i]) > oldnconss[i] )
498  {
499  SCIP_CONS** conss;
500  int c;
501  int nconss;
502 
503  nconss = SCIPconshdlrGetNConss(conshdlrs[i]);
504  conss = SCIPconshdlrGetConss(conshdlrs[i]);
505 
506  /* loop over all constraints that have been added in sub-SCIP run, these are the conflicts */
507  for( c = oldnconss[i]; c < nconss && nconflicts < nmaxconfs; ++c)
508  {
509  SCIP_CONS* cons;
510  SCIP_CONS* conscopy;
511 
512  cons = conss[c];
513  assert(cons != NULL);
514 
515  success = FALSE;
516 
517  /* @todo assert that flags are as they should be for conflicts */
518  SCIP_CALL( SCIPgetConsCopy(subscip, scip, cons, &conscopy, conshdlrs[i], varmapbw, consmap, NULL,
520  SCIPconsIsPropagated(cons), !global, FALSE, SCIPconsIsDynamic(cons),
521  SCIPconsIsRemovable(cons), FALSE, TRUE, &success) );
522 
523  if( success )
524  {
525  nconflicts++;
526 
527  SCIP_CALL( SCIPaddConflict(scip, global ? NULL : SCIPgetCurrentNode(scip), conscopy, NULL,
529  }
530  else
531  {
532  SCIPdebugMsg(scip, "failed to copy conflict constraint %s back to original SCIP\n", SCIPconsGetName(cons));
533  }
534  }
535  }
536  }
537  SCIPhashmapFree(&consmap);
538  }
539 
540  /* check, whether tighter (global) bounds were detected */
541  cutoff = FALSE;
542  nbdchgs = 0;
543  if( sepadata->applybdchgs && !disabledualreductions )
544  {
545  for( i = 0; i < nvars; ++i )
546  {
547  SCIP_Bool tightened;
548 
549  if( subvars[i] == NULL )
550  continue;
551 
552  assert(SCIPisLE(scip, SCIPvarGetLbGlobal(vars[i]), SCIPvarGetLbGlobal(subvars[i])));
553  assert(SCIPisLE(scip, SCIPvarGetLbGlobal(subvars[i]), SCIPvarGetUbGlobal(subvars[i])));
554  assert(SCIPisLE(scip, SCIPvarGetUbGlobal(subvars[i]), SCIPvarGetUbGlobal(vars[i])));
555 
556  /* update the bounds of the original SCIP, if a better bound was proven in the sub-SCIP */
557  if( global )
558  {
559 #ifndef NDEBUG
560  assert(SCIPgetEffectiveRootDepth(scip) == SCIPgetDepth(scip));
561 #else
562  if( SCIPgetEffectiveRootDepth(scip) < SCIPgetDepth(scip) )
563  return SCIP_INVALIDCALL;
564 #endif
565  tightened = FALSE;
566 
567  SCIP_CALL( SCIPtightenVarUbGlobal(scip, vars[i], SCIPvarGetUbGlobal(subvars[i]), FALSE, &cutoff, &tightened) );
568 
569  if( cutoff )
570  break;
571 
572  if( tightened )
573  nbdchgs++;
574 
575  tightened = FALSE;
576 
577  SCIP_CALL( SCIPtightenVarLbGlobal(scip, vars[i], SCIPvarGetLbGlobal(subvars[i]), FALSE, &cutoff, &tightened) );
578 
579  if( cutoff )
580  break;
581 
582  if( tightened )
583  nbdchgs++;
584  }
585  else
586  {
587  tightened = FALSE;
588 
589  SCIP_CALL( SCIPtightenVarUb(scip, vars[i], SCIPvarGetUbGlobal(subvars[i]), FALSE, &cutoff, &tightened) );
590 
591  if( cutoff )
592  break;
593 
594  if( tightened )
595  nbdchgs++;
596 
597  tightened = FALSE;
598 
599  SCIP_CALL( SCIPtightenVarLb(scip, vars[i], SCIPvarGetLbGlobal(subvars[i]), FALSE, &cutoff, &tightened) );
600 
601  if( cutoff )
602  break;
603 
604  if( tightened )
605  nbdchgs++;
606  }
607  }
608  }
609 
610  /* install start values for inference branching */
611  /* @todo use different nbranching counters for pseudo cost and inference values and update inference values in the tree */
612  if( sepadata->applyinfervals && global && (!sepadata->reducedinfer || soladded || nbdchgs + nconflicts > 0) )
613  {
614  for( i = 0; i < nvars; ++i )
615  {
616  SCIP_Real downinfer;
617  SCIP_Real upinfer;
618  SCIP_Real downvsids;
619  SCIP_Real upvsids;
620  SCIP_Real downconflen;
621  SCIP_Real upconflen;
622 
623  if( subvars[i] == NULL )
624  continue;
625 
626  /* copy downwards branching statistics */
627  downvsids = SCIPgetVarVSIDS(subscip, subvars[i], SCIP_BRANCHDIR_DOWNWARDS);
628  downconflen = SCIPgetVarAvgConflictlength(subscip, subvars[i], SCIP_BRANCHDIR_DOWNWARDS);
629  downinfer = SCIPgetVarAvgInferences(subscip, subvars[i], SCIP_BRANCHDIR_DOWNWARDS);
630 
631  /* copy upwards branching statistics */
632  upvsids = SCIPgetVarVSIDS(subscip, subvars[i], SCIP_BRANCHDIR_UPWARDS);
633  upconflen = SCIPgetVarAvgConflictlength(subscip, subvars[i], SCIP_BRANCHDIR_UPWARDS);
634  upinfer = SCIPgetVarAvgInferences(subscip, subvars[i], SCIP_BRANCHDIR_UPWARDS);
635 
636 #ifdef SCIP_DEBUG
637  /* memorize statistics */
638  if( downinfer+downconflen+downvsids > 0.0 || upinfer+upconflen+upvsids != 0 )
639  n1startinfers++;
640 
641  if( downinfer+downconflen+downvsids > 0.0 && upinfer+upconflen+upvsids != 0 )
642  n2startinfers++;
643 #endif
644 
645  SCIP_CALL( SCIPinitVarBranchStats(scip, vars[i], 0.0, 0.0, downvsids, upvsids, downconflen, upconflen, downinfer, upinfer, 0.0, 0.0) );
646  }
647  }
648 
649 #ifdef SCIP_DEBUG
650  if( cutoff )
651  {
652  SCIPdebugMsg(scip, "Rapidlearning detected %s infeasibility.\n", global ? "global" : "local");
653  }
654 
655  SCIPdebugMsg(scip, "Rapidlearning added %d %s conflicts, changed %d bounds, %s primal solution, %s dual bound improvement.\n",
656  nconflicts, global ? "global" : "local", nbdchgs, soladded ? "found" : "no", dualboundchg ? "found" : "no");
657 
658  SCIPdebugMsg(scip, "YYY Infervalues initialized on one side: %5.2f %% of variables, %5.2f %% on both sides\n",
659  100.0 * n1startinfers/(SCIP_Real)nvars, 100.0 * n2startinfers/(SCIP_Real)nvars);
660 #endif
661 
662  /* change result pointer */
663  if( cutoff )
664  *result = SCIP_CUTOFF;
665  else if( nconflicts > 0 || dualboundchg )
666  *result = SCIP_CONSADDED;
667  else if( nbdchgs > 0 )
668  *result = SCIP_REDUCEDDOM;
669 
670  /* free local data */
671  assert(oldnconss != NULL);
672  assert(conshdlrs != NULL);
673  assert(varmapbw != NULL);
674  SCIPfreeBufferArray(scip, &oldnconss);
675  SCIPfreeBufferArray(scip, &conshdlrs);
676  SCIPhashmapFree(&varmapbw);
677 
678  /* free subproblem */
679  SCIPfreeBufferArray(scip, &subvars);
680 
681  return SCIP_OKAY;
682 }
683 
684 /** returns whether rapid learning is allowed to run locally */
685 static
687  SCIP* scip, /**< SCIP data structure */
688  SCIP_SEPADATA* sepadata, /**< separator's private data */
689  SCIP_Bool* run /**< pointer to store whether rapid learning is allowed to run */
690  )
691 {
692  assert(scip != NULL);
693  assert(sepadata != NULL);
694 
695  *run = FALSE;
696 
697  /* return TRUE if local exec should not be checked */
698  if( !sepadata->checkexec )
699  {
700  *run = TRUE;
701  }
702 
703  /* problem has zero objective function, i.e., it is a pure feasibility problem */
704  if( !(*run) && sepadata->checkobj && SCIPgetNObjVars(scip) == 0 )
705  {
706  SCIPdebugMsg(scip, "-> allow local rapid learning due to global zero objective\n");
707 
708  *run = TRUE;
709  }
710 
711  /* check whether a solution was found */
712  if( !(*run) && sepadata->checknsols && SCIPgetNSolsFound(scip) == 0 )
713  {
714  SCIPdebugMsg(scip, "-> allow local rapid learning due to no solution found so far\n");
715 
716  *run = TRUE;
717  }
718 
719  /* check whether the dual bound has not changed since the root node */
720  if( !(*run) && sepadata->checkdualbound && sepadata->nwaitingnodes < SCIPgetNNodes(scip) )
721  {
722  SCIP_Real rootdualbound;
723  SCIP_Real locdualbound;
724 
725  rootdualbound = SCIPgetLowerboundRoot(scip);
726  locdualbound = SCIPgetLocalLowerbound(scip);
727 
728  if( SCIPisEQ(scip, rootdualbound, locdualbound) )
729  {
730  SCIPdebugMsg(scip, "-> allow local rapid learning due to equal dualbound\n");
731 
732  *run = TRUE;
733  }
734  }
735 
736  /* check leaf nodes */
737  if( !(*run) && sepadata->checkleaves )
738  {
739  SCIP_Real ratio = (SCIPgetNInfeasibleLeaves(scip) + 1.0) / (SCIPgetNObjlimLeaves(scip) + 1.0);
740 
741  if( SCIPisLE(scip, sepadata->mininflpratio, ratio) )
742  {
743  SCIPdebugMsg(scip, "-> allow local rapid learning due to inf/obj leaves ratio\n");
744 
745  *run = TRUE;
746  }
747  }
748 
749  /* check whether all undecided integer variables have zero objective coefficient */
750  if( !(*run) && sepadata->checkobj )
751  {
752  SCIP_Bool allzero;
753  SCIP_VAR** vars;
754  int ndiscvars;
755  int i;
756 
757  allzero = TRUE;
758  vars = SCIPgetVars(scip);
759  ndiscvars = SCIPgetNBinVars(scip) + SCIPgetNIntVars(scip) + SCIPgetNImplVars(scip);
760 
761  for( i = 0; i < ndiscvars; i++ )
762  {
763  assert(SCIPvarIsIntegral(vars[i]));
764 
765  /* skip locally fixed variables */
766  if( SCIPisEQ(scip, SCIPvarGetLbLocal(vars[i]), SCIPvarGetUbLocal(vars[i])) )
767  continue;
768 
769  if( !SCIPisZero(scip, SCIPvarGetObj(vars[i])) )
770  {
771  allzero = FALSE;
772  break;
773  }
774  }
775 
776  if( allzero )
777  {
778  SCIPdebugMsg(scip, "-> allow local rapid learning due to local zero objective\n");
779 
780  *run = TRUE;
781  }
782  }
783 
784  /* check degeneracy */
785  if( !(*run) && sepadata->checkdegeneracy )
786  {
787  SCIP_Real degeneracy;
788  SCIP_Real varconsratio;
789 
790  SCIP_CALL( SCIPgetLPDegeneracy(scip, &degeneracy, &varconsratio) );
791 
792  SCIPdebugMsg(scip, "degeneracy: %.2f ratio: %.2f\n", degeneracy, varconsratio);
793 
794  if( degeneracy >= sepadata->mindegeneracy || varconsratio >= sepadata->minvarconsratio )
795  {
796  SCIPdebugMsg(scip, "-> allow local rapid learning due to degeneracy\n");
797 
798  *run = TRUE;
799  }
800  }
801 
802  return SCIP_OKAY;
803 }
804 
805 /** LP solution separation method of separator */
806 static
807 SCIP_DECL_SEPAEXECLP(sepaExeclpRapidlearning)
808 {/*lint --e{715}*/
809  SCIP_VAR** vars;
810  SCIP* subscip;
811  SCIP_SEPADATA* sepadata;
812  SCIP_Bool global;
814  SCIP_Bool success;
815  SCIP_RETCODE retcode;
816  int ndiscvars;
817  int i;
818 
819  assert(sepa != NULL);
820  assert(scip != NULL);
821  assert(result != NULL);
822 
823  *result = SCIP_DIDNOTRUN;
824 
825  ndiscvars = SCIPgetNBinVars(scip) + SCIPgetNIntVars(scip) + SCIPgetNImplVars(scip);
826 
827  /* only run when still not fixed binary variables exists */
828  if( ndiscvars == 0 )
829  return SCIP_OKAY;
830 
831  /* get separator's data */
832  sepadata = SCIPsepaGetData(sepa);
833  assert(sepadata != NULL);
834 
835  /* call separator at most maxcalls times */
836  if( SCIPsepaGetNCalls(sepa) >= sepadata->maxcalls )
837  return SCIP_OKAY;
838 
839  /* only run for integer programs */
840  if( !sepadata->contvars && ndiscvars != SCIPgetNVars(scip) )
841  return SCIP_OKAY;
842 
843  /* only run if there are few enough continuous variables */
844  if( sepadata->contvars && SCIPgetNContVars(scip) > sepadata->contvarsquot * SCIPgetNVars(scip) )
845  return SCIP_OKAY;
846 
847  /* do not run if pricers are present */
848  if( SCIPgetNActivePricers(scip) > 0 )
849  return SCIP_OKAY;
850 
851  /* if the separator should be exclusive to the root node, this prevents multiple calls due to restarts */
852  if( SCIPsepaGetFreq(sepa) == 0 && SCIPsepaGetNCalls(sepa) > 0 )
853  return SCIP_OKAY;
854 
855  /* call separator at most once per node */
856  if( SCIPsepaGetNCallsAtNode(sepa) > 0 )
857  return SCIP_OKAY;
858 
859  global = (SCIPgetDepth(scip) <= SCIPgetEffectiveRootDepth(scip));
860 
861  /* check if rapid learning should be applied locally */
862  SCIP_CALL( checkExec(scip, sepadata, &run) );
863 
864  /* @todo check whether we want to run at the root node again, e.g., inf/obj ratio is large enough */
865  if( !run )
866  return SCIP_OKAY;
867 
868  /* do not call rapid learning, if the problem is too big */
869  if( SCIPgetNVars(scip) > sepadata->maxnvars || SCIPgetNConss(scip) > sepadata->maxnconss )
870  return SCIP_OKAY;
871 
872  if( SCIPisStopped(scip) )
873  return SCIP_OKAY;
874 
875  /* check whether there is enough time and memory left */
876  SCIP_CALL( SCIPcheckCopyLimits(scip, &success) );
877 
878  if( !success)
879  return SCIP_OKAY;
880 
881  /* skip rapid learning when the sub-SCIP would contain an integer variable with an infinite bound in direction of the
882  * objective function; this might lead to very bad branching decisions when enforcing a pseudo solution (#1439)
883  */
884  vars = SCIPgetVars(scip);
885  for( i = SCIPgetNBinVars(scip); i < ndiscvars; i++ )
886  {
887  SCIP_Real lb = SCIPvarGetLbLocal(vars[i]);
888  SCIP_Real ub = SCIPvarGetUbLocal(vars[i]);
889  SCIP_Real obj = SCIPvarGetObj(vars[i]);
890 
891  if( (SCIPisNegative(scip, obj) && SCIPisInfinity(scip, ub))
892  || (SCIPisPositive(scip, obj) && SCIPisInfinity(scip, -lb)) )
893  {
894  SCIPdebugMsg(scip, "unbounded integer variable %s (in [%g,%g]) with objective %g -> skip rapid learning\n",
895  SCIPvarGetName(vars[i]), lb, ub, obj);
896  return SCIP_OKAY;
897  }
898  }
899 
900  *result = SCIP_DIDNOTFIND;
901 
902  SCIP_CALL( SCIPcreate(&subscip) );
903 
904  retcode = setupAndSolveSubscipRapidlearning(scip, subscip, sepadata, (int)SCIPsepaGetNCalls(sepa)+1, global, result);
905 
906  SCIP_CALL( SCIPfree(&subscip) );
907 
908  return retcode;
909 }
910 
911 
912 /*
913  * separator specific interface methods
914  */
915 
916 /** creates the rapidlearning separator and includes it in SCIP */
918  SCIP* scip /**< SCIP data structure */
919  )
920 {
921  SCIP_SEPADATA* sepadata;
922  SCIP_SEPA* sepa;
924  /* create rapidlearning separator data */
925  SCIP_CALL( SCIPallocBlockMemory(scip, &sepadata) );
926 
927  /* include separator */
930  sepaExeclpRapidlearning, NULL,
931  sepadata) );
932 
933  assert(sepa != NULL);
934 
935  /* set non-NULL pointers to callback methods */
936  SCIP_CALL( SCIPsetSepaCopy(scip, sepa, sepaCopyRapidlearning) );
937  SCIP_CALL( SCIPsetSepaFree(scip, sepa, sepaFreeRapidlearning) );
938 
939  /* add rapidlearning separator parameters */
940  SCIP_CALL( SCIPaddBoolParam(scip, "separating/" SEPA_NAME "/applyconflicts",
941  "should the found conflicts be applied in the original SCIP?",
942  &sepadata->applyconflicts, TRUE, DEFAULT_APPLYCONFLICTS, NULL, NULL) );
943 
944  SCIP_CALL( SCIPaddBoolParam(scip, "separating/" SEPA_NAME "/applybdchgs",
945  "should the found global bound deductions be applied in the original SCIP?",
946  &sepadata->applybdchgs, TRUE, DEFAULT_APPLYBDCHGS, NULL, NULL) );
947 
948  SCIP_CALL( SCIPaddBoolParam(scip, "separating/" SEPA_NAME "/applyinfervals",
949  "should the inference values be used as initialization in the original SCIP?",
950  &sepadata->applyinfervals, TRUE, DEFAULT_APPLYINFERVALS, NULL, NULL) );
951 
952  SCIP_CALL( SCIPaddBoolParam(scip, "separating/" SEPA_NAME "/reducedinfer",
953  "should the inference values only be used when " SEPA_NAME " found other reductions?",
954  &sepadata->reducedinfer, TRUE, DEFAULT_REDUCEDINFER, NULL, NULL) );
955 
956  SCIP_CALL( SCIPaddBoolParam(scip, "separating/" SEPA_NAME "/applyprimalsol",
957  "should the incumbent solution be copied to the original SCIP?",
958  &sepadata->applyprimalsol, TRUE, DEFAULT_APPLYPRIMALSOL, NULL, NULL) );
959 
960  SCIP_CALL( SCIPaddBoolParam(scip, "separating/" SEPA_NAME "/applysolved",
961  "should a solved status be copied to the original SCIP?",
962  &sepadata->applysolved, TRUE, DEFAULT_APPLYSOLVED, NULL, NULL) );
963 
964  SCIP_CALL( SCIPaddBoolParam(scip, "separating/" SEPA_NAME "/checkdegeneracy",
965  "should local LP degeneracy be checked?",
966  &sepadata->checkdegeneracy, TRUE, DEFAULT_CHECKDEGANERACY, NULL, NULL) );
967 
968  SCIP_CALL( SCIPaddBoolParam(scip, "separating/" SEPA_NAME "/checkdualbound",
969  "should the progress on the dual bound be checked?",
970  &sepadata->checkdualbound, TRUE, DEFAULT_CHECKDUALBOUND, NULL, NULL) );
971 
972  SCIP_CALL( SCIPaddBoolParam(scip, "separating/" SEPA_NAME "/checkleaves",
973  "should the ratio of leaves proven to be infeasible and exceeding the cutoff bound be checked?",
974  &sepadata->checkleaves, TRUE, DEFAULT_CHECKLEAVES, NULL, NULL) );
975 
976  SCIP_CALL( SCIPaddBoolParam(scip, "separating/" SEPA_NAME "/checkexec",
977  "check whether rapid learning should be executed",
978  &sepadata->checkexec, TRUE, DEFAULT_CHECKEXEC, NULL, NULL) );
979 
980  SCIP_CALL( SCIPaddBoolParam(scip, "separating/" SEPA_NAME "/checkobj",
981  "should the (local) objective function be checked?",
982  &sepadata->checkobj, TRUE, DEFAULT_CHECKOBJ, NULL, NULL) );
983 
984  SCIP_CALL( SCIPaddBoolParam(scip, "separating/" SEPA_NAME "/checknsols",
985  "should the number of solutions found so far be checked?",
986  &sepadata->checknsols, TRUE, DEFAULT_CHECKNSOLS, NULL, NULL) );
987 
988  SCIP_CALL( SCIPaddBoolParam(scip, "separating/" SEPA_NAME "/contvars",
989  "should rapid learning be applied when there are continuous variables?",
990  &sepadata->contvars, TRUE, DEFAULT_CONTVARS, NULL, NULL) );
991 
992  SCIP_CALL( SCIPaddRealParam(scip, "separating/" SEPA_NAME "/contvarsquot",
993  "maximal portion of continuous variables to apply rapid learning",
994  &sepadata->contvarsquot, TRUE, DEFAULT_CONTVARSQUOT, 0.0, 1.0, NULL, NULL) );
995 
996  SCIP_CALL( SCIPaddRealParam(scip, "separating/" SEPA_NAME "/lpiterquot",
997  "maximal fraction of LP iterations compared to node LP iterations",
998  &sepadata->lpiterquot, TRUE, DEFAULT_LPITERQUOT, 0.0, SCIP_REAL_MAX, NULL, NULL) );
999 
1000  SCIP_CALL( SCIPaddRealParam(scip, "separating/" SEPA_NAME "/mindegeneracy",
1001  "minimal degeneracy threshold to allow local rapid learning",
1002  &sepadata->mindegeneracy, TRUE, DEFAULT_MINDEGENERACY, 0.0, 1.0, NULL, NULL) );
1003 
1004  SCIP_CALL( SCIPaddRealParam(scip, "separating/" SEPA_NAME "/mininflpratio",
1005  "minimal threshold of inf/obj leaves to allow local rapid learning",
1006  &sepadata->mininflpratio, TRUE, DEFAULT_MININFLPRATIO, 0.0, SCIP_REAL_MAX, NULL, NULL) );
1007 
1008  SCIP_CALL( SCIPaddRealParam(scip, "separating/" SEPA_NAME "/minvarconsratio",
1009  "minimal ratio of unfixed variables in relation to basis size to allow local rapid learning",
1010  &sepadata->minvarconsratio, TRUE, DEFAULT_MINVARCONSRATIO, 1.0, SCIP_REAL_MAX, NULL, NULL) );
1011 
1012  SCIP_CALL( SCIPaddIntParam(scip, "separating/" SEPA_NAME "/maxnvars",
1013  "maximum problem size (variables) for which rapid learning will be called",
1014  &sepadata->maxnvars, TRUE, DEFAULT_MAXNVARS, 0, INT_MAX, NULL, NULL) );
1015 
1016  SCIP_CALL( SCIPaddIntParam(scip, "separating/" SEPA_NAME "/maxnconss",
1017  "maximum problem size (constraints) for which rapid learning will be called",
1018  &sepadata->maxnconss, TRUE, DEFAULT_MAXNCONSS, 0, INT_MAX, NULL, NULL) );
1019 
1020  SCIP_CALL( SCIPaddIntParam(scip, "separating/" SEPA_NAME "/maxcalls",
1021  "maximum number of overall calls",
1022  &sepadata->maxcalls, TRUE, DEFAULT_MAXCALLS, 0, INT_MAX, NULL, NULL) );
1023 
1024  SCIP_CALL( SCIPaddIntParam(scip, "separating/" SEPA_NAME "/maxnodes",
1025  "maximum number of nodes considered in rapid learning run",
1026  &sepadata->maxnodes, TRUE, DEFAULT_MAXNODES, 0, INT_MAX, NULL, NULL) );
1027 
1028  SCIP_CALL( SCIPaddIntParam(scip, "separating/" SEPA_NAME "/minnodes",
1029  "minimum number of nodes considered in rapid learning run",
1030  &sepadata->minnodes, TRUE, DEFAULT_MINNODES, 0, INT_MAX, NULL, NULL) );
1031 
1032  SCIP_CALL( SCIPaddLongintParam(scip, "separating/" SEPA_NAME "/nwaitingnodes",
1033  "number of nodes that should be processed before rapid learning is executed locally based on the progress of the dualbound",
1034  &sepadata->nwaitingnodes, TRUE, DEFAULT_NWAITINGNODES, 0L, SCIP_LONGINT_MAX, NULL, NULL) );
1035 
1036  SCIP_CALL( SCIPaddBoolParam(scip, "separating/" SEPA_NAME "/copycuts",
1037  "should all active cuts from cutpool be copied to constraints in subproblem?",
1038  &sepadata->copycuts, TRUE, DEFAULT_COPYCUTS, NULL, NULL) );
1039 
1040  return SCIP_OKAY;
1041 }
enum SCIP_Result SCIP_RESULT
Definition: type_result.h:52
SCIP_Bool SCIPisEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
#define SEPA_USESSUBSCIP
SCIP_Longint SCIPgetNSolsFound(SCIP *scip)
SCIP_RETCODE SCIPhashmapInsert(SCIP_HASHMAP *hashmap, void *origin, void *image)
Definition: misc.c:3096
int SCIPgetNContVars(SCIP *scip)
Definition: scip_prob.c:2166
SCIP_Bool SCIPisPositive(SCIP *scip, SCIP_Real val)
#define DEFAULT_REDUCEDINFER
SCIP_Bool SCIPisStopped(SCIP *scip)
Definition: scip_general.c:687
SCIP_EXPORT int SCIPsepaGetFreq(SCIP_SEPA *sepa)
Definition: sepa.c:741
SCIP_CONSHDLR * SCIPfindConshdlr(SCIP *scip, const char *name)
Definition: scip_cons.c:877
#define SEPA_FREQ
SCIP_RETCODE SCIPtightenVarLb(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound, SCIP_Bool force, SCIP_Bool *infeasible, SCIP_Bool *tightened)
Definition: scip_var.c:5184
#define DEFAULT_MINNODES
SCIP_STATUS SCIPgetStatus(SCIP *scip)
Definition: scip_general.c:467
SCIP_RETCODE SCIPtranslateSubSol(SCIP *scip, SCIP *subscip, SCIP_SOL *subsol, SCIP_HEUR *heur, SCIP_VAR **subvars, SCIP_SOL **newsol)
Definition: scip_copy.c:1356
SCIP_EXPORT SCIP_VAR * SCIPvarGetTransVar(SCIP_VAR *var)
Definition: var.c:17370
SCIP_Bool SCIPconsIsChecked(SCIP_CONS *cons)
Definition: cons.c:8276
SCIP_Real SCIPgetVarAvgInferences(SCIP *scip, SCIP_VAR *var, SCIP_BRANCHDIR dir)
Definition: scip_var.c:9354
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
Definition: scip_message.c:123
static SCIP_RETCODE checkExec(SCIP *scip, SCIP_SEPADATA *sepadata, SCIP_Bool *run)
#define DEFAULT_CONTVARSQUOT
#define DEFAULT_LPITERQUOT
SCIP_RETCODE SCIPtightenVarUb(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound, SCIP_Bool force, SCIP_Bool *infeasible, SCIP_Bool *tightened)
Definition: scip_var.c:5301
SCIP_RETCODE SCIPtransformProb(SCIP *scip)
Definition: scip_solve.c:357
static SCIP_DECL_SEPAEXECLP(sepaExeclpRapidlearning)
#define DEFAULT_COPYCUTS
SCIP_RETCODE SCIPgetConsCopy(SCIP *sourcescip, SCIP *targetscip, SCIP_CONS *sourcecons, SCIP_CONS **targetcons, SCIP_CONSHDLR *sourceconshdlr, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, const char *name, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode, SCIP_Bool global, SCIP_Bool *valid)
Definition: scip_copy.c:1534
int SCIPconshdlrGetNConss(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4582
static SCIP_RETCODE setupAndSolveSubscipRapidlearning(SCIP *scip, SCIP *subscip, SCIP_SEPADATA *sepadata, int randseed, SCIP_Bool global, SCIP_RESULT *result)
SCIP_NODE * SCIPgetCurrentNode(SCIP *scip)
Definition: scip_tree.c:81
int SCIPgetNConss(SCIP *scip)
Definition: scip_prob.c:3036
int SCIPgetNVars(SCIP *scip)
Definition: scip_prob.c:1986
#define FALSE
Definition: def.h:73
SCIP_Real SCIPgetVarAvgConflictlength(SCIP *scip, SCIP_VAR *var, SCIP_BRANCHDIR dir)
Definition: scip_var.c:9300
SCIP_EXPORT SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
Definition: var.c:17515
SCIP_EXPORT SCIP_VARTYPE SCIPvarGetType(SCIP_VAR *var)
Definition: var.c:17182
#define TRUE
Definition: def.h:72
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:54
methods commonly used by primal heuristics
SCIP_Bool SCIPconsIsInitial(SCIP_CONS *cons)
Definition: cons.c:8246
#define DEFAULT_MINDEGENERACY
SCIP_Real SCIPgetLocalLowerbound(SCIP *scip)
Definition: scip_prob.c:3579
SCIP_RETCODE SCIPsolve(SCIP *scip)
Definition: scip_solve.c:2527
SCIP_Bool SCIPisFeasLE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
void * SCIPhashmapGetImage(SCIP_HASHMAP *hashmap, void *origin)
Definition: misc.c:3201
SCIP_RETCODE SCIPincludeSepaRapidlearning(SCIP *scip)
int SCIPgetNImplVars(SCIP *scip)
Definition: scip_prob.c:2121
public methods for problem variables
SCIP_RETCODE SCIPsetSepaCopy(SCIP *scip, SCIP_SEPA *sepa, SCIP_DECL_SEPACOPY((*sepacopy)))
Definition: scip_sepa.c:142
SCIP_RETCODE SCIPaddBoolParam(SCIP *scip, const char *name, const char *desc, SCIP_Bool *valueptr, SCIP_Bool isadvanced, SCIP_Bool defaultvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
Definition: scip_param.c:48
#define SCIPfreeBlockMemory(scip, ptr)
Definition: scip_mem.h:95
SCIP_RETCODE SCIPsetSubscipsOff(SCIP *scip, SCIP_Bool quiet)
Definition: scip_param.c:899
SCIP_Real SCIPgetUpperbound(SCIP *scip)
#define SCIP_LONGINT_MAX
Definition: def.h:149
#define SCIPfreeBufferArray(scip, ptr)
Definition: scip_mem.h:123
#define SCIPallocBlockMemory(scip, ptr)
Definition: scip_mem.h:78
SCIP_RETCODE SCIPpresolve(SCIP *scip)
Definition: scip_solve.c:2366
#define SCIPdebugMsg
Definition: scip_message.h:69
#define DEFAULT_CHECKDUALBOUND
SCIP_RETCODE SCIPcheckCopyLimits(SCIP *sourcescip, SCIP_Bool *success)
Definition: scip_copy.c:3192
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
#define DEFAULT_APPLYCONFLICTS
SCIP_Real SCIPgetVarVSIDS(SCIP *scip, SCIP_VAR *var, SCIP_BRANCHDIR dir)
Definition: scip_var.c:9112
int SCIPgetNIntVars(SCIP *scip)
Definition: scip_prob.c:2076
int SCIPgetEffectiveRootDepth(SCIP *scip)
Definition: scip_tree.c:117
SCIP_Longint SCIPgetNLPs(SCIP *scip)
SCIP_RETCODE SCIPsetObjlimit(SCIP *scip, SCIP_Real objlimit)
Definition: scip_prob.c:1420
int SCIPgetNSols(SCIP *scip)
Definition: scip_sol.c:2206
SCIP_Bool SCIPisLE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_RETCODE SCIPsetRealParam(SCIP *scip, const char *name, SCIP_Real value)
Definition: scip_param.c:619
SCIP_Longint SCIPgetNNodes(SCIP *scip)
SCIP_RETCODE SCIPcreate(SCIP **scip)
Definition: scip_general.c:283
SCIP_EXPORT const char * SCIPvarGetName(SCIP_VAR *var)
Definition: var.c:17017
SCIP_EXPORT SCIP_Bool SCIPvarIsIntegral(SCIP_VAR *var)
Definition: var.c:17208
int SCIPgetNObjVars(SCIP *scip)
Definition: scip_prob.c:2214
SCIP_VAR ** SCIPgetVars(SCIP *scip)
Definition: scip_prob.c:1941
#define DEFAULT_APPLYBDCHGS
SCIP_RETCODE SCIPaddConflict(SCIP *scip, SCIP_NODE *node, SCIP_CONS *cons, SCIP_NODE *validnode, SCIP_CONFTYPE conftype, SCIP_Bool iscutoffinvolved)
Definition: scip_prob.c:3222
#define SEPA_DELAY
BMS_BLKMEM * SCIPblkmem(SCIP *scip)
Definition: scip_mem.c:48
SCIP_Bool SCIPisZero(SCIP *scip, SCIP_Real val)
SCIP_RETCODE SCIPcopyCuts(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool global, int *ncutsadded)
Definition: scip_copy.c:2073
#define NULL
Definition: lpi_spx1.cpp:155
#define DEFAULT_CHECKEXEC
#define SEPA_PRIORITY
SCIP_Longint SCIPgetNObjlimLeaves(SCIP *scip)
#define SCIP_CALL(x)
Definition: def.h:364
SCIP_RETCODE SCIPsetPresolving(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
Definition: scip_param.c:948
#define DEFAULT_MAXNCONSS
SCIP_EXPORT SCIP_SEPADATA * SCIPsepaGetData(SCIP_SEPA *sepa)
Definition: sepa.c:608
SCIP_EXPORT const char * SCIPsepaGetName(SCIP_SEPA *sepa)
Definition: sepa.c:697
#define DEFAULT_CHECKNSOLS
#define DEFAULT_CHECKDEGANERACY
SCIP_RETCODE SCIPgetIntParam(SCIP *scip, const char *name, int *value)
Definition: scip_param.c:260
#define DEFAULT_MAXNVARS
SCIP_RETCODE SCIPunfixParam(SCIP *scip, const char *name)
Definition: scip_param.c:376
SCIP_Bool SCIPconsIsRemovable(SCIP_CONS *cons)
Definition: cons.c:8346
SCIP_RETCODE SCIPinitVarBranchStats(SCIP *scip, SCIP_VAR *var, SCIP_Real downpscost, SCIP_Real uppscost, SCIP_Real downvsids, SCIP_Real upvsids, SCIP_Real downconflen, SCIP_Real upconflen, SCIP_Real downinfer, SCIP_Real upinfer, SCIP_Real downcutoff, SCIP_Real upcutoff)
Definition: scip_var.c:9472
#define SCIPallocBufferArray(scip, ptr, num)
Definition: scip_mem.h:111
#define DEFAULT_MAXCALLS
int SCIPgetDepth(SCIP *scip)
Definition: scip_tree.c:638
#define SCIP_Bool
Definition: def.h:70
#define DEFAULT_MININFLPRATIO
SCIP_RETCODE SCIPhashmapCreate(SCIP_HASHMAP **hashmap, BMS_BLKMEM *blkmem, int mapsize)
Definition: misc.c:3014
SCIP_RETCODE SCIPincludeSepaBasic(SCIP *scip, SCIP_SEPA **sepa, const char *name, const char *desc, int priority, int freq, SCIP_Real maxbounddist, SCIP_Bool usessubscip, SCIP_Bool delay, SCIP_DECL_SEPAEXECLP((*sepaexeclp)), SCIP_DECL_SEPAEXECSOL((*sepaexecsol)), SCIP_SEPADATA *sepadata)
Definition: scip_sepa.c:100
SCIP_EXPORT SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
Definition: var.c:17677
SCIP_Bool SCIPisParamFixed(SCIP *scip, const char *name)
Definition: scip_param.c:210
#define MAX(x, y)
Definition: tclique_def.h:83
int SCIPgetNRootboundChgs(SCIP *scip)
#define DEFAULT_APPLYINFERVALS
SCIP_Longint SCIPgetNConflictConssFound(SCIP *scip)
SCIP_Bool SCIPisNegative(SCIP *scip, SCIP_Real val)
#define DEFAULT_MINVARCONSRATIO
static const unsigned int randseed
Definition: circle.c:46
SCIP_RETCODE SCIPprintStatistics(SCIP *scip, FILE *file)
SCIP_Bool SCIPconsIsSeparated(SCIP_CONS *cons)
Definition: cons.c:8256
SCIP_Real SCIPgetLowerboundRoot(SCIP *scip)
int SCIPgetNActivePricers(SCIP *scip)
Definition: scip_pricer.c:339
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 threadsafe, SCIP_Bool passmessagehdlr, SCIP_Bool *valid)
Definition: scip_copy.c:2908
SCIP_Bool SCIPconsIsDynamic(SCIP_CONS *cons)
Definition: cons.c:8336
SCIP_RETCODE SCIPcopyLimits(SCIP *sourcescip, SCIP *targetscip)
Definition: scip_copy.c:3228
SCIP_EXPORT SCIP_Real SCIPvarGetLbLocal(SCIP_VAR *var)
Definition: var.c:17723
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
#define SCIP_REAL_MAX
Definition: def.h:164
SCIP_EXPORT SCIP_Real SCIPvarGetUbLocal(SCIP_VAR *var)
Definition: var.c:17733
SCIP_RETCODE SCIPsetLongintParam(SCIP *scip, const char *name, SCIP_Longint value)
Definition: scip_param.c:561
static SCIP_DECL_SEPAFREE(sepaFreeRapidlearning)
SCIP_Longint SCIPgetNLPIterations(SCIP *scip)
SCIP_RETCODE SCIPgetLPDegeneracy(SCIP *scip, SCIP_Real *degeneracy, SCIP_Real *varconsratio)
Definition: scip_lp.c:2731
SCIP_Bool SCIPconsIsEnforced(SCIP_CONS *cons)
Definition: cons.c:8266
SCIP_SOL ** SCIPgetSols(SCIP *scip)
Definition: scip_sol.c:2255
SCIP_EXPORT SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
Definition: var.c:17667
SCIP_Bool SCIPisFeasLT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_CONS ** SCIPconshdlrGetConss(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4539
#define DEFAULT_CHECKOBJ
SCIP_RETCODE SCIPgetVarsData(SCIP *scip, SCIP_VAR ***vars, int *nvars, int *nbinvars, int *nintvars, int *nimplvars, int *ncontvars)
Definition: scip_prob.c:1860
SCIP_RETCODE SCIPaddIntParam(SCIP *scip, const char *name, const char *desc, int *valueptr, SCIP_Bool isadvanced, int defaultvalue, int minvalue, int maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
Definition: scip_param.c:74
SCIP_RETCODE SCIPupdateLocalDualbound(SCIP *scip, SCIP_Real newbound)
Definition: scip_prob.c:3640
void SCIPhashmapFree(SCIP_HASHMAP **hashmap)
Definition: misc.c:3048
const char * SCIPconsGetName(SCIP_CONS *cons)
Definition: cons.c:8077
#define SCIP_Real
Definition: def.h:163
SCIP_Real SCIPretransformObj(SCIP *scip, SCIP_Real obj)
Definition: scip_sol.c:1568
#define DEFAULT_CHECKLEAVES
rapidlearning separator
SCIP_RETCODE SCIPtightenVarUbGlobal(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound, SCIP_Bool force, SCIP_Bool *infeasible, SCIP_Bool *tightened)
Definition: scip_var.c:6329
#define SCIP_Longint
Definition: def.h:148
SCIP_RETCODE SCIPsetBoolParam(SCIP *scip, const char *name, SCIP_Bool value)
Definition: scip_param.c:445
#define DEFAULT_APPLYPRIMALSOL
int SCIPgetNBinVars(SCIP *scip)
Definition: scip_prob.c:2031
#define SEPA_NAME
SCIP_RETCODE SCIPaddLongintParam(SCIP *scip, const char *name, const char *desc, SCIP_Longint *valueptr, SCIP_Bool isadvanced, SCIP_Longint defaultvalue, SCIP_Longint minvalue, SCIP_Longint maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
Definition: scip_param.c:102
SCIP_EXPORT void SCIPsepaSetData(SCIP_SEPA *sepa, SCIP_SEPADATA *sepadata)
Definition: sepa.c:618
#define DEFAULT_MAXNODES
#define SEPA_DESC
SCIP_RETCODE SCIPfree(SCIP **scip)
Definition: scip_general.c:315
SCIP_RETCODE SCIPsetSepaFree(SCIP *scip, SCIP_SEPA *sepa, SCIP_DECL_SEPAFREE((*sepafree)))
Definition: scip_sepa.c:158
SCIP_EXPORT SCIP_Longint SCIPsepaGetNCalls(SCIP_SEPA *sepa)
Definition: sepa.c:814
#define DEFAULT_NWAITINGNODES
#define SCIP_CALL_ABORT(x)
Definition: def.h:343
SCIP_RETCODE SCIPchgVarType(SCIP *scip, SCIP_VAR *var, SCIP_VARTYPE vartype, SCIP_Bool *infeasible)
Definition: scip_var.c:8157
SCIP_STAGE SCIPgetStage(SCIP *scip)
Definition: scip_general.c:356
SCIP_RETCODE SCIPtrySolFree(SCIP *scip, SCIP_SOL **sol, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *stored)
Definition: scip_sol.c:3232
#define DEFAULT_APPLYSOLVED
SCIP_Real SCIPgetDualbound(SCIP *scip)
SCIP_EXPORT int SCIPsepaGetNCallsAtNode(SCIP_SEPA *sepa)
Definition: sepa.c:824
#define SEPA_MAXBOUNDDIST
default SCIP plugins
SCIP_Bool SCIPconsIsPropagated(SCIP_CONS *cons)
Definition: cons.c:8296
SCIP_RETCODE SCIPsetIntParam(SCIP *scip, const char *name, int value)
Definition: scip_param.c:503
#define DEFAULT_CONTVARS
SCIP_RETCODE SCIPsetSeparating(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
Definition: scip_param.c:974
static SCIP_DECL_SEPACOPY(sepaCopyRapidlearning)
SCIP_Longint SCIPgetNConflictConssApplied(SCIP *scip)
struct SCIP_SepaData SCIP_SEPADATA
Definition: type_sepa.h:43
SCIP_RETCODE SCIPtightenVarLbGlobal(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound, SCIP_Bool force, SCIP_Bool *infeasible, SCIP_Bool *tightened)
Definition: scip_var.c:6209
SCIP_Longint SCIPgetNInfeasibleLeaves(SCIP *scip)
SCIP_Real SCIPgetSolOrigObj(SCIP *scip, SCIP_SOL *sol)
Definition: scip_sol.c:1436