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-2022 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SCIP is distributed under the terms of the ZIB Academic License. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SCIP; see the file COPYING. If not visit scipopt.org. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file 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  if( SCIPisParamFixed(subscip, "nodeselection/dfs/stdpriority") )
266  {
267  SCIPwarningMessage(scip, "unfixing parameter nodeselection/dfs/stdpriority in subscip of rapidlearning\n");
268  SCIP_CALL( SCIPunfixParam(subscip, "nodeselection/dfs/stdpriority") );
269  }
271 
272  /* turn off pseudo objective propagation */
273  if( !SCIPisParamFixed(subscip, "propagating/pseudoobj/freq") )
274  {
275  SCIP_CALL( SCIPsetIntParam(subscip, "propagating/pseudoobj/freq", -1) );
276  }
277 
278  /* use classic inference branching */
279  if( !SCIPisParamFixed(subscip, "branching/inference/useweightedsum") )
280  {
281  SCIP_CALL( SCIPsetBoolParam(subscip, "branching/inference/useweightedsum", FALSE) );
282  }
283 
284  /* only create short conflicts */
285  if( !SCIPisParamFixed(subscip, "conflict/maxvarsfac") )
286  {
287  SCIP_CALL( SCIPsetRealParam(subscip, "conflict/maxvarsfac", 0.05) );
288  }
289 
290  /* set node limit for the subproblem based on the number of LP iterations per node,
291  * which are a determistic measure for the node processing time.
292  *
293  * Note: We scale by number of LPs + 1 because the counter is increased after solving the LP.
294  */
295  nodelimit = SCIPgetNLPIterations(scip) / (SCIPgetNLPs(scip) + 1);
296  nodelimit = MAX(sepadata->minnodes, nodelimit);
297  nodelimit = MIN(sepadata->maxnodes, nodelimit);
298 
299  /* change global random seed */
300  assert(randseed >= 0);
301  SCIP_CALL( SCIPgetIntParam(scip, "randomization/randomseedshift", &seedshift) );
302 
303  initseed = ((randseed + seedshift) % INT_MAX);
304  SCIP_CALL( SCIPsetIntParam(subscip, "randomization/randomseedshift", initseed) );
305 
306  restartnum = 1000;
307 
308  #ifdef SCIP_DEBUG
309  /* for debugging, enable full output */
310  SCIP_CALL( SCIPsetIntParam(subscip, "display/verblevel", 5) );
311  SCIP_CALL( SCIPsetIntParam(subscip, "display/freq", -1) );
312  #else
313  /* disable statistic timing inside sub SCIP and output to console */
314  SCIP_CALL( SCIPsetIntParam(subscip, "display/verblevel", 0) );
315  SCIP_CALL( SCIPsetBoolParam(subscip, "timing/statistictiming", FALSE) );
316  #endif
317 
318  /* set limits for the subproblem */
319  SCIP_CALL( SCIPcopyLimits(scip, subscip) );
320  SCIP_CALL( SCIPsetLongintParam(subscip, "limits/nodes", nodelimit/5) );
321  SCIP_CALL( SCIPsetIntParam(subscip, "limits/restarts", 0) );
322  SCIP_CALL( SCIPsetIntParam(subscip, "conflict/restartnum", restartnum) );
323 
324  /* forbid recursive call of heuristics and separators solving subMIPs */
325  SCIP_CALL( SCIPsetSubscipsOff(subscip, TRUE) );
326 
327  /* disable cutting plane separation */
329 
330  /* disable expensive presolving */
332 
333  /* do not abort subproblem on CTRL-C */
334  SCIP_CALL( SCIPsetBoolParam(subscip, "misc/catchctrlc", FALSE) );
335 
336  /* add an objective cutoff */
337  SCIP_CALL( SCIPsetObjlimit(subscip, SCIPgetUpperbound(scip)) );
338 
339  /* create the variable mapping hash map */
340  SCIP_CALL( SCIPhashmapCreate(&varmapbw, SCIPblkmem(scip), nvars) );
341 
342  /* store reversing mapping of variables */
343  SCIP_CALL( SCIPtransformProb(subscip) );
344  for( i = 0; i < nvars; ++i)
345  {
346  if( subvars[i] != NULL )
347  {
348  SCIP_CALL( SCIPhashmapInsert(varmapbw, SCIPvarGetTransVar(subvars[i]), vars[i]) );
349  }
350  }
351 
352  /* allocate memory for constraints storage. Each constraint that will be created from now on will be a conflict.
353  * Therefore, we need to remember oldnconss to get the conflicts from the FD search.
354  */
355  nconshdlrs = 4;
356  SCIP_CALL( SCIPallocBufferArray(scip, &conshdlrs, nconshdlrs) );
357  SCIP_CALL( SCIPallocBufferArray(scip, &oldnconss, nconshdlrs) );
358 
359  /* store number of constraints before rapid learning search */
360  conshdlrs[0] = SCIPfindConshdlr(subscip, "setppc");
361  conshdlrs[1] = SCIPfindConshdlr(subscip, "logicor");
362  conshdlrs[2] = SCIPfindConshdlr(subscip, "linear");
363  conshdlrs[3] = SCIPfindConshdlr(subscip, "bounddisjunction");
364 
365  /* redundant constraints might be eliminated in presolving */
366  SCIP_CALL( SCIPpresolve(subscip) );
367 
368  for( i = 0; i < nconshdlrs; ++i)
369  {
370  if( conshdlrs[i] != NULL )
371  oldnconss[i] = SCIPconshdlrGetNConss(conshdlrs[i]);
372  }
373 
374  /* solve the subproblem, abort after errors in debug mode */
375  SCIP_CALL_ABORT( SCIPsolve(subscip) );
376 
377  /* if problem was already solved do not increase limits to run again */
378  if( SCIPgetStage(subscip) == SCIP_STAGE_SOLVED )
379  {
380  SCIPdebugMsg(scip, "Subscip was completely solved, status %d.\n", SCIPgetStatus(subscip));
381  }
382  /* abort solving, if limit of applied conflicts is reached */
383  else if( SCIPgetNConflictConssApplied(subscip) >= restartnum )
384  {
385  SCIPdebugMsg(scip, "finish after %" SCIP_LONGINT_FORMAT " successful conflict calls.\n", SCIPgetNConflictConssApplied(subscip));
386  }
387  /* if the first 20% of the solution process were successful, proceed */
388  else if( (sepadata->applyprimalsol && SCIPgetNSols(subscip) > 0 && SCIPisFeasLT(scip, SCIPgetUpperbound(subscip), SCIPgetUpperbound(scip) ) )
389  || (sepadata->applybdchgs && SCIPgetNRootboundChgs(subscip) > 0 )
390  || (sepadata->applyconflicts && SCIPgetNConflictConssApplied(subscip) > 0) )
391  {
392  SCIPdebugMsg(scip, "proceed solving after the first 20%% of the solution process, since:\n");
393 
394  if( SCIPgetNSols(subscip) > 0 && SCIPisFeasLE(scip, SCIPgetUpperbound(subscip), SCIPgetUpperbound(scip) ) )
395  {
396  SCIPdebugMsg(scip, " - there was a better solution (%f < %f)\n",SCIPgetUpperbound(subscip), SCIPgetUpperbound(scip));
397  }
398  if( SCIPgetNRootboundChgs(subscip) > 0 )
399  {
400  SCIPdebugMsg(scip, " - there were %d changed variables bounds\n", SCIPgetNRootboundChgs(subscip) );
401  }
402  if( SCIPgetNConflictConssFound(subscip) > 0 )
403  {
404  SCIPdebugMsg(scip, " - there were %" SCIP_LONGINT_FORMAT " conflict constraints created\n", SCIPgetNConflictConssApplied(subscip));
405  }
406 
407  /* set node limit to 100% */
408  SCIP_CALL( SCIPsetLongintParam(subscip, "limits/nodes", nodelimit) );
409 
410  /* solve the subproblem, abort after errors in debug mode */
411  SCIP_CALL_ABORT( SCIPsolve(subscip) );
412  }
413  else
414  {
415  SCIPdebugMsg(scip, "do not proceed solving after the first 20%% of the solution process.\n");
416  }
417 
418  #ifdef SCIP_DEBUG
419  SCIP_CALL( SCIPprintStatistics(subscip, NULL) );
420  #endif
421 
422  if( SCIPallowStrongDualReds(scip) )
423  disabledualreductions = FALSE;
424  else
425  disabledualreductions = TRUE;
426 
427  /* check, whether a solution was found */
428  if( sepadata->applyprimalsol && SCIPgetNSols(subscip) > 0 )
429  {
430  SCIP_SOL** subsols;
431  int nsubsols;
432 
433  /* check, whether a solution was found;
434  * due to numerics, it might happen that not all solutions are feasible -> try all solutions until was declared to be feasible
435  */
436  nsubsols = SCIPgetNSols(subscip);
437  subsols = SCIPgetSols(subscip);
438  soladded = FALSE;
439 
440  /* try adding solution from subSCIP to SCIP, until finding one that is accepted */
441  for( i = 0; i < nsubsols && !soladded; ++i )
442  {
443  SCIP_SOL* newsol;
444 
445  SCIP_CALL( SCIPtranslateSubSol(scip, subscip, subsols[i], NULL, subvars, &newsol) );
446  SCIP_CALL( SCIPtrySolFree(scip, &newsol, FALSE, FALSE, TRUE, TRUE, TRUE, &soladded) );
447  }
448  if( !soladded || !SCIPisEQ(scip, SCIPgetSolOrigObj(subscip, subsols[i-1]), SCIPgetSolOrigObj(subscip, subsols[0])) )
449  disabledualreductions = TRUE;
450  }
451 
452  /* if the sub problem was solved completely, we update the dual bound */
453  dualboundchg = FALSE;
454  if( sepadata->applysolved && !disabledualreductions
456  {
457  /* we need to multiply the dualbound with the scaling factor and add the offset,
458  * because this information has been disregarded in the sub-SCIP
459  */
460  SCIPdebugMsg(scip, "Update old dualbound %g to new dualbound %g.\n",
461  SCIPgetDualbound(scip), SCIPretransformObj(scip, SCIPgetDualbound(subscip)));
462 
464  dualboundchg = TRUE;
465  }
466 
467  /* check, whether conflicts were created */
468  nconflicts = 0;
469  if( sepadata->applyconflicts && !disabledualreductions && SCIPgetNConflictConssApplied(subscip) > 0 )
470  {
471  SCIP_HASHMAP* consmap;
472  int hashtablesize;
473  int nmaxconfs;
474 
475  assert(SCIPgetNConflictConssApplied(subscip) < (SCIP_Longint) INT_MAX);
476  hashtablesize = (int) SCIPgetNConflictConssApplied(subscip);
477  assert(hashtablesize < INT_MAX/5);
478 
479  /* create the variable mapping hash map */
480  SCIP_CALL( SCIPhashmapCreate(&consmap, SCIPblkmem(scip), hashtablesize) );
481 
482  SCIP_CALL( SCIPgetIntParam(scip, "conflict/maxconss", &nmaxconfs) );
483  if( global )
484  nmaxconfs *= 20;
485 
486  /* loop over all constraint handlers that might contain conflict constraints
487  * @todo select promising constraints and not greedy
488  */
489  for( i = 0; i < nconshdlrs && nconflicts < nmaxconfs; ++i)
490  {
491  /* copy constraints that have been created in FD run */
492  if( conshdlrs[i] != NULL && SCIPconshdlrGetNConss(conshdlrs[i]) > oldnconss[i] )
493  {
494  SCIP_CONS** conss;
495  int c;
496  int nconss;
497 
498  nconss = SCIPconshdlrGetNConss(conshdlrs[i]);
499  conss = SCIPconshdlrGetConss(conshdlrs[i]);
500 
501  /* loop over all constraints that have been added in sub-SCIP run, these are the conflicts */
502  for( c = oldnconss[i]; c < nconss && nconflicts < nmaxconfs; ++c)
503  {
504  SCIP_CONS* cons;
505  SCIP_CONS* conscopy;
506 
507  cons = conss[c];
508  assert(cons != NULL);
509 
510  success = FALSE;
511 
512  /* @todo assert that flags are as they should be for conflicts */
513  SCIP_CALL( SCIPgetConsCopy(subscip, scip, cons, &conscopy, conshdlrs[i], varmapbw, consmap, NULL,
515  SCIPconsIsPropagated(cons), !global, FALSE, SCIPconsIsDynamic(cons),
516  SCIPconsIsRemovable(cons), FALSE, TRUE, &success) );
517 
518  if( success )
519  {
520  nconflicts++;
521 
522  SCIP_CALL( SCIPaddConflict(scip, global ? NULL : SCIPgetCurrentNode(scip), conscopy, NULL,
524  }
525  else
526  {
527  SCIPdebugMsg(scip, "failed to copy conflict constraint %s back to original SCIP\n", SCIPconsGetName(cons));
528  }
529  }
530  }
531  }
532  SCIPhashmapFree(&consmap);
533  }
534 
535  /* check, whether tighter (global) bounds were detected */
536  cutoff = FALSE;
537  nbdchgs = 0;
538  if( sepadata->applybdchgs && !disabledualreductions )
539  {
540  for( i = 0; i < nvars; ++i )
541  {
542  SCIP_Bool tightened;
543 
544  if( subvars[i] == NULL )
545  continue;
546 
547  assert(SCIPisLE(scip, SCIPvarGetLbGlobal(vars[i]), SCIPvarGetLbGlobal(subvars[i])));
548  assert(SCIPisLE(scip, SCIPvarGetLbGlobal(subvars[i]), SCIPvarGetUbGlobal(subvars[i])));
549  assert(SCIPisLE(scip, SCIPvarGetUbGlobal(subvars[i]), SCIPvarGetUbGlobal(vars[i])));
550 
551  /* update the bounds of the original SCIP, if a better bound was proven in the sub-SCIP */
552  if( global )
553  {
554 #ifndef NDEBUG
555  assert(SCIPgetEffectiveRootDepth(scip) == SCIPgetDepth(scip));
556 #else
557  if( SCIPgetEffectiveRootDepth(scip) < SCIPgetDepth(scip) )
558  return SCIP_INVALIDCALL;
559 #endif
560  tightened = FALSE;
561 
562  SCIP_CALL( SCIPtightenVarUbGlobal(scip, vars[i], SCIPvarGetUbGlobal(subvars[i]), FALSE, &cutoff, &tightened) );
563 
564  if( cutoff )
565  break;
566 
567  if( tightened )
568  nbdchgs++;
569 
570  tightened = FALSE;
571 
572  SCIP_CALL( SCIPtightenVarLbGlobal(scip, vars[i], SCIPvarGetLbGlobal(subvars[i]), FALSE, &cutoff, &tightened) );
573 
574  if( cutoff )
575  break;
576 
577  if( tightened )
578  nbdchgs++;
579  }
580  else
581  {
582  tightened = FALSE;
583 
584  SCIP_CALL( SCIPtightenVarUb(scip, vars[i], SCIPvarGetUbGlobal(subvars[i]), FALSE, &cutoff, &tightened) );
585 
586  if( cutoff )
587  break;
588 
589  if( tightened )
590  nbdchgs++;
591 
592  tightened = FALSE;
593 
594  SCIP_CALL( SCIPtightenVarLb(scip, vars[i], SCIPvarGetLbGlobal(subvars[i]), FALSE, &cutoff, &tightened) );
595 
596  if( cutoff )
597  break;
598 
599  if( tightened )
600  nbdchgs++;
601  }
602  }
603  }
604 
605  /* install start values for inference branching */
606  /* @todo use different nbranching counters for pseudo cost and inference values and update inference values in the tree */
607  if( sepadata->applyinfervals && global && (!sepadata->reducedinfer || soladded || nbdchgs + nconflicts > 0) )
608  {
609  for( i = 0; i < nvars; ++i )
610  {
611  SCIP_Real downinfer;
612  SCIP_Real upinfer;
613  SCIP_Real downvsids;
614  SCIP_Real upvsids;
615  SCIP_Real downconflen;
616  SCIP_Real upconflen;
617 
618  if( subvars[i] == NULL )
619  continue;
620 
621  /* copy downwards branching statistics */
622  downvsids = SCIPgetVarVSIDS(subscip, subvars[i], SCIP_BRANCHDIR_DOWNWARDS);
623  downconflen = SCIPgetVarAvgConflictlength(subscip, subvars[i], SCIP_BRANCHDIR_DOWNWARDS);
624  downinfer = SCIPgetVarAvgInferences(subscip, subvars[i], SCIP_BRANCHDIR_DOWNWARDS);
625 
626  /* copy upwards branching statistics */
627  upvsids = SCIPgetVarVSIDS(subscip, subvars[i], SCIP_BRANCHDIR_UPWARDS);
628  upconflen = SCIPgetVarAvgConflictlength(subscip, subvars[i], SCIP_BRANCHDIR_UPWARDS);
629  upinfer = SCIPgetVarAvgInferences(subscip, subvars[i], SCIP_BRANCHDIR_UPWARDS);
630 
631 #ifdef SCIP_DEBUG
632  /* memorize statistics */
633  if( downinfer+downconflen+downvsids > 0.0 || upinfer+upconflen+upvsids != 0 )
634  n1startinfers++;
635 
636  if( downinfer+downconflen+downvsids > 0.0 && upinfer+upconflen+upvsids != 0 )
637  n2startinfers++;
638 #endif
639 
640  SCIP_CALL( SCIPinitVarBranchStats(scip, vars[i], 0.0, 0.0, downvsids, upvsids, downconflen, upconflen, downinfer, upinfer, 0.0, 0.0) );
641  }
642  }
643 
644 #ifdef SCIP_DEBUG
645  if( cutoff )
646  {
647  SCIPdebugMsg(scip, "Rapidlearning detected %s infeasibility.\n", global ? "global" : "local");
648  }
649 
650  SCIPdebugMsg(scip, "Rapidlearning added %d %s conflicts, changed %d bounds, %s primal solution, %s dual bound improvement.\n",
651  nconflicts, global ? "global" : "local", nbdchgs, soladded ? "found" : "no", dualboundchg ? "found" : "no");
652 
653  SCIPdebugMsg(scip, "YYY Infervalues initialized on one side: %5.2f %% of variables, %5.2f %% on both sides\n",
654  100.0 * n1startinfers/(SCIP_Real)nvars, 100.0 * n2startinfers/(SCIP_Real)nvars);
655 #endif
656 
657  /* change result pointer */
658  if( cutoff )
659  *result = SCIP_CUTOFF;
660  else if( nconflicts > 0 || dualboundchg )
661  *result = SCIP_CONSADDED;
662  else if( nbdchgs > 0 )
663  *result = SCIP_REDUCEDDOM;
664 
665  /* free local data */
666  assert(oldnconss != NULL);
667  assert(conshdlrs != NULL);
668  assert(varmapbw != NULL);
669  SCIPfreeBufferArray(scip, &oldnconss);
670  SCIPfreeBufferArray(scip, &conshdlrs);
671  SCIPhashmapFree(&varmapbw);
672 
673  /* free subproblem */
674  SCIPfreeBufferArray(scip, &subvars);
675 
676  return SCIP_OKAY;
677 }
678 
679 /** returns whether rapid learning is allowed to run locally */
680 static
682  SCIP* scip, /**< SCIP data structure */
683  SCIP_SEPADATA* sepadata, /**< separator's private data */
684  SCIP_Bool* run /**< pointer to store whether rapid learning is allowed to run */
685  )
686 {
687  assert(scip != NULL);
688  assert(sepadata != NULL);
689 
690  *run = FALSE;
691 
692  /* return TRUE if local exec should not be checked */
693  if( !sepadata->checkexec )
694  {
695  *run = TRUE;
696  }
697 
698  /* problem has zero objective function, i.e., it is a pure feasibility problem */
699  if( !(*run) && sepadata->checkobj && SCIPgetNObjVars(scip) == 0 )
700  {
701  SCIPdebugMsg(scip, "-> allow local rapid learning due to global zero objective\n");
702 
703  *run = TRUE;
704  }
705 
706  /* check whether a solution was found */
707  if( !(*run) && sepadata->checknsols && SCIPgetNSolsFound(scip) == 0 )
708  {
709  SCIPdebugMsg(scip, "-> allow local rapid learning due to no solution found so far\n");
710 
711  *run = TRUE;
712  }
713 
714  /* check whether the dual bound has not changed since the root node */
715  if( !(*run) && sepadata->checkdualbound && sepadata->nwaitingnodes < SCIPgetNNodes(scip) )
716  {
717  SCIP_Real rootdualbound;
718  SCIP_Real locdualbound;
719 
720  rootdualbound = SCIPgetLowerboundRoot(scip);
721  locdualbound = SCIPgetLocalLowerbound(scip);
722 
723  if( SCIPisEQ(scip, rootdualbound, locdualbound) )
724  {
725  SCIPdebugMsg(scip, "-> allow local rapid learning due to equal dualbound\n");
726 
727  *run = TRUE;
728  }
729  }
730 
731  /* check leaf nodes */
732  if( !(*run) && sepadata->checkleaves )
733  {
734  SCIP_Real ratio = (SCIPgetNInfeasibleLeaves(scip) + 1.0) / (SCIPgetNObjlimLeaves(scip) + 1.0);
735 
736  if( SCIPisLE(scip, sepadata->mininflpratio, ratio) )
737  {
738  SCIPdebugMsg(scip, "-> allow local rapid learning due to inf/obj leaves ratio\n");
739 
740  *run = TRUE;
741  }
742  }
743 
744  /* check whether all undecided integer variables have zero objective coefficient */
745  if( !(*run) && sepadata->checkobj )
746  {
747  SCIP_Bool allzero;
748  SCIP_VAR** vars;
749  int ndiscvars;
750  int i;
751 
752  allzero = TRUE;
753  vars = SCIPgetVars(scip);
754  ndiscvars = SCIPgetNBinVars(scip) + SCIPgetNIntVars(scip) + SCIPgetNImplVars(scip);
755 
756  for( i = 0; i < ndiscvars; i++ )
757  {
758  assert(SCIPvarIsIntegral(vars[i]));
759 
760  /* skip locally fixed variables */
761  if( SCIPisEQ(scip, SCIPvarGetLbLocal(vars[i]), SCIPvarGetUbLocal(vars[i])) )
762  continue;
763 
764  if( !SCIPisZero(scip, SCIPvarGetObj(vars[i])) )
765  {
766  allzero = FALSE;
767  break;
768  }
769  }
770 
771  if( allzero )
772  {
773  SCIPdebugMsg(scip, "-> allow local rapid learning due to local zero objective\n");
774 
775  *run = TRUE;
776  }
777  }
778 
779  /* check degeneracy */
780  if( !(*run) && sepadata->checkdegeneracy )
781  {
782  SCIP_Real degeneracy;
783  SCIP_Real varconsratio;
784 
785  SCIP_CALL( SCIPgetLPDualDegeneracy(scip, &degeneracy, &varconsratio) );
786 
787  SCIPdebugMsg(scip, "degeneracy: %.2f ratio: %.2f\n", degeneracy, varconsratio);
788 
789  if( degeneracy >= sepadata->mindegeneracy || varconsratio >= sepadata->minvarconsratio )
790  {
791  SCIPdebugMsg(scip, "-> allow local rapid learning due to degeneracy\n");
792 
793  *run = TRUE;
794  }
795  }
796 
797  return SCIP_OKAY;
798 }
799 
800 /** LP solution separation method of separator */
801 static
802 SCIP_DECL_SEPAEXECLP(sepaExeclpRapidlearning)
803 {/*lint --e{715}*/
804  SCIP_VAR** vars;
805  SCIP* subscip;
806  SCIP_SEPADATA* sepadata;
807  SCIP_Bool global;
809  SCIP_Bool success;
810  SCIP_RETCODE retcode;
811  int ndiscvars;
812  int i;
813 
814  assert(sepa != NULL);
815  assert(scip != NULL);
816  assert(result != NULL);
817 
818  *result = SCIP_DIDNOTRUN;
819 
820  ndiscvars = SCIPgetNBinVars(scip) + SCIPgetNIntVars(scip) + SCIPgetNImplVars(scip);
821 
822  /* only run when still not fixed binary variables exists */
823  if( ndiscvars == 0 )
824  return SCIP_OKAY;
825 
826  /* get separator's data */
827  sepadata = SCIPsepaGetData(sepa);
828  assert(sepadata != NULL);
829 
830  /* call separator at most maxcalls times */
831  if( SCIPsepaGetNCalls(sepa) >= sepadata->maxcalls )
832  return SCIP_OKAY;
833 
834  /* only run for integer programs */
835  if( !sepadata->contvars && ndiscvars != SCIPgetNVars(scip) )
836  return SCIP_OKAY;
837 
838  /* only run if there are few enough continuous variables */
839  if( sepadata->contvars && SCIPgetNContVars(scip) > sepadata->contvarsquot * SCIPgetNVars(scip) )
840  return SCIP_OKAY;
841 
842  /* do not run if pricers are present */
843  if( SCIPgetNActivePricers(scip) > 0 )
844  return SCIP_OKAY;
845 
846  /* if the separator should be exclusive to the root node, this prevents multiple calls due to restarts */
847  if( SCIPsepaGetFreq(sepa) == 0 && SCIPsepaGetNCalls(sepa) > 0 )
848  return SCIP_OKAY;
849 
850  /* call separator at most once per node */
851  if( SCIPsepaGetNCallsAtNode(sepa) > 0 )
852  return SCIP_OKAY;
853 
854  /* the information deduced from rapid learning is globally valid only if we are at the root node; thus we can't use
855  * the depth argument of the callback
856  */
857  global = (SCIPgetDepth(scip) <= SCIPgetEffectiveRootDepth(scip));
858 
859  /* check if rapid learning should be applied locally */
860  SCIP_CALL( checkExec(scip, sepadata, &run) );
861 
862  /* @todo check whether we want to run at the root node again, e.g., inf/obj ratio is large enough */
863  if( !run )
864  return SCIP_OKAY;
865 
866  /* do not call rapid learning, if the problem is too big */
867  if( SCIPgetNVars(scip) > sepadata->maxnvars || SCIPgetNConss(scip) > sepadata->maxnconss )
868  return SCIP_OKAY;
869 
870  if( SCIPisStopped(scip) )
871  return SCIP_OKAY;
872 
873  /* check whether there is enough time and memory left */
874  SCIP_CALL( SCIPcheckCopyLimits(scip, &success) );
875 
876  if( !success)
877  return SCIP_OKAY;
878 
879  /* skip rapid learning when the sub-SCIP would contain an integer variable with an infinite bound in direction of the
880  * objective function; this might lead to very bad branching decisions when enforcing a pseudo solution (#1439)
881  */
882  vars = SCIPgetVars(scip);
883  for( i = SCIPgetNBinVars(scip); i < ndiscvars; i++ )
884  {
885  SCIP_Real lb = SCIPvarGetLbLocal(vars[i]);
886  SCIP_Real ub = SCIPvarGetUbLocal(vars[i]);
887  SCIP_Real obj = SCIPvarGetObj(vars[i]);
888 
889  if( (SCIPisNegative(scip, obj) && SCIPisInfinity(scip, ub))
890  || (SCIPisPositive(scip, obj) && SCIPisInfinity(scip, -lb)) )
891  {
892  SCIPdebugMsg(scip, "unbounded integer variable %s (in [%g,%g]) with objective %g -> skip rapid learning\n",
893  SCIPvarGetName(vars[i]), lb, ub, obj);
894  return SCIP_OKAY;
895  }
896  }
897 
898  *result = SCIP_DIDNOTFIND;
899 
900  SCIP_CALL( SCIPcreate(&subscip) );
901 
902  retcode = setupAndSolveSubscipRapidlearning(scip, subscip, sepadata, (int)SCIPsepaGetNCalls(sepa)+1, global, result);
903 
904  SCIP_CALL( SCIPfree(&subscip) );
905 
906  return retcode;
907 }
908 
909 
910 /*
911  * separator specific interface methods
912  */
913 
914 /** creates the rapidlearning separator and includes it in SCIP */
916  SCIP* scip /**< SCIP data structure */
917  )
918 {
919  SCIP_SEPADATA* sepadata;
920  SCIP_SEPA* sepa;
922  /* create rapidlearning separator data */
923  SCIP_CALL( SCIPallocBlockMemory(scip, &sepadata) );
924 
925  /* include separator */
928  sepaExeclpRapidlearning, NULL,
929  sepadata) );
930 
931  assert(sepa != NULL);
932 
933  /* set non-NULL pointers to callback methods */
934  SCIP_CALL( SCIPsetSepaCopy(scip, sepa, sepaCopyRapidlearning) );
935  SCIP_CALL( SCIPsetSepaFree(scip, sepa, sepaFreeRapidlearning) );
936 
937  /* add rapidlearning separator parameters */
938  SCIP_CALL( SCIPaddBoolParam(scip, "separating/" SEPA_NAME "/applyconflicts",
939  "should the found conflicts be applied in the original SCIP?",
940  &sepadata->applyconflicts, TRUE, DEFAULT_APPLYCONFLICTS, NULL, NULL) );
941 
942  SCIP_CALL( SCIPaddBoolParam(scip, "separating/" SEPA_NAME "/applybdchgs",
943  "should the found global bound deductions be applied in the original SCIP?",
944  &sepadata->applybdchgs, TRUE, DEFAULT_APPLYBDCHGS, NULL, NULL) );
945 
946  SCIP_CALL( SCIPaddBoolParam(scip, "separating/" SEPA_NAME "/applyinfervals",
947  "should the inference values be used as initialization in the original SCIP?",
948  &sepadata->applyinfervals, TRUE, DEFAULT_APPLYINFERVALS, NULL, NULL) );
949 
950  SCIP_CALL( SCIPaddBoolParam(scip, "separating/" SEPA_NAME "/reducedinfer",
951  "should the inference values only be used when " SEPA_NAME " found other reductions?",
952  &sepadata->reducedinfer, TRUE, DEFAULT_REDUCEDINFER, NULL, NULL) );
953 
954  SCIP_CALL( SCIPaddBoolParam(scip, "separating/" SEPA_NAME "/applyprimalsol",
955  "should the incumbent solution be copied to the original SCIP?",
956  &sepadata->applyprimalsol, TRUE, DEFAULT_APPLYPRIMALSOL, NULL, NULL) );
957 
958  SCIP_CALL( SCIPaddBoolParam(scip, "separating/" SEPA_NAME "/applysolved",
959  "should a solved status be copied to the original SCIP?",
960  &sepadata->applysolved, TRUE, DEFAULT_APPLYSOLVED, NULL, NULL) );
961 
962  SCIP_CALL( SCIPaddBoolParam(scip, "separating/" SEPA_NAME "/checkdegeneracy",
963  "should local LP degeneracy be checked?",
964  &sepadata->checkdegeneracy, TRUE, DEFAULT_CHECKDEGANERACY, NULL, NULL) );
965 
966  SCIP_CALL( SCIPaddBoolParam(scip, "separating/" SEPA_NAME "/checkdualbound",
967  "should the progress on the dual bound be checked?",
968  &sepadata->checkdualbound, TRUE, DEFAULT_CHECKDUALBOUND, NULL, NULL) );
969 
970  SCIP_CALL( SCIPaddBoolParam(scip, "separating/" SEPA_NAME "/checkleaves",
971  "should the ratio of leaves proven to be infeasible and exceeding the cutoff bound be checked?",
972  &sepadata->checkleaves, TRUE, DEFAULT_CHECKLEAVES, NULL, NULL) );
973 
974  SCIP_CALL( SCIPaddBoolParam(scip, "separating/" SEPA_NAME "/checkexec",
975  "check whether rapid learning should be executed",
976  &sepadata->checkexec, TRUE, DEFAULT_CHECKEXEC, NULL, NULL) );
977 
978  SCIP_CALL( SCIPaddBoolParam(scip, "separating/" SEPA_NAME "/checkobj",
979  "should the (local) objective function be checked?",
980  &sepadata->checkobj, TRUE, DEFAULT_CHECKOBJ, NULL, NULL) );
981 
982  SCIP_CALL( SCIPaddBoolParam(scip, "separating/" SEPA_NAME "/checknsols",
983  "should the number of solutions found so far be checked?",
984  &sepadata->checknsols, TRUE, DEFAULT_CHECKNSOLS, NULL, NULL) );
985 
986  SCIP_CALL( SCIPaddBoolParam(scip, "separating/" SEPA_NAME "/contvars",
987  "should rapid learning be applied when there are continuous variables?",
988  &sepadata->contvars, TRUE, DEFAULT_CONTVARS, NULL, NULL) );
989 
990  SCIP_CALL( SCIPaddRealParam(scip, "separating/" SEPA_NAME "/contvarsquot",
991  "maximal portion of continuous variables to apply rapid learning",
992  &sepadata->contvarsquot, TRUE, DEFAULT_CONTVARSQUOT, 0.0, 1.0, NULL, NULL) );
993 
994  SCIP_CALL( SCIPaddRealParam(scip, "separating/" SEPA_NAME "/lpiterquot",
995  "maximal fraction of LP iterations compared to node LP iterations",
996  &sepadata->lpiterquot, TRUE, DEFAULT_LPITERQUOT, 0.0, SCIP_REAL_MAX, NULL, NULL) );
997 
998  SCIP_CALL( SCIPaddRealParam(scip, "separating/" SEPA_NAME "/mindegeneracy",
999  "minimal degeneracy threshold to allow local rapid learning",
1000  &sepadata->mindegeneracy, TRUE, DEFAULT_MINDEGENERACY, 0.0, 1.0, NULL, NULL) );
1001 
1002  SCIP_CALL( SCIPaddRealParam(scip, "separating/" SEPA_NAME "/mininflpratio",
1003  "minimal threshold of inf/obj leaves to allow local rapid learning",
1004  &sepadata->mininflpratio, TRUE, DEFAULT_MININFLPRATIO, 0.0, SCIP_REAL_MAX, NULL, NULL) );
1005 
1006  SCIP_CALL( SCIPaddRealParam(scip, "separating/" SEPA_NAME "/minvarconsratio",
1007  "minimal ratio of unfixed variables in relation to basis size to allow local rapid learning",
1008  &sepadata->minvarconsratio, TRUE, DEFAULT_MINVARCONSRATIO, 1.0, SCIP_REAL_MAX, NULL, NULL) );
1009 
1010  SCIP_CALL( SCIPaddIntParam(scip, "separating/" SEPA_NAME "/maxnvars",
1011  "maximum problem size (variables) for which rapid learning will be called",
1012  &sepadata->maxnvars, TRUE, DEFAULT_MAXNVARS, 0, INT_MAX, NULL, NULL) );
1013 
1014  SCIP_CALL( SCIPaddIntParam(scip, "separating/" SEPA_NAME "/maxnconss",
1015  "maximum problem size (constraints) for which rapid learning will be called",
1016  &sepadata->maxnconss, TRUE, DEFAULT_MAXNCONSS, 0, INT_MAX, NULL, NULL) );
1017 
1018  SCIP_CALL( SCIPaddIntParam(scip, "separating/" SEPA_NAME "/maxcalls",
1019  "maximum number of overall calls",
1020  &sepadata->maxcalls, TRUE, DEFAULT_MAXCALLS, 0, INT_MAX, NULL, NULL) );
1021 
1022  SCIP_CALL( SCIPaddIntParam(scip, "separating/" SEPA_NAME "/maxnodes",
1023  "maximum number of nodes considered in rapid learning run",
1024  &sepadata->maxnodes, TRUE, DEFAULT_MAXNODES, 0, INT_MAX, NULL, NULL) );
1025 
1026  SCIP_CALL( SCIPaddIntParam(scip, "separating/" SEPA_NAME "/minnodes",
1027  "minimum number of nodes considered in rapid learning run",
1028  &sepadata->minnodes, TRUE, DEFAULT_MINNODES, 0, INT_MAX, NULL, NULL) );
1029 
1030  SCIP_CALL( SCIPaddLongintParam(scip, "separating/" SEPA_NAME "/nwaitingnodes",
1031  "number of nodes that should be processed before rapid learning is executed locally based on the progress of the dualbound",
1032  &sepadata->nwaitingnodes, TRUE, DEFAULT_NWAITINGNODES, 0L, SCIP_LONGINT_MAX, NULL, NULL) );
1033 
1034  SCIP_CALL( SCIPaddBoolParam(scip, "separating/" SEPA_NAME "/copycuts",
1035  "should all active cuts from cutpool be copied to constraints in subproblem?",
1036  &sepadata->copycuts, TRUE, DEFAULT_COPYCUTS, NULL, NULL) );
1037 
1038  return SCIP_OKAY;
1039 }
enum SCIP_Result SCIP_RESULT
Definition: type_result.h:52
#define SEPA_USESSUBSCIP
int SCIPgetNIntVars(SCIP *scip)
Definition: scip_prob.c:2081
#define DEFAULT_REDUCEDINFER
SCIP_RETCODE SCIPsetSeparating(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
Definition: scip_param.c:949
SCIP_Real SCIPgetVarAvgInferences(SCIP *scip, SCIP_VAR *var, SCIP_BRANCHDIR dir)
Definition: scip_var.c:9416
SCIP_RETCODE SCIPtightenVarLb(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound, SCIP_Bool force, SCIP_Bool *infeasible, SCIP_Bool *tightened)
Definition: scip_var.c:5200
SCIP_NODE * SCIPgetCurrentNode(SCIP *scip)
Definition: scip_tree.c:82
SCIP_STAGE SCIPgetStage(SCIP *scip)
Definition: scip_general.c:356
SCIP_Bool SCIPconsIsDynamic(SCIP_CONS *cons)
Definition: cons.c:8344
#define SEPA_FREQ
SCIP_Longint SCIPgetNLPIterations(SCIP *scip)
SCIP_Bool SCIPisFeasLT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
#define DEFAULT_MINNODES
SCIP_CONSHDLR * SCIPfindConshdlr(SCIP *scip, const char *name)
Definition: scip_cons.c:877
SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
Definition: var.c:17910
SCIP_Longint SCIPgetNSolsFound(SCIP *scip)
static SCIP_RETCODE checkExec(SCIP *scip, SCIP_SEPADATA *sepadata, SCIP_Bool *run)
#define DEFAULT_CONTVARSQUOT
SCIP_Bool SCIPisPositive(SCIP *scip, SCIP_Real val)
SCIP_RETCODE SCIPgetLPDualDegeneracy(SCIP *scip, SCIP_Real *degeneracy, SCIP_Real *varconsratio)
Definition: scip_lp.c:2777
SCIP_Real SCIPvarGetLbLocal(SCIP_VAR *var)
Definition: var.c:17966
#define DEFAULT_LPITERQUOT
static SCIP_DECL_SEPAEXECLP(sepaExeclpRapidlearning)
#define DEFAULT_COPYCUTS
static SCIP_RETCODE setupAndSolveSubscipRapidlearning(SCIP *scip, SCIP *subscip, SCIP_SEPADATA *sepadata, int randseed, SCIP_Bool global, SCIP_RESULT *result)
SCIP_RETCODE SCIPgetVarsData(SCIP *scip, SCIP_VAR ***vars, int *nvars, int *nbinvars, int *nintvars, int *nimplvars, int *ncontvars)
Definition: scip_prob.c:1865
SCIP_CONS ** SCIPconshdlrGetConss(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4547
SCIP_SOL ** SCIPgetSols(SCIP *scip)
Definition: scip_sol.c:2254
#define FALSE
Definition: def.h:87
SCIP_RETCODE SCIPhashmapCreate(SCIP_HASHMAP **hashmap, BMS_BLKMEM *blkmem, int mapsize)
Definition: misc.c:3014
SCIP_Real SCIPgetVarVSIDS(SCIP *scip, SCIP_VAR *var, SCIP_BRANCHDIR dir)
Definition: scip_var.c:9174
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_RETCODE SCIPcopyLimits(SCIP *sourcescip, SCIP *targetscip)
Definition: scip_copy.c:3278
int SCIPgetNActivePricers(SCIP *scip)
Definition: scip_pricer.c:339
SCIP_Bool SCIPisNegative(SCIP *scip, SCIP_Real val)
#define TRUE
Definition: def.h:86
const char * SCIPsepaGetName(SCIP_SEPA *sepa)
Definition: sepa.c:734
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:54
SCIP_Real SCIPgetLocalLowerbound(SCIP *scip)
Definition: scip_prob.c:3584
methods commonly used by primal heuristics
SCIP_RETCODE SCIPsetPresolving(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
Definition: scip_param.c:923
SCIP_RETCODE SCIPtranslateSubSol(SCIP *scip, SCIP *subscip, SCIP_SOL *subsol, SCIP_HEUR *heur, SCIP_VAR **subvars, SCIP_SOL **newsol)
Definition: scip_copy.c:1399
#define DEFAULT_MINDEGENERACY
public methods for problem variables
SCIP_RETCODE SCIPtightenVarUb(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound, SCIP_Bool force, SCIP_Bool *infeasible, SCIP_Bool *tightened)
Definition: scip_var.c:5317
#define SCIPfreeBlockMemory(scip, ptr)
Definition: scip_mem.h:99
void * SCIPhashmapGetImage(SCIP_HASHMAP *hashmap, void *origin)
Definition: misc.c:3201
SCIP_Bool SCIPisEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
#define SCIP_LONGINT_MAX
Definition: def.h:163
#define SCIPfreeBufferArray(scip, ptr)
Definition: scip_mem.h:127
SCIP_RETCODE SCIPcreate(SCIP **scip)
Definition: scip_general.c:283
SCIP_RETCODE SCIPsetSepaCopy(SCIP *scip, SCIP_SEPA *sepa, SCIP_DECL_SEPACOPY((*sepacopy)))
Definition: scip_sepa.c:142
SCIP_RETCODE SCIPsetRealParam(SCIP *scip, const char *name, SCIP_Real value)
Definition: scip_param.c:594
SCIP_Bool SCIPconsIsRemovable(SCIP_CONS *cons)
Definition: cons.c:8354
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
Definition: scip_message.c:111
#define SCIPdebugMsg
Definition: scip_message.h:69
SCIP_RETCODE SCIPaddIntParam(SCIP *scip, const char *name, const char *desc, int *valueptr, SCIP_Bool isadvanced, int defaultvalue, int minvalue, int maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
Definition: scip_param.c:74
SCIP_RETCODE SCIPprintStatistics(SCIP *scip, FILE *file)
#define DEFAULT_CHECKDUALBOUND
int SCIPgetNContVars(SCIP *scip)
Definition: scip_prob.c:2171
SCIP_Real SCIPgetLowerboundRoot(SCIP *scip)
#define DEFAULT_APPLYCONFLICTS
SCIP_SEPADATA * SCIPsepaGetData(SCIP_SEPA *sepa)
Definition: sepa.c:624
SCIP_RETCODE SCIPchgVarType(SCIP *scip, SCIP_VAR *var, SCIP_VARTYPE vartype, SCIP_Bool *infeasible)
Definition: scip_var.c:8173
SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
Definition: var.c:17920
int SCIPsepaGetFreq(SCIP_SEPA *sepa)
Definition: sepa.c:778
SCIP_RETCODE SCIPsolve(SCIP *scip)
Definition: scip_solve.c:2613
SCIP_Bool SCIPisParamFixed(SCIP *scip, const char *name)
Definition: scip_param.c:210
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:9534
#define DEFAULT_APPLYBDCHGS
SCIP_Real SCIPgetDualbound(SCIP *scip)
#define SEPA_DELAY
int SCIPsepaGetNCallsAtNode(SCIP_SEPA *sepa)
Definition: sepa.c:871
SCIP_RETCODE SCIPsetBoolParam(SCIP *scip, const char *name, SCIP_Bool value)
Definition: scip_param.c:420
SCIP_STATUS SCIPgetStatus(SCIP *scip)
Definition: scip_general.c:474
SCIP_RETCODE SCIPpresolve(SCIP *scip)
Definition: scip_solve.c:2443
SCIP_RETCODE SCIPcopyCuts(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool global, int *ncutsadded)
Definition: scip_copy.c:2116
BMS_BLKMEM * SCIPblkmem(SCIP *scip)
Definition: scip_mem.c:48
const char * SCIPconsGetName(SCIP_CONS *cons)
Definition: cons.c:8085
SCIP_Bool SCIPconsIsPropagated(SCIP_CONS *cons)
Definition: cons.c:8304
const char * SCIPvarGetName(SCIP_VAR *var)
Definition: var.c:17251
void SCIPhashmapFree(SCIP_HASHMAP **hashmap)
Definition: misc.c:3048
void SCIPsepaSetData(SCIP_SEPA *sepa, SCIP_SEPADATA *sepadata)
Definition: sepa.c:634
int SCIPgetNRootboundChgs(SCIP *scip)
SCIP_RETCODE SCIPtightenVarLbGlobal(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound, SCIP_Bool force, SCIP_Bool *infeasible, SCIP_Bool *tightened)
Definition: scip_var.c:6225
#define NULL
Definition: lpi_spx1.cpp:155
#define DEFAULT_CHECKEXEC
#define SEPA_PRIORITY
SCIP_RETCODE SCIPgetIntParam(SCIP *scip, const char *name, int *value)
Definition: scip_param.c:260
SCIP_RETCODE SCIPunfixParam(SCIP *scip, const char *name)
Definition: scip_param.c:376
int SCIPgetEffectiveRootDepth(SCIP *scip)
Definition: scip_tree.c:118
#define SCIP_CALL(x)
Definition: def.h:384
SCIP_Real SCIPgetVarAvgConflictlength(SCIP *scip, SCIP_VAR *var, SCIP_BRANCHDIR dir)
Definition: scip_var.c:9362
SCIP_RETCODE SCIPsetEmphasis(SCIP *scip, SCIP_PARAMEMPHASIS paramemphasis, SCIP_Bool quiet)
Definition: scip_param.c:852
#define DEFAULT_MAXNCONSS
SCIP_Bool SCIPisFeasLE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
#define DEFAULT_CHECKNSOLS
#define DEFAULT_CHECKDEGANERACY
int SCIPconshdlrGetNConss(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4590
#define DEFAULT_MAXNVARS
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:1577
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_Longint SCIPsepaGetNCalls(SCIP_SEPA *sepa)
Definition: sepa.c:851
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:2951
#define SCIPallocBufferArray(scip, ptr, num)
Definition: scip_mem.h:115
#define DEFAULT_MAXCALLS
#define SCIP_Bool
Definition: def.h:84
#define DEFAULT_MININFLPRATIO
int SCIPgetNImplVars(SCIP *scip)
Definition: scip_prob.c:2126
SCIP_RETCODE SCIPsetObjlimit(SCIP *scip, SCIP_Real objlimit)
Definition: scip_prob.c:1421
int SCIPgetDepth(SCIP *scip)
Definition: scip_tree.c:661
#define MAX(x, y)
Definition: tclique_def.h:83
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:3231
#define DEFAULT_APPLYINFERVALS
SCIP_RETCODE SCIPsetIntParam(SCIP *scip, const char *name, int value)
Definition: scip_param.c:478
SCIP_Bool SCIPconsIsChecked(SCIP_CONS *cons)
Definition: cons.c:8284
SCIP_Bool SCIPconsIsInitial(SCIP_CONS *cons)
Definition: cons.c:8254
SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
Definition: var.c:17758
#define DEFAULT_MINVARCONSRATIO
SCIP_Longint SCIPgetNConflictConssFound(SCIP *scip)
int SCIPgetNSols(SCIP *scip)
Definition: scip_sol.c:2205
SCIP_RETCODE SCIPupdateLocalDualbound(SCIP *scip, SCIP_Real newbound)
Definition: scip_prob.c:3645
SCIP_Real SCIPgetSolOrigObj(SCIP *scip, SCIP_SOL *sol)
Definition: scip_sol.c:1435
int SCIPgetNObjVars(SCIP *scip)
Definition: scip_prob.c:2219
SCIP_Longint SCIPgetNConflictConssApplied(SCIP *scip)
SCIP_Longint SCIPgetNObjlimLeaves(SCIP *scip)
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
int SCIPgetNBinVars(SCIP *scip)
Definition: scip_prob.c:2036
int SCIPgetNVars(SCIP *scip)
Definition: scip_prob.c:1991
#define SCIP_REAL_MAX
Definition: def.h:178
static SCIP_DECL_SEPAFREE(sepaFreeRapidlearning)
SCIP_RETCODE SCIPsetSepaFree(SCIP *scip, SCIP_SEPA *sepa, SCIP_DECL_SEPAFREE((*sepafree)))
Definition: scip_sepa.c:158
SCIP_RETCODE SCIPincludeSepaRapidlearning(SCIP *scip)
int SCIPgetNConss(SCIP *scip)
Definition: scip_prob.c:3041
#define DEFAULT_CHECKOBJ
SCIP_Real SCIPretransformObj(SCIP *scip, SCIP_Real obj)
Definition: scip_sol.c:1567
SCIP_VAR ** SCIPgetVars(SCIP *scip)
Definition: scip_prob.c:1946
#define SCIP_Real
Definition: def.h:177
SCIP_Bool SCIPisStopped(SCIP *scip)
Definition: scip_general.c:694
#define DEFAULT_CHECKLEAVES
SCIP_Bool SCIPconsIsEnforced(SCIP_CONS *cons)
Definition: cons.c:8274
SCIP_Bool SCIPconsIsSeparated(SCIP_CONS *cons)
Definition: cons.c:8264
rapidlearning separator
#define SCIP_Longint
Definition: def.h:162
SCIP_RETCODE SCIPcheckCopyLimits(SCIP *sourcescip, SCIP_Bool *success)
Definition: scip_copy.c:3235
#define DEFAULT_APPLYPRIMALSOL
SCIP_VARTYPE SCIPvarGetType(SCIP_VAR *var)
Definition: var.c:17416
SCIP_RETCODE SCIPtransformProb(SCIP *scip)
Definition: scip_solve.c:358
SCIP_Bool SCIPisZero(SCIP *scip, SCIP_Real val)
#define SEPA_NAME
SCIP_Bool SCIPisLE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Real SCIPvarGetUbLocal(SCIP_VAR *var)
Definition: var.c:17976
SCIP_RETCODE SCIPtightenVarUbGlobal(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound, SCIP_Bool force, SCIP_Bool *infeasible, SCIP_Bool *tightened)
Definition: scip_var.c:6345
SCIP_Real SCIPgetUpperbound(SCIP *scip)
#define DEFAULT_MAXNODES
#define SEPA_DESC
SCIP_RETCODE SCIPhashmapInsert(SCIP_HASHMAP *hashmap, void *origin, void *image)
Definition: misc.c:3096
SCIPallocBlockMemory(scip, subsol))
#define DEFAULT_NWAITINGNODES
SCIP_RETCODE SCIPaddConflict(SCIP *scip, SCIP_NODE *node, SCIP_CONS *cons, SCIP_NODE *validnode, SCIP_CONFTYPE conftype, SCIP_Bool iscutoffinvolved)
Definition: scip_prob.c:3227
#define SCIP_CALL_ABORT(x)
Definition: def.h:363
#define DEFAULT_APPLYSOLVED
SCIP_VAR * SCIPvarGetTransVar(SCIP_VAR *var)
Definition: var.c:17610
SCIP_Longint SCIPgetNNodes(SCIP *scip)
SCIP_Longint SCIPgetNLPs(SCIP *scip)
SCIP_Longint SCIPgetNInfeasibleLeaves(SCIP *scip)
#define SEPA_MAXBOUNDDIST
SCIP_Bool SCIPvarIsIntegral(SCIP_VAR *var)
Definition: var.c:17442
default SCIP plugins
SCIP_Bool SCIPallowStrongDualReds(SCIP *scip)
Definition: scip_var.c:8626
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 DEFAULT_CONTVARS
SCIP_RETCODE SCIPsetSubscipsOff(SCIP *scip, SCIP_Bool quiet)
Definition: scip_param.c:874
static SCIP_DECL_SEPACOPY(sepaCopyRapidlearning)
SCIP_RETCODE SCIPsetLongintParam(SCIP *scip, const char *name, SCIP_Longint value)
Definition: scip_param.c:536
struct SCIP_SepaData SCIP_SEPADATA
Definition: type_sepa.h:43
SCIP_RETCODE SCIPaddBoolParam(SCIP *scip, const char *name, const char *desc, SCIP_Bool *valueptr, SCIP_Bool isadvanced, SCIP_Bool defaultvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
Definition: scip_param.c:48
SCIP_RETCODE SCIPfree(SCIP **scip)
Definition: scip_general.c:315