Scippy

SCIP

Solving Constraint Integer Programs

heur_lpface.c
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the program and library */
4 /* SCIP --- Solving Constraint Integer Programs */
5 /* */
6 /* Copyright (C) 2002-2022 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SCIP is distributed under the terms of the ZIB Academic License. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SCIP; see the file COPYING. If not visit scipopt.org. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file heur_lpface.c
17  * @ingroup DEFPLUGINS_HEUR
18  * @brief lpface primal heuristic that searches the optimal LP face inside a sub-MIP
19  * @author Gregor Hendel
20  */
21 
22 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
23 
24 #include "blockmemshell/memory.h"
25 #include "scip/cons_linear.h"
26 #include "scip/scipdefplugins.h"
27 #include "scip/heur_lpface.h"
28 #include "scip/pub_event.h"
29 #include "scip/pub_heur.h"
30 #include "scip/pub_lp.h"
31 #include "scip/pub_message.h"
32 #include "scip/pub_misc.h"
33 #include "scip/pub_sol.h"
34 #include "scip/pub_tree.h"
35 #include "scip/pub_var.h"
36 #include "scip/scip_branch.h"
37 #include "scip/scip_cons.h"
38 #include "scip/scip_copy.h"
39 #include "scip/scip_event.h"
40 #include "scip/scip_general.h"
41 #include "scip/scip_heur.h"
42 #include "scip/scip_lp.h"
43 #include "scip/scip_mem.h"
44 #include "scip/scip_message.h"
45 #include "scip/scip_nodesel.h"
46 #include "scip/scip_numerics.h"
47 #include "scip/scip_param.h"
48 #include "scip/scip_prob.h"
49 #include "scip/scip_sol.h"
50 #include "scip/scip_solve.h"
51 #include "scip/scip_solvingstats.h"
52 #include "scip/scip_timing.h"
53 #include "scip/scip_tree.h"
54 #include "scip/scip_var.h"
55 #include <string.h>
56 
57 #define HEUR_NAME "lpface"
58 #define HEUR_DESC "LNS heuristic that searches the optimal LP face inside a sub-MIP"
59 #define HEUR_DISPCHAR SCIP_HEURDISPCHAR_LNS
60 #define HEUR_PRIORITY -1104010
61 #define HEUR_FREQ 15
62 #define HEUR_FREQOFS 0
63 #define HEUR_MAXDEPTH -1
64 #define HEUR_TIMING SCIP_HEURTIMING_AFTERLPNODE
65 #define HEUR_USESSUBSCIP TRUE /**< does the heuristic use a secondary SCIP instance? */
66 
67 #define DEFAULT_MAXNODES 5000LL /**< maximum number of nodes to regard in the subproblem */
68 #define DEFAULT_MINNODES 50LL /**< minimum number of nodes to regard in the subproblem */
69 #define DEFAULT_MINFIXINGRATE 0.1 /**< required percentage of fixed integer variables in sub-MIP to run */
70 #define DEFAULT_NODESOFS 200LL /**< number of nodes added to the contingent of the total nodes */
71 #define DEFAULT_NODESQUOT 0.1 /**< subproblem nodes in relation to nodes of the original problem */
72 #define DEFAULT_LPLIMFAC 2.0 /**< factor by which the limit on the number of LP depends on the node limit */
73 #define DEFAULT_USELPROWS TRUE /**< should subproblem be created out of the rows in the LP rows,
74  * otherwise, the copy constructors of the constraints handlers are used */
75 #define DEFAULT_COPYCUTS TRUE /**< if uselprows == FALSE, should all active cuts from cutpool be copied
76  * to constraints in subproblem? */
77 #define DEFAULT_DUALBASISEQUATIONS FALSE /**< should the dually nonbasic rows be turned into equations? */
78 #define DEFAULT_KEEPSUBSCIP FALSE /**< should the heuristic continue solving the same sub-SCIP? */
79 #define DEFAULT_MINPATHLEN 5 /**< the minimum active search tree path length along which the lower bound
80  * hasn't changed before heuristic becomes active */
81 /* event handler properties */
82 #define EVENTHDLR_NAME "Lpface"
83 #define EVENTHDLR_DESC "LP event handler for " HEUR_NAME " heuristic"
84 
85 /*
86  * Data structures
87  */
88 
89 /** data structure to keep sub-SCIP across runs */
90 struct SubscipData
91 {
92  SCIP* subscip; /**< pointer to store sub-SCIP data structure */
93  SCIP_VAR** subvars; /**< array of variables of the sub-problem */
94  int nsubvars; /**< number of sub-problem variables */
95  SCIP_Real objbound; /**< lower bound on objective for when sub SCIP was created */
96 };
97 typedef struct SubscipData SUBSCIPDATA;
98 
99 /** primal heuristic data */
100 struct SCIP_HeurData
101 {
102  SCIP_Longint maxnodes; /**< maximum number of nodes to regard in the subproblem */
103  SCIP_Longint minnodes; /**< minimum number of nodes to regard in the subproblem */
104  SCIP_Longint nodesofs; /**< number of nodes added to the contingent of the total nodes */
105  SCIP_Longint usednodes; /**< nodes already used by lpface in earlier calls */
106  SCIP_Real nodesquot; /**< subproblem nodes in relation to nodes of the original problem */
107 
108  unsigned int nfailures; /**< number of failures since last successful call */
109  SCIP_Longint nextnodenumber; /**< number of nodes at which lpface should be called the next time */
110  SCIP_Real lastlpobjinfeas; /**< last LP objective where the sub-MIP was run to proven infeasibility */
111  SCIP_Real minfixingrate; /**< required percentage of fixed integer variables in sub-MIP to run */
112  SCIP_Real nodelimit; /**< the nodelimit employed in the current sub-SCIP, for the event handler*/
113  SCIP_Real lplimfac; /**< factor by which the limit on the number of LP depends on the node limit */
114  SCIP_Bool uselprows; /**< should subproblem be created out of the rows in the LP rows? */
115  SCIP_Bool copycuts; /**< if uselprows == FALSE, should all active cuts from cutpool be copied
116  * to constraints in subproblem? */
117  SCIP_Bool dualbasisequations; /**< should the dually nonbasic rows be turned into equations? */
118  SCIP_Bool keepsubscip; /**< should the heuristic continue solving the same sub-SCIP? */
119  char subscipobjective; /**< objective function in the sub-SCIP: (z)ero, (r)oot-LP-difference,
120  * (i)nference, LP (f)ractionality, (o)riginal */
121 
122  SCIP_STATUS submipstatus; /**< return status of the sub-MIP */
123  SCIP_Longint submipnlpiters; /**< number of LP iterations of the sub-MIP */
124  SCIP_Real submippresoltime; /**< time required to presolve the sub-MIP */
125  int nvarsfixed; /**< the number of fixed variables by the heuristic */
126  int minpathlen; /**< the minimum active search tree path length along which the lower bound
127  * hasn't changed before heuristic becomes active */
128  SUBSCIPDATA* subscipdata; /**< sub-SCIP data structure */
129 };
130 
131 /*
132  * Local methods
133  */
134 
135 /** determine variable fixings for sub-SCIP based on reduced costs */
136 static
138  SCIP* scip, /**< SCIP data structure */
139  SCIP_HEURDATA* heurdata, /**< primal heuristic data */
140  SCIP_VAR** fixvars, /**< buffer to store variables that should be fixed */
141  SCIP_Real* fixvals, /**< buffer to store corresponding fixing values */
142  int* nfixvars, /**< pointer to store number of variables that should be fixed */
143  SCIP_Bool* success /**< pointer to store whether enough integer variables were fixed */
144  )
145 {
146  SCIP_VAR** vars; /* original scip variables */
147  SCIP_Real fixingrate; /* percentage of variables that are fixed */
148  int nvars;
149  int nbinvars;
150  int nintvars;
151  int i;
152  int fixingcounter;
153 
154  /* get required data of the main scip problem */
155  SCIP_CALL( SCIPgetVarsData(scip, &vars, &nvars, &nbinvars, &nintvars, NULL, NULL) );
156 
157  fixingcounter = 0;
158 
159  assert(nvars >= nbinvars + nintvars);
160 
161  *nfixvars = 0;
162  /* loop over problem variables and fix all with nonzero reduced costs to their solution value */
163  for( i = 0; i < nvars; i++ )
164  {
165  SCIP_Real solval;
166  SCIP_COL* col;
167  SCIP_Real redcost;
168  SCIP_Real lbglobal;
169  SCIP_Real ubglobal;
170  SCIP_VAR* var;
171 
172  var = vars[i];
173 
174  /* skip non-column variables */
176  continue;
177 
178  /* skip relaxation only variables */
179  if( SCIPvarIsRelaxationOnly(var) )
180  continue;
181 
182  solval = SCIPgetSolVal(scip, NULL, var);
183  col = SCIPvarGetCol(vars[i]);
184  assert(col != NULL);
185  redcost = SCIPgetColRedcost(scip, col);
186  lbglobal = SCIPvarGetLbGlobal(var);
187  ubglobal = SCIPvarGetUbGlobal(var);
188 
189  /* fix the variable to its solution value if variable is nonbasic (i.e., at one of its bounds)
190  * with nonzero reduced costs
191  */
192  if( ! SCIPisDualfeasZero(scip, redcost) )
193  {
194  /* fix variable based on reduced cost information, respecting global bounds */
195  if( (redcost > 0 && SCIPisFeasEQ(scip, solval, lbglobal)) ||
196  (redcost < 0 && SCIPisFeasEQ(scip, solval, ubglobal)) )
197  {
198  assert(! SCIPisInfinity(scip, REALABS(solval)));
199 
200  fixvars[*nfixvars] = var;
201  fixvals[*nfixvars] = solval;
202 
203  if( SCIPvarIsIntegral(var) )
204  ++fixingcounter;
205 
206  ++(*nfixvars);
207  }
208  }
209  }
210 
211  fixingrate = (SCIP_Real)fixingcounter / (SCIP_Real)(MAX(nbinvars + nintvars, 1));
212  heurdata->nvarsfixed = fixingcounter;
213 
214  /* if all variables were fixed or amount of fixed variables is insufficient, skip residual part of
215  * subproblem creation and abort immediately
216  */
217  *success = (fixingcounter < nvars && fixingrate >= heurdata->minfixingrate);
218 
219  SCIPdebugMsg(scip, " LP face heuristic fixed %senough variables (%d out of %d)\n",
220  *success ? "": "not ", fixingcounter, nvars);
221 
222  return SCIP_OKAY;
223 }
224 
225 /** creates the rows of the subproblem */
226 static
228  SCIP* scip, /**< original SCIP data structure */
229  SCIP* subscip, /**< SCIP data structure for the subproblem */
230  SCIP_VAR** subvars, /**< the variables of the subproblem */
231  SCIP_Bool dualbasisequations /**< should the dually nonbasic rows be turned into equations? */
232  )
233 {
234  SCIP_ROW** rows; /* original scip rows */
235 
236  int nrows;
237  int i;
238 
239  /* get the rows and their number */
240  SCIP_CALL( SCIPgetLPRowsData(scip, &rows, &nrows) );
241 
242  /* copy all global rows to linear constraints, unless they contain relaxation-only variables */
243  for( i = 0; i < nrows; i++ )
244  {
245  SCIP_VAR** consvars; /* new constraint's variables */
246  SCIP_COL** cols; /* original row's columns */
247  SCIP_CONS* cons; /* new constraint */
248 
249  SCIP_Real* vals; /* variables' coefficient values of the row */
250  SCIP_Real constant; /* constant added to the row */
251  SCIP_Real lhs; /* left hand side of the row */
252  SCIP_Real rhs; /* left right side of the row */
253  SCIP_Real dualsol;
254  SCIP_Real rowsolactivity;
255  int j;
256  int nnonz;
257 
258  /* ignore rows that are only locally valid */
259  if( SCIProwIsLocal(rows[i]) )
260  continue;
261 
262  /* get the row's data */
263  constant = SCIProwGetConstant(rows[i]);
264  vals = SCIProwGetVals(rows[i]);
265  nnonz = SCIProwGetNNonz(rows[i]);
266  cols = SCIProwGetCols(rows[i]);
267 
268  /* only subtract constant if left hand side is not infinite */
269  lhs = SCIProwGetLhs(rows[i]);
270  if( ! SCIPisInfinity(scip, -lhs) )
271  lhs -= constant;
272 
273  /* only subtract constant if right hand side is not infinite */
274  rhs = SCIProwGetRhs(rows[i]);
275  if( ! SCIPisInfinity(scip, rhs) )
276  rhs -= constant;
277 
278  assert(lhs <= rhs);
279 
280  /* allocate memory array to be filled with the corresponding subproblem variables */
281  SCIP_CALL( SCIPallocBufferArray(scip, &consvars, nnonz) );
282  for( j = 0; j < nnonz; j++ )
283  {
284  consvars[j] = subvars[SCIPvarGetProbindex(SCIPcolGetVar(cols[j]))];
285  if( consvars[j] == NULL )
286  break;
287  }
288  /* skip row if not all variables are in sub-SCIP, i.e., relaxation-only variables */
289  if( j < nnonz )
290  {
291  SCIPfreeBufferArray(scip, &consvars);
292  continue;
293  }
294 
295  dualsol = SCIProwGetDualsol(rows[i]);
296  rowsolactivity = SCIPgetRowActivity(scip, rows[i]);
297 
298  /* transform into equation if the row is sharp and has a nonzero dual solution */
299  if( dualbasisequations && ! SCIPisDualfeasZero(scip, dualsol) )
300  {
301  if( dualsol > 0.0 && SCIPisFeasEQ(scip, rowsolactivity, lhs) )
302  rhs = lhs;
303  else if( dualsol < 0.0 && SCIPisFeasEQ(scip, rowsolactivity, rhs) )
304  lhs = rhs;
305  }
306 
307  /* create a new linear constraint and add it to the subproblem */
308  SCIP_CALL( SCIPcreateConsLinear(subscip, &cons, SCIProwGetName(rows[i]), nnonz, consvars, vals, lhs, rhs,
309  TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE) );
310  SCIP_CALL( SCIPaddCons(subscip, cons) );
311  SCIP_CALL( SCIPreleaseCons(subscip, &cons) );
312 
313  /* free temporary memory */
314  SCIPfreeBufferArray(scip, &consvars);
315  }
316 
317  return SCIP_OKAY;
318 }
319 
320 /** create the LP face subproblem constraints */
321 static
323  SCIP* scip, /**< original SCIP data structure */
324  SCIP* subscip, /**< SCIP data structure for the subproblem */
325  SCIP_VAR** subvars, /**< the variables of the subproblem */
326  SCIP_HEURDATA* heurdata /**< primal heuristic data */
327  )
328 {
329  SCIP_VAR** vars = SCIPgetVars(scip);
330  int nvars = SCIPgetNVars(scip);
331  SCIP_Real lowerbound;
332  SCIP_CONS* origobjcons;
333  int i;
334 #ifndef NDEBUG
335  int nobjvars = 0;
336 #endif
337 
338  /* we copy the rows of the LP, if enough variables could be fixed and we work on the MIP relaxation of the problem */
339  if( heurdata->uselprows )
340  {
341  SCIP_CALL( createRows(scip, subscip, subvars, heurdata->dualbasisequations) );
342  }
343 
344  /* add an equation that the objective function must be equal to the lower bound */
345  lowerbound = SCIPgetLowerbound(scip);
346 
347  SCIP_CALL( SCIPcreateConsLinear(subscip, &origobjcons, "objbound_of_origscip", 0, NULL, NULL, lowerbound, lowerbound,
349 
350  for( i = 0; i < nvars; ++i)
351  {
352  if( ! SCIPisZero(subscip, SCIPvarGetObj(vars[i])) )
353  {
354  assert(subvars[i] != NULL); /* a relaxation-only variable cannot have an objective coefficient */
355  SCIP_CALL( SCIPaddCoefLinear(subscip, origobjcons, subvars[i], SCIPvarGetObj(vars[i])) );
356 #ifndef NDEBUG
357  nobjvars++;
358 #endif
359  }
360  }
361  assert(nobjvars == SCIPgetNObjVars(scip));
362 
363  SCIP_CALL( SCIPaddCons(subscip, origobjcons) );
364  SCIP_CALL( SCIPreleaseCons(subscip, &origobjcons) );
365 
366  return SCIP_OKAY;
367 }
368 
369 /** updates heurdata after an unsuccessful run of lpface */
370 static
372  SCIP* scip, /**< original SCIP data structure */
373  SCIP_HEURDATA* heurdata /**< primal heuristic data */
374  )
375 {
376  /* increase number of failures, calculate next node at which lpface should be called and update actual solutions */
377  heurdata->nfailures++;
378  heurdata->nextnodenumber = (heurdata->nfailures <= 25
379  ? SCIPgetNNodes(scip) + 100*(2LL << heurdata->nfailures) /*lint !e703*/
380  : SCIP_LONGINT_MAX);
381 }
382 
383 /** calculate a node limit based on node limiting parameters of the heuristic */
384 static
386  SCIP* scip, /**< (original) SCIP data structure */
387  SCIP_HEUR* heur, /**< LP face heuristic */
388  SCIP_HEURDATA* heurdata /**< primal heuristic data */
389  )
390 {
391  SCIP_Longint nodelimit;
392 
393  /* calculate the maximal number of branching nodes until heuristic is aborted */
394  nodelimit = (SCIP_Longint)(heurdata->nodesquot * SCIPgetNNodes(scip));
395 
396  /* count the setup costs for the sub-MIP as 100 nodes */
397  nodelimit -= 100 * SCIPheurGetNCalls(heur);
398 
399  /* add the offset */
400  nodelimit += heurdata->nodesofs;
401 
402  /* subtract previously used nodes */
403  nodelimit -= heurdata->usednodes;
404 
405  /* do not use more than the maximum number of allowed nodes in one run */
406  nodelimit = MIN(nodelimit, heurdata->maxnodes);
407 
408  /* if the subscip has been kept from a previous run, add the number of already processed nodes */
409  if( heurdata->subscipdata->subscip != NULL )
410  nodelimit += SCIPgetNNodes(heurdata->subscipdata->subscip);
411 
412  return nodelimit;
413 }
414 
415 /** sets node, time, and memory limit according to the parameter settings of the heuristic */
416 static
418  SCIP* scip, /**< original SCIP data structure */
419  SCIP* subscip, /**< data structure of the sub-problem */
420  SCIP_HEUR* heur, /**< LP face heuristic */
421  SCIP_HEURDATA* heurdata, /**< heuristic data structure */
422  SCIP_Bool* success /**< did we successfully set all parameters up? */
423  )
424 {
425  SCIP_Real timelimit;
426  SCIP_Real memorylimit;
427  SCIP_Longint nodelimit;
428  SCIP_Bool avoidmemout;
429 
430  *success = TRUE;
431 
432  /* check whether there is enough time and memory left */
433  SCIP_CALL( SCIPgetRealParam(scip, "limits/time", &timelimit) );
434  SCIP_CALL( SCIPgetRealParam(scip, "limits/memory", &memorylimit) );
435  SCIP_CALL( SCIPgetBoolParam(scip, "misc/avoidmemout", &avoidmemout) );
436 
437  if( ! SCIPisInfinity(scip, timelimit) )
438  timelimit -= SCIPgetSolvingTime(scip);
439 
440  /* substract the memory already used by the main SCIP and the estimated memory usage of external software */
441  if( ! SCIPisInfinity(scip, memorylimit) )
442  {
443  memorylimit -= SCIPgetMemUsed(scip)/1048576.0;
444  memorylimit -= SCIPgetMemExternEstim(scip)/1048576.0;
445  }
446 
447  /* abort if no time is left or not enough memory (we don't abort in this case if misc_avoidmemout == FALSE)
448  * to create a copy of SCIP, including external memory usage */
449  if( timelimit <= 0.0 || (avoidmemout && memorylimit <= 2.0 * SCIPgetMemExternEstim(scip) / 1048576.0) )
450  {
451  *success = FALSE;
452  return SCIP_OKAY;
453  }
454 
455  /* calculate node limit for the subproblem */
456  nodelimit = calcNodeLimit(scip, heur, heurdata);
457 
458  /* we should have aborted the sub-SCIP procedure earlier if no additional nodes are allowed
459  * with the current parameter settings
460  */
461  assert(nodelimit > SCIPgetNNodes(subscip));
462 
463  SCIP_CALL( SCIPsetLongintParam(subscip, "limits/nodes", nodelimit) );
464  heurdata->nodelimit = nodelimit;
465 
466  /* set also the other two limits */
467  SCIP_CALL( SCIPsetRealParam(subscip, "limits/time", timelimit) );
468  SCIP_CALL( SCIPsetRealParam(subscip, "limits/memory", memorylimit) );
469 
470  return SCIP_OKAY;
471 }
472 
473 /** sets all one-time parameter settings like search strategy, but no limits */
474 static
476  SCIP* subscip /**< data structure of the sub-problem */
477  )
478 {
479  /* do not abort subproblem on CTRL-C */
480  SCIP_CALL( SCIPsetBoolParam(subscip, "misc/catchctrlc", FALSE) );
481 
482  /* for debugging lpface, enable MIP output */
483 #ifdef SCIP_DEBUG
484  SCIP_CALL( SCIPsetIntParam(subscip, "display/verblevel", 5) );
485  SCIP_CALL( SCIPsetIntParam(subscip, "display/freq", 1) );
486 #endif
487 
488  /* disable statistic timing inside sub SCIP */
489  SCIP_CALL( SCIPsetBoolParam(subscip, "timing/statistictiming", FALSE) );
490 
491  /* forbid recursive call of heuristics and separators solving subMIPs */
492  SCIP_CALL( SCIPsetSubscipsOff(subscip, TRUE) );
493 
494  /* disable expensive cutting plane separation */
496 
497  /* disable expensive presolving */
499 
500  /* use restart depth first node selection */
501  if( SCIPfindNodesel(subscip, "restartdfs") != NULL && ! SCIPisParamFixed(subscip, "nodeselection/restartdfs/stdpriority") )
502  {
503  SCIP_CALL( SCIPsetIntParam(subscip, "nodeselection/restartdfs/stdpriority", INT_MAX/4) );
504  }
505 
506  /* use inference branching */
507  if( SCIPfindBranchrule(subscip, "inference") != NULL && ! SCIPisParamFixed(subscip, "branching/inference/priority") )
508  {
509  SCIP_CALL( SCIPsetIntParam(subscip, "branching/inference/priority", INT_MAX/4) );
510  }
511 
512  /* enable conflict analysis, disable analysis of boundexceeding LPs, and restrict conflict pool */
513  if( !SCIPisParamFixed(subscip, "conflict/enable") )
514  {
515  SCIP_CALL( SCIPsetBoolParam(subscip, "conflict/enable", TRUE) );
516  }
517  if( !SCIPisParamFixed(subscip, "conflict/useboundlp") )
518  {
519  SCIP_CALL( SCIPsetCharParam(subscip, "conflict/useboundlp", 'o') );
520  }
521  if( !SCIPisParamFixed(subscip, "conflict/maxstoresize") )
522  {
523  SCIP_CALL( SCIPsetIntParam(subscip, "conflict/maxstoresize", 100) );
524  }
525 
526  return SCIP_OKAY;
527 }
528 
529 /** reset the sub-SCIP data to its default values */
530 static
531 void subscipdataReset(
532  SUBSCIPDATA* subscipdata /**< data structure of the sub-problem */
533  )
534 {
535  subscipdata->subscip = NULL;
536  subscipdata->subvars = NULL;
537  subscipdata->nsubvars = 0;
538  subscipdata->objbound = SCIP_INVALID;
539 }
540 
541 /** free the stored sub-SCIP information */
542 static
544  SCIP* scip, /**< original SCIP data structure */
545  SUBSCIPDATA* subscipdata /**< data structure of the sub-problem */
546  )
547 {
548  assert(subscipdata != NULL);
549 
550  /* free the subscipdata's scip */
551  if( subscipdata->subscip != NULL )
552  {
553  SCIP_CALL( SCIPfree(&subscipdata->subscip) );
554  }
555 
556  subscipdata->subscip = NULL;
557 
558  /* free the subscip variables */
559  if( subscipdata->subvars != NULL )
560  {
561  assert(subscipdata->nsubvars > 0);
562  SCIPfreeBlockMemoryArray(scip, &subscipdata->subvars, subscipdata->nsubvars);
563  }
564 
565  subscipdataReset(subscipdata);
566 
567  return SCIP_OKAY;
568 }
569 
570 /** store the sub-SCIP to the data structure */
571 static
573  SCIP* scip, /**< original SCIP data structure */
574  SUBSCIPDATA* subscipdata, /**< data structure of the sub-problem */
575  SCIP* subscip, /**< sub scip data structure to keep */
576  SCIP_VAR** subvars, /**< sub scip variable array in the order of the main SCIP variables */
577  int nvars /**< number of sub SCIP variables */
578  )
579 {
580  assert(scip != NULL);
581  assert(subscipdata != NULL);
582  assert(subscip != NULL);
583  assert(subvars != NULL);
584  assert(nvars == SCIPgetNVars(scip));
585 
586  assert(subscipdata->subscip == NULL);
587  assert(subscipdata->subvars == NULL);
588 
589  subscipdata->subscip = subscip;
590  SCIP_CALL( SCIPduplicateBlockMemoryArray(scip, &subscipdata->subvars, subvars, nvars) );
591  subscipdata->nsubvars = nvars;
592 
593  subscipdata->objbound = SCIPgetNodeLowerbound(scip, SCIPgetCurrentNode(scip));
594 
595  return SCIP_OKAY;
596 }
597 
598 #ifdef SCIP_DEBUG
599 /** print debug message listing solving time, nodes, and status of sub-SCIP */
600 static
601 SCIP_RETCODE subscipGetInfo(
602  SCIP* scip, /**< SCIP data structure */
603  SCIP* subscip /**< sub SCIP data */
604  )
605 {
606  SCIP_Real timelimit;
607  SCIP_Real memorylimit;
608  SCIP_Longint nodelimit;
609  SCIP_Real time;
610  SCIP_Longint nodes;
611  SCIP_STATUS status;
612 
613  SCIP_CALL( SCIPgetRealParam(subscip, "limits/time", &timelimit) );
614  SCIP_CALL( SCIPgetRealParam(subscip, "limits/memory", &memorylimit) );
615  SCIP_CALL( SCIPgetLongintParam(subscip, "limits/nodes", &nodelimit) );
616 
617  time = SCIPgetSolvingTime(subscip);
618  nodes = SCIPgetNNodes(subscip);
619  status = SCIPgetStatus(subscip);
620 
621  SCIPdebugMsg(scip, "SCIP info: Time: %.1f (Limit: %.1f) Nodes: %"SCIP_LONGINT_FORMAT" (Limit: %"SCIP_LONGINT_FORMAT") Status: %d\n",
622  time, timelimit, nodes, nodelimit, status);
623 
624  return SCIP_OKAY;
625 }
626 #endif
627 
628 /** create the objective function based on the user selection */
629 static
631  SCIP* scip, /**< SCIP data structure */
632  SCIP* subscip, /**< sub-SCIP data structure */
633  SCIP_VAR* var, /**< SCIP variable */
634  SCIP_VAR* subvar, /**< sub-SCIP variable whose objective coefficient is changed */
635  SCIP_HEURDATA* heurdata /**< heuristic data structure to control how the objective is changed */
636  )
637 {
638  SCIP_Real objcoeff;
639  SCIP_Real upfrac;
640  SCIP_Real downfrac;
641  SCIP_Real lpsolval;
642  SCIP_Real rootlpsolval;
643 
644  /* create the objective value based on the choice of the sub-SCIP objective */
645  switch( heurdata->subscipobjective )
646  {
647  /* use zero as objective function */
648  case 'z':
649  objcoeff = 0.0;
650  break;
651 
652  /* use current LP fractionality as objective */
653  case 'f':
654  lpsolval = SCIPvarGetLPSol(var);
655  downfrac = SCIPfrac(scip, lpsolval);
656  upfrac = 1.0 - downfrac;
657 
658  objcoeff = downfrac - upfrac;
659  break;
660 
661  /* use root LP solution difference */
662  case 'r':
663  lpsolval = SCIPvarGetLPSol(var);
664  rootlpsolval = SCIPvarGetRootSol(var);
665  objcoeff = rootlpsolval - lpsolval;
666  break;
667 
668  /* use average inferences */
669  case 'i':
672  break;
673 
674  /* use original objective function */
675  case 'o':
676  objcoeff = SCIPvarGetObj(var);
677  break;
678  default:
679  objcoeff = 0.0;
680  break;
681  }
682 
683  SCIP_CALL( SCIPchgVarObj(subscip, subvar, objcoeff) );
684 
685  return SCIP_OKAY;
686 }
687 
688 /* ---------------- Callback methods of event handler ---------------- */
689 
690 /** execution callback of the event handler for Lpface sub-SCIP
691  *
692  * we interrupt the solution process if we hit the LP iteration limit per node
693  */
694 static
695 SCIP_DECL_EVENTEXEC(eventExecLpface)
696 {
697  SCIP_HEURDATA* heurdata;
699  assert(eventhdlr != NULL);
700  assert(eventdata != NULL);
701  assert(strcmp(SCIPeventhdlrGetName(eventhdlr), EVENTHDLR_NAME) == 0);
702  assert(event != NULL);
703  assert(SCIPeventGetType(event) & SCIP_EVENTTYPE_LPSOLVED);
704 
705  heurdata = (SCIP_HEURDATA*)eventdata;
706  assert(heurdata != NULL);
707 
708  /* interrupt solution process of sub-SCIP */
709  if( SCIPgetNLPs(scip) > heurdata->lplimfac * heurdata->nodelimit )
710  {
711  SCIPdebugMsg(scip, "interrupt after %" SCIP_LONGINT_FORMAT " LPs\n",SCIPgetNLPs(scip));
712  SCIP_CALL( SCIPinterruptSolve(scip) );
713  }
714 
715  return SCIP_OKAY;
716 }
717 
718 /** setup and solve the subproblem and catch the return code */
719 static
721  SCIP* scip, /**< SCIP data structure */
722  SCIP* subscip, /**< sub-SCIP data structure */
723  SCIP_HEURDATA* heurdata, /**< heuristics data */
724  SCIP_VAR** subvars, /**< subproblem's variables */
725  SCIP_VAR** vars, /**< original problem's variables */
726  SCIP_VAR** fixvars, /**< variables that should be fixed */
727  SCIP_Real* fixvals, /**< corresponding fixing values */
728  int nfixvars, /**< number of variables that should be fixed */
729  int nvars /**< number of original problem's variables */
730  )
731 {
732  SCIP_HASHMAP* varmapfw = NULL; /* mapping of SCIP variables to sub-SCIP variables */
733  SCIP_Bool success;
734  int i;
735 
736  assert( subscip != NULL );
737  assert( heurdata != NULL );
738  assert( vars != NULL );
739 
740  /* create the variable hash map */
741  SCIP_CALL( SCIPhashmapCreate(&varmapfw, SCIPblkmem(subscip), nvars) );
742  success = FALSE;
743 
744  if( heurdata->uselprows )
745  {
746  SCIP_Bool valid;
747  char probname[SCIP_MAXSTRLEN];
748 
749  /* copy all plugins */
750  SCIP_CALL( SCIPcopyPlugins(scip, subscip, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
751  TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, &valid) );
752  /* get name of the original problem and add the string "_lpfacesub" */
753  (void) SCIPsnprintf(probname, SCIP_MAXSTRLEN, "%s_lpfacesub", SCIPgetProbName(scip));
754 
755  /* create the subproblem */
756  SCIP_CALL( SCIPcreateProbBasic(subscip, probname) );
757  SCIPsetSubscipDepth(subscip, SCIPgetSubscipDepth(scip) + 1);
758 
759  /* copy all variables */
760  SCIP_CALL( SCIPcopyVars(scip, subscip, varmapfw, NULL, fixvars, fixvals, nfixvars, TRUE) );
761 
762  /* copy parameter settings */
763  SCIP_CALL( SCIPcopyParamSettings(scip, subscip) );
764  }
765  else
766  {
767  SCIP_CALL( SCIPcopyConsCompression(scip, subscip, varmapfw, NULL, "lpface", fixvars, fixvals, nfixvars, TRUE, FALSE, FALSE, TRUE, &success) );
768 
769  if( heurdata->copycuts )
770  {
771  /* copies all active cuts from cutpool of sourcescip to linear constraints in targetscip */
772  SCIP_CALL( SCIPcopyCuts(scip, subscip, varmapfw, NULL, TRUE, NULL) );
773  }
774  }
775 
776  /* fill subvars array with mapping from original variables and set the objective coefficient to the desired value */
777  for( i = 0; i < nvars; i++ )
778  {
779  subvars[i] = (SCIP_VAR*) SCIPhashmapGetImage(varmapfw, vars[i]);
780 
781  if( subvars[i] != NULL )
782  {
783  SCIP_CALL( changeSubvariableObjective(scip, subscip, vars[i], subvars[i], heurdata) );
784  }
785  }
786 
787  /* free hash map */
788  SCIPhashmapFree(&varmapfw);
789 
790  /* disable output to console */
791  SCIP_CALL( SCIPsetIntParam(subscip, "display/verblevel", 0) );
792 
793  /* fix variables that are at their bounds and have nonzero reduced costs */
794  SCIP_CALL( setupSubproblem(scip, subscip, subvars, heurdata) );
795 
796  /* set up sub-SCIP parameters */
797  SCIP_CALL( setSubscipParameters(subscip) );
798 
799  return SCIP_OKAY;
800 }
801 
802 /** setup and solve the subproblem and catch the return code */
803 static
805  SCIP* scip, /**< SCIP data structure */
806  SCIP* subscip, /**< sub-SCIP data structure */
807  SCIP_HEUR* heur, /**< mutation heuristic */
808  SCIP_HEURDATA* heurdata, /**< heuristics data */
809  SCIP_VAR** subvars, /**< subproblem's variables */
810  SCIP_RESULT* result, /**< pointer to store the result */
811  SCIP_Real focusnodelb, /**< lower bound of the focus node */
812  SCIP_Bool* keepthisscip /**< should the subscip be kept or deleted? */
813  )
814 {
815  SCIP_EVENTHDLR* eventhdlr;
816  SCIP_Bool success;
817 
818  assert( scip != NULL );
819  assert( subscip != NULL );
820  assert( heur != NULL );
821  assert( heurdata != NULL );
822  assert( subvars != NULL );
823 
824  /* create event handler for LP events */
825  SCIP_CALL( SCIPincludeEventhdlrBasic(subscip, &eventhdlr, EVENTHDLR_NAME, EVENTHDLR_DESC, eventExecLpface, NULL) );
826  if( eventhdlr == NULL )
827  {
828  SCIPerrorMessage("event handler for " HEUR_NAME " heuristic not found.\n");
829  return SCIP_PLUGINNOTFOUND;
830  }
831 
832  /* determine node, memory, and time limits for the sub-SCIP. Both node and time limit change with every call to
833  * the heuristic
834  */
835  SCIP_CALL( setSubscipLimits(scip, subscip, heur, heurdata, &success) );
836 
837  /* if we did not succeed to set the limits of the subscip to let it run, we won't keep it any longer */
838  if( !success )
839  {
840  *keepthisscip = FALSE;
841 
842  return SCIP_OKAY;
843  }
844 
845  /* catch LP events of sub-SCIP */
846  SCIP_CALL( SCIPtransformProb(subscip) );
847  SCIP_CALL( SCIPcatchEvent(subscip, SCIP_EVENTTYPE_LPSOLVED, eventhdlr, (SCIP_EVENTDATA*) heurdata, NULL) );
848 
849 #ifdef WRITELPFACEPROB
850  {
851  char probfilename[] = "./lpface_prob.mps";
852  char paramfilename[] = "./lpface_prob.set";
853  SCIPinfoMessage(scip, NULL, "Writing problem and parameters to file: <%s> <%s>\n", probfilename, paramfilename);
854  SCIP_CALL( SCIPwriteOrigProblem(subscip, probfilename, NULL, FALSE) );
855  SCIP_CALL( SCIPwriteParams(subscip, paramfilename, TRUE, TRUE) );
856  }
857 #endif
858 
859  /* we must not be infeasible at this stage */
860  assert(SCIPgetStatus(subscip) != SCIP_STATUS_INFEASIBLE);
861 
862  /* solve the subproblem */
863  SCIPdebugMsg(scip, "Solve Lpface subMIP\n");
864  SCIPdebug(
865  SCIP_CALL( subscipGetInfo(scip, subscip) );
866  )
867 
868  /* Errors in solving the subproblem should not kill the overall solving process.
869  * Hence, the return code is caught and a warning is printed, only in debug mode, SCIP will stop.
870  */
871  SCIP_CALL_ABORT( SCIPsolve(subscip) );
872 
873  /* print solving statistics of subproblem if we are in SCIP's debug mode */
875 
876  /* save useful information regarding the subscip runs */
877  heurdata->usednodes += SCIPgetNNodes(subscip);
878  heurdata->submipnlpiters += SCIPgetNLPIterations(subscip);
879  heurdata->submippresoltime += SCIPgetPresolvingTime(subscip);
880  heurdata->submipstatus = SCIPgetStatus(subscip);
881 
882  /* store the focus node lower bound as infeasible to avoid running on this face again */
883  if( heurdata->submipstatus == SCIP_STATUS_INFEASIBLE )
884  {
885  heurdata->lastlpobjinfeas = focusnodelb;
886  *keepthisscip = FALSE;
887  }
888  else if( SCIPgetNSols(subscip) > 0 )
889  {
890  int solindex;
891 
892  /* check, whether a solution was found;
893  * due to numerics, it might happen that not all solutions are feasible -> try all solutions until one is accepted
894  */
895  SCIP_CALL( SCIPtranslateSubSols(scip, subscip, heur, subvars, &success, &solindex) );
896  SCIPdebugMsg(scip, "Transfer was %s successful\n", success ? "" : "not");
897 
898  /* we found an optimal solution and are done. Thus, we free the subscip immediately */
899  if( success )
900  {
901  *keepthisscip = FALSE;
902  *result = SCIP_FOUNDSOL;
903  }
904 
905  /* if solution could not be added to problem => run is counted as a failure */
906  if( ! success || solindex != SCIPsolGetIndex(SCIPgetBestSol(scip)) )
907  updateFailureStatistic(scip, heurdata);
908  }
909  else
910  {
911  /* if no new solution was found, run was a failure */
912  updateFailureStatistic(scip, heurdata);
913  }
914 
915  return SCIP_OKAY;
916 }
917 
918 /*
919  * Callback methods of primal heuristic
920  */
921 
922 /** copy method for primal heuristic plugins (called when SCIP copies plugins) */
923 static
924 SCIP_DECL_HEURCOPY(heurCopyLpface)
925 { /*lint --e{715}*/
926  assert(scip != NULL);
927  assert(heur != NULL);
928  assert(strcmp(SCIPheurGetName(heur), HEUR_NAME) == 0);
929 
930  /* call inclusion method of primal heuristic */
932 
933  return SCIP_OKAY;
934 }
935 
936 /** destructor of primal heuristic to free user data (called when SCIP is exiting) */
937 static
938 SCIP_DECL_HEURFREE(heurFreeLpface)
939 { /*lint --e{715}*/
940  SCIP_HEURDATA* heurdata;
942  assert(heur != NULL);
943  assert(scip != NULL);
944 
945  /* get heuristic data */
946  heurdata = SCIPheurGetData(heur);
947  assert(heurdata != NULL);
948 
949  /* free heuristic data */
950  SCIPfreeBlockMemory(scip, &heurdata);
951  SCIPheurSetData(heur, NULL);
952 
953  return SCIP_OKAY;
954 }
955 
956 /** initialization method of primal heuristic (called after problem was transformed) */
957 static
958 SCIP_DECL_HEURINIT(heurInitLpface)
959 { /*lint --e{715}*/
960  SCIP_HEURDATA* heurdata;
962  assert(heur != NULL);
963  assert(scip != NULL);
964 
965  /* get heuristic's data */
966  heurdata = SCIPheurGetData(heur);
967  assert(heurdata != NULL);
968 
969  /* initialize data */
970  heurdata->usednodes = 0;
971  heurdata->nfailures = 0;
972  heurdata->nextnodenumber = 0;
973 
974  heurdata->submipstatus = SCIP_STATUS_UNKNOWN;
975  heurdata->submipnlpiters = -1;
976  heurdata->submippresoltime = 0.0;
977  heurdata->nvarsfixed = -1;
978 
979  return SCIP_OKAY;
980 }
981 
982 /** solving process initialization method of primal heuristic (called when branch and bound process is about to begin) */
983 static
984 SCIP_DECL_HEURINITSOL(heurInitsolLpface)
985 { /*lint --e{715}*/
986  SCIP_HEURDATA* heurdata;
988  assert(heur != NULL);
989  assert(scip != NULL);
990 
991  /* get heuristic's data */
992  heurdata = SCIPheurGetData(heur);
993  assert(heurdata != NULL);
994 
995  /* reset the last infeasible objective because it lives in transformed space and must be invalidated at every restart */
996  heurdata->lastlpobjinfeas = -SCIPinfinity(scip);
997 
998  assert(heurdata->subscipdata == NULL);
999 
1000  /* variable order might have changed since the last run, reinitialize sub-SCIP data */
1001  SCIP_CALL( SCIPallocBlockMemory(scip, &heurdata->subscipdata) );
1002  subscipdataReset(heurdata->subscipdata);
1003 
1004  return SCIP_OKAY;
1005 }
1006 
1007 /** solving process deinitialization method of primal heuristic (called before branch and bound process is exiting) */
1008 static
1009 SCIP_DECL_HEUREXITSOL(heurExitsolLpface)
1010 { /*lint --e{715}*/
1011  SCIP_HEURDATA* heurdata;
1013  assert(heur != NULL);
1014  assert(scip != NULL);
1015 
1016  /* get heuristic's data */
1017  heurdata = SCIPheurGetData(heur);
1018  assert(heurdata != NULL);
1019 
1020  /* variable order might change after restart, free the heuristic subscipdata */
1021  assert(heurdata->keepsubscip || heurdata->subscipdata->subscip == NULL);
1022  if( heurdata->subscipdata->subscip != NULL )
1023  {
1024  /* free kept data structures first */
1025  SCIP_CALL( subscipdataFreeSubscip(scip, heurdata->subscipdata) );
1026  }
1027 
1028  /* free the sub-SCIP data structure */
1029  SCIPfreeBlockMemory(scip, &heurdata->subscipdata);
1030 
1031  return SCIP_OKAY;
1032 }
1033 
1034 #ifdef SCIP_STATISTIC
1035 /** deinitialization method of primal heuristic (called before transformed problem is freed) */
1036 static
1038 { /*lint --e{715}*/
1039  SCIP_HEURDATA* heurdata;
1040 
1041  assert(heur != NULL);
1042  assert(scip != NULL);
1043 
1044  /* get heuristic's data */
1045  heurdata = SCIPheurGetData(heur);
1046  assert(heurdata != NULL);
1047 
1049  "LP Face heuristic stats: Status: %d Nodes: %d LP iters: %d Fixed: %d Presolving time: %.2f\n",
1050  heurdata->submipstatus, heurdata->usednodes, heurdata->submipnlpiters, heurdata->nvarsfixed, heurdata->submippresoltime);
1051 
1052  return SCIP_OKAY;
1053 }
1054 #else
1055 #define heurExitLpface NULL
1056 #endif
1057 
1058 /** execution method of primal heuristic */
1059 static
1060 SCIP_DECL_HEUREXEC(heurExecLpface)
1061 { /*lint --e{715}*/
1062  SCIP* subscip; /* the subproblem created by lpface */
1063  SCIP_HEURDATA* heurdata; /* primal heuristic data */
1064  SCIP_VAR** vars; /* original problem's variables */
1065  SCIP_VAR** subvars; /* subproblem's variables */
1066  SCIP_RETCODE retcode;
1067  SCIP_Bool keepthisscip;
1068  SCIP_Real focusnodelb;
1069  SCIP_Real rootlb;
1070  SCIP_Longint nodelimit; /* node limit for the subproblem */
1071  int nvars; /* number of original problem's variables */
1072  int nbinvars;
1073  int nintvars;
1074 
1075  assert(heur != NULL);
1076  assert(scip != NULL);
1077  assert(result != NULL);
1078 
1079  /* get heuristic's data */
1080  heurdata = SCIPheurGetData(heur);
1081  assert(heurdata != NULL);
1082 
1083  *result = SCIP_DELAYED;
1084 
1085  /* we skip infeasible nodes */
1086  if( nodeinfeasible )
1087  return SCIP_OKAY;
1088 
1089  /* the node number to run the heuristic again was not yet reached */
1090  if( SCIPgetNNodes(scip) < heurdata->nextnodenumber )
1091  return SCIP_OKAY;
1092 
1093  /* do not run heuristic on nodes that were not solved to optimality */
1095  return SCIP_OKAY;
1096 
1097  /* LP face requires that the LP defines a valid lower bound for the current node */
1098  if( ! SCIPisLPRelax(scip) || ! SCIPallColsInLP(scip) )
1099  return SCIP_OKAY;
1100 
1101  assert(SCIPgetCurrentNode(scip) != NULL);
1102  focusnodelb = SCIPgetNodeLowerbound(scip, SCIPgetCurrentNode(scip));
1103 
1104  /* from the checked conditions, the LP objective should be a valid lower bound for the current node */
1105  assert(SCIPisGE(scip, focusnodelb, SCIPgetLPObjval(scip)));
1106 
1107  /* do not run if the current focus node already has a lower bound higher than the LP value at the node,
1108  * for example, due to strong branching
1109  */
1110  if( SCIPisGT(scip, focusnodelb, SCIPgetLPObjval(scip)) )
1111  return SCIP_OKAY;
1112 
1113  /* delay heuristic if the active search tree path is not deep enough */
1114  if( SCIPgetDepth(scip) < heurdata->minpathlen - 1 )
1115  return SCIP_OKAY;
1116 
1117  /* only run at lower bound defining nodes */
1118  if( SCIPisGT(scip, focusnodelb, SCIPgetLowerbound(scip)) )
1119  return SCIP_OKAY;
1120 
1121  /* only run if lower bound has increased since last LP objective where the sub-MIP was solved to infeasibility */
1122  if( SCIPisEQ(scip, heurdata->lastlpobjinfeas, focusnodelb) )
1123  return SCIP_OKAY;
1124 
1125  /* make the reasoning stronger if the objective value must be integral */
1126  if( SCIPisObjIntegral(scip)
1127  && (! SCIPisIntegral(scip, focusnodelb) || SCIPisLT(scip, focusnodelb, heurdata->lastlpobjinfeas + 1.0)) )
1128  return SCIP_OKAY;
1129 
1130  rootlb = SCIPgetLowerboundRoot(scip);
1131  assert(SCIPisLE(scip, rootlb, focusnodelb));
1132 
1133  /* if the lower bound hasn't changed since the root node, we want to run anyway, otherwise we base our decision on the
1134  * total path length of the active search tree along which the lower bound did not change anymore.
1135  */
1136  if( SCIPisLT(scip, rootlb, focusnodelb) )
1137  {
1138  SCIP_NODE* parent;
1139  int nonimprovingpathlen = 0; /* the length of the current path (in edges) along which the lower bound stayed the same */
1140 
1141  parent = SCIPnodeGetParent(SCIPgetCurrentNode(scip));
1142 
1143  /* count the path length along which the dual bound has not changed */
1144  while( SCIPisEQ(scip, SCIPnodeGetLowerbound(parent), focusnodelb) && nonimprovingpathlen < heurdata->minpathlen )
1145  {
1146  ++nonimprovingpathlen;
1147 
1148  /* we cannot hit the root node because the root lower bound is strictly smaller */
1149  assert(SCIPnodeGetParent(parent) != NULL);
1150  parent = SCIPnodeGetParent(parent);
1151  }
1152 
1153  /* we return if the nonimproving path is too short measured by the heuristic frequency */
1154  if( nonimprovingpathlen < heurdata->minpathlen )
1155  {
1156  /* we do not delay the heuristic if the path has length zero, otherwise it may be called at children so that
1157  * the path length is sufficient
1158  */
1159  if( nonimprovingpathlen == 0 )
1160  *result = SCIP_DIDNOTRUN;
1161 
1162  return SCIP_OKAY;
1163  }
1164  }
1165 
1166  *result = SCIP_DIDNOTRUN;
1167 
1168  /* calculate the maximal number of branching nodes until heuristic is aborted */
1169  nodelimit = calcNodeLimit(scip, heur, heurdata);
1170 
1171  /* check whether we have enough nodes left to call subproblem solving */
1172  if( nodelimit < heurdata->minnodes )
1173  return SCIP_OKAY;
1174 
1175  if( SCIPisStopped(scip) )
1176  return SCIP_OKAY;
1177 
1178  SCIP_CALL( SCIPgetVarsData(scip, &vars, &nvars, &nbinvars, &nintvars, NULL, NULL) );
1179  assert(nvars > 0);
1180 
1181  /* check whether discrete variables are present */
1182  if( nbinvars == 0 && nintvars == 0 )
1183  return SCIP_OKAY;
1184 
1185  *result = SCIP_DIDNOTFIND;
1186 
1187  keepthisscip = heurdata->keepsubscip;
1188 
1189  /* check if variable number increased since last call to the sub-SCIP */
1190  if( heurdata->subscipdata->subscip != NULL && heurdata->subscipdata->nsubvars != nvars )
1191  {
1192  SCIPdebugMsg(scip, "Free subscip of LP face heuristic because variable number %d changed since last call (was %d)\n",
1193  nvars, heurdata->subscipdata->nsubvars);
1194 
1195  SCIP_CALL( subscipdataFreeSubscip(scip, heurdata->subscipdata) );
1196  }
1197  else if( heurdata->subscipdata->subscip != NULL && SCIPisGT(scip, focusnodelb, heurdata->subscipdata->objbound) )
1198  {
1199  SCIPdebugMsg(scip, "Free subscip of LP face heuristic because of different dual bound: %16.9g > %16.9g\n",
1200  SCIPretransformObj(scip, focusnodelb), SCIPretransformObj(scip, heurdata->subscipdata->objbound));
1201 
1202  SCIP_CALL( subscipdataFreeSubscip(scip, heurdata->subscipdata) );
1203  }
1204 
1205  /* retrieve the sub-SCIP from the heuristic data structure */
1206  if( heurdata->subscipdata->subscip != NULL )
1207  {
1208  subscip = heurdata->subscipdata->subscip;
1209  subvars = heurdata->subscipdata->subvars;
1210  nvars = heurdata->subscipdata->nsubvars;
1211 
1212  SCIPdebug(
1213  SCIPdebugMsg(scip, "Loaded sub-SCIP from previous run:\n");
1214  SCIP_CALL( subscipGetInfo(scip, subscip) );
1215  )
1216  }
1217  else
1218  {
1219  SCIP_VAR** fixvars;
1220  SCIP_Real* fixvals;
1221  int nfixvars;
1222  SCIP_Bool success;
1223 
1224  assert(heurdata->subscipdata->subscip == NULL);
1225 
1226  /* allocate memory to hold sub-SCIP variables */
1227  SCIP_CALL( SCIPallocBufferArray(scip, &subvars, nvars) );
1228 
1229  SCIP_CALL( SCIPallocBufferArray(scip, &fixvars, nvars) );
1230  SCIP_CALL( SCIPallocBufferArray(scip, &fixvals, nvars) );
1231 
1232  SCIP_CALL( determineVariableFixings(scip, heurdata, fixvars, fixvals, &nfixvars, &success) );
1233 
1234  if( ! success )
1235  {
1236  SCIPfreeBufferArray(scip, &fixvals);
1237  SCIPfreeBufferArray(scip, &fixvars);
1238  SCIPfreeBufferArray(scip, &subvars);
1239 
1240  *result = SCIP_DIDNOTRUN;
1241  return SCIP_OKAY;
1242  }
1243 
1244  SCIPdebugMsg(scip, "Creating new sub-Problem for LP face heuristic\n");
1245 
1246  /* initialize the subproblem */
1247  SCIP_CALL( SCIPcreate(&subscip) );
1248 
1249  SCIP_CALL( setupSubscipLpface(scip, subscip, heurdata, subvars, vars, fixvars, fixvals, nfixvars, nvars) );
1250 
1251  SCIPfreeBufferArray(scip, &fixvals);
1252  SCIPfreeBufferArray(scip, &fixvars);
1253  }
1254 
1255  retcode = solveSubscipLpface(scip, subscip, heur, heurdata, subvars, result, focusnodelb, &keepthisscip);
1256 
1257  SCIP_CALL( retcode );
1258 
1259  /* free subproblem or store it for the next run of the heuristic */
1260  if( ! keepthisscip )
1261  {
1262  /* we only allocated buffer memory if no previous subscip was reinstalled */
1263  if( heurdata->subscipdata->subscip == NULL )
1264  {
1265  SCIPfreeBufferArray(scip, &subvars);
1266  SCIP_CALL( SCIPfree(&subscip) );
1267  }
1268  else
1269  SCIP_CALL( subscipdataFreeSubscip(scip, heurdata->subscipdata) );
1270 
1271  subscipdataReset(heurdata->subscipdata);
1272  }
1273  else
1274  {
1275  /* if the subscip has not yet been stored, we copy the subscip into the heuristic data to keep it for the next run */
1276  if( heurdata->subscipdata->subscip == NULL )
1277  {
1278  SCIP_CALL( subscipdataCopySubscip(scip, heurdata->subscipdata, subscip, subvars, nvars) );
1279  SCIPfreeBufferArray(scip, &subvars);
1280  }
1281  else
1282  {
1283  assert(heurdata->subscipdata->subscip == subscip);
1284  assert(heurdata->subscipdata->subvars == subvars);
1285  assert(heurdata->subscipdata->nsubvars == nvars);
1286  }
1287  }
1288 
1289  return SCIP_OKAY;
1290 }
1291 
1292 /*
1293  * primal heuristic specific interface methods
1294  */
1295 
1296 /** creates the lpface primal heuristic and includes it in SCIP */
1298  SCIP* scip /**< SCIP data structure */
1299  )
1301  SCIP_HEURDATA* heurdata;
1302  SCIP_HEUR* heur;
1303 
1304  /* create Lpface primal heuristic data */
1305  SCIP_CALL( SCIPallocBlockMemory(scip, &heurdata) );
1306 
1307  heurdata->subscipdata = NULL;
1308 
1309  /* include primal heuristic */
1310  SCIP_CALL( SCIPincludeHeurBasic(scip, &heur,
1312  HEUR_MAXDEPTH, HEUR_TIMING, HEUR_USESSUBSCIP, heurExecLpface, heurdata) );
1313 
1314  assert(heur != NULL);
1315 
1316  /* set non-NULL pointers to callback methods */
1317  SCIP_CALL( SCIPsetHeurCopy(scip, heur, heurCopyLpface) );
1318  SCIP_CALL( SCIPsetHeurFree(scip, heur, heurFreeLpface) );
1319  SCIP_CALL( SCIPsetHeurInit(scip, heur, heurInitLpface) );
1320  SCIP_CALL( SCIPsetHeurInitsol(scip, heur, heurInitsolLpface) );
1321  SCIP_CALL( SCIPsetHeurExitsol(scip, heur, heurExitsolLpface) );
1322  SCIP_CALL( SCIPsetHeurExit(scip, heur, heurExitLpface) );
1323 
1324  /* add lpface primal heuristic parameters */
1325  SCIP_CALL( SCIPaddLongintParam(scip, "heuristics/" HEUR_NAME "/nodesofs",
1326  "number of nodes added to the contingent of the total nodes",
1327  &heurdata->nodesofs, FALSE, DEFAULT_NODESOFS, 0LL, SCIP_LONGINT_MAX, NULL, NULL) );
1328 
1329  SCIP_CALL( SCIPaddLongintParam(scip, "heuristics/" HEUR_NAME "/maxnodes",
1330  "maximum number of nodes to regard in the subproblem",
1331  &heurdata->maxnodes, TRUE, DEFAULT_MAXNODES, 0LL, SCIP_LONGINT_MAX, NULL, NULL) );
1332 
1333  SCIP_CALL( SCIPaddLongintParam(scip, "heuristics/" HEUR_NAME "/minnodes",
1334  "minimum number of nodes required to start the subproblem",
1335  &heurdata->minnodes, TRUE, DEFAULT_MINNODES, 0LL, SCIP_LONGINT_MAX, NULL, NULL) );
1336 
1337  SCIP_CALL( SCIPaddRealParam(scip, "heuristics/" HEUR_NAME "/nodesquot",
1338  "contingent of sub problem nodes in relation to the number of nodes of the original problem",
1339  &heurdata->nodesquot, FALSE, DEFAULT_NODESQUOT, 0.0, 1.0, NULL, NULL) );
1340 
1341  SCIP_CALL( SCIPaddRealParam(scip, "heuristics/" HEUR_NAME "/minfixingrate",
1342  "required percentage of fixed integer variables in sub-MIP to run",
1343  &heurdata->minfixingrate, FALSE, DEFAULT_MINFIXINGRATE, 0.0, 1.0, NULL, NULL) );
1344 
1345  SCIP_CALL( SCIPaddRealParam(scip, "heuristics/" HEUR_NAME "/lplimfac",
1346  "factor by which the limit on the number of LP depends on the node limit",
1347  &heurdata->lplimfac, TRUE, DEFAULT_LPLIMFAC, 1.0, SCIP_REAL_MAX, NULL, NULL) );
1348 
1349  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/" HEUR_NAME "/uselprows",
1350  "should subproblem be created out of the rows in the LP rows?",
1351  &heurdata->uselprows, TRUE, DEFAULT_USELPROWS, NULL, NULL) );
1352 
1353  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/" HEUR_NAME "/dualbasisequations",
1354  "should dually nonbasic rows be turned into equations?",
1355  &heurdata->dualbasisequations, TRUE, DEFAULT_DUALBASISEQUATIONS, NULL, NULL) );
1356 
1357  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/" HEUR_NAME "/keepsubscip",
1358  "should the heuristic continue solving the same sub-SCIP?",
1359  &heurdata->keepsubscip, TRUE, DEFAULT_KEEPSUBSCIP, NULL, NULL) );
1360 
1361  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/" HEUR_NAME "/copycuts",
1362  "if uselprows == FALSE, should all active cuts from cutpool be copied to constraints in subproblem?",
1363  &heurdata->copycuts, TRUE, DEFAULT_COPYCUTS, NULL, NULL) );
1364 
1365  SCIP_CALL( SCIPaddCharParam(scip, "heuristics/" HEUR_NAME "/subscipobjective",
1366  "objective function in the sub-SCIP: (z)ero, (r)oot-LP-difference, (i)nference, LP (f)ractionality, (o)riginal",
1367  &heurdata->subscipobjective, TRUE, 'z', "forzi", NULL, NULL) );
1368 
1369  SCIP_CALL( SCIPaddIntParam(scip, "heuristics/" HEUR_NAME "/minpathlen",
1370  "the minimum active search tree path length along which lower bound hasn't changed before heuristic becomes active",
1371  &heurdata->minpathlen, TRUE, DEFAULT_MINPATHLEN, 0, 65531, NULL, NULL) );
1372 
1373  return SCIP_OKAY;
1374 }
enum SCIP_Result SCIP_RESULT
Definition: type_result.h:52
SCIP_RETCODE SCIPsetHeurExitsol(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEUREXITSOL((*heurexitsol)))
Definition: scip_heur.c:233
#define SCIPfreeBlockMemoryArray(scip, ptr, num)
Definition: scip_mem.h:101
SCIP_Real SCIPgetSolvingTime(SCIP *scip)
Definition: scip_timing.c:369
#define SCIP_EVENTTYPE_LPSOLVED
Definition: type_event.h:92
SCIP_RETCODE SCIPsetSeparating(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
Definition: scip_param.c:949
SCIP_Real SCIPgetVarAvgInferences(SCIP *scip, SCIP_VAR *var, SCIP_BRANCHDIR dir)
Definition: scip_var.c:9416
SCIP_Bool SCIPisFeasEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
public methods for SCIP parameter handling
SCIP_NODE * SCIPgetCurrentNode(SCIP *scip)
Definition: scip_tree.c:82
public methods for branch and bound tree
#define DEFAULT_USELPROWS
Definition: heur_lpface.c:73
SCIP_Longint SCIPgetNLPIterations(SCIP *scip)
#define EVENTHDLR_DESC
Definition: heur_lpface.c:86
public methods for node selector plugins
public methods for memory management
#define DEFAULT_NODESOFS
Definition: heur_lpface.c:70
SCIP_Real SCIPnodeGetLowerbound(SCIP_NODE *node)
Definition: tree.c:7452
SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
Definition: var.c:17910
SCIP_RETCODE SCIPgetRealParam(SCIP *scip, const char *name, SCIP_Real *value)
Definition: scip_param.c:298
#define SCIP_MAXSTRLEN
Definition: def.h:293
#define HEUR_FREQOFS
Definition: heur_lpface.c:62
SCIP_RETCODE SCIPsetHeurExit(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEUREXIT((*heurexit)))
Definition: scip_heur.c:201
int SCIProwGetNNonz(SCIP_ROW *row)
Definition: lp.c:17146
SCIP_Real SCIPgetColRedcost(SCIP *scip, SCIP_COL *col)
Definition: scip_lp.c:1145
SCIP_Bool SCIPisGE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
#define HEUR_PRIORITY
Definition: heur_lpface.c:60
public solving methods
SCIP_RETCODE SCIPincludeEventhdlrBasic(SCIP *scip, SCIP_EVENTHDLR **eventhdlrptr, const char *name, const char *desc, SCIP_DECL_EVENTEXEC((*eventexec)), SCIP_EVENTHDLRDATA *eventhdlrdata)
Definition: scip_event.c:95
public methods for timing
const char * SCIProwGetName(SCIP_ROW *row)
Definition: lp.c:17284
SCIP_NODE * SCIPnodeGetParent(SCIP_NODE *node)
Definition: tree.c:7712
static SCIP_Longint calcNodeLimit(SCIP *scip, SCIP_HEUR *heur, SCIP_HEURDATA *heurdata)
Definition: heur_lpface.c:388
#define heurExitLpface
Definition: heur_lpface.c:1058
#define DEFAULT_MAXNODES
Definition: heur_lpface.c:67
static SCIP_RETCODE determineVariableFixings(SCIP *scip, SCIP_HEURDATA *heurdata, SCIP_VAR **fixvars, SCIP_Real *fixvals, int *nfixvars, SCIP_Bool *success)
Definition: heur_lpface.c:140
SCIP_Real SCIPvarGetRootSol(SCIP_VAR *var)
Definition: var.c:13349
SCIP_RETCODE SCIPgetVarsData(SCIP *scip, SCIP_VAR ***vars, int *nvars, int *nbinvars, int *nintvars, int *nimplvars, int *ncontvars)
Definition: scip_prob.c:1865
static SCIP_RETCODE createRows(SCIP *scip, SCIP *subscip, SCIP_VAR **subvars, SCIP_Bool dualbasisequations)
Definition: heur_lpface.c:230
SCIP_Real SCIProwGetLhs(SCIP_ROW *row)
Definition: lp.c:17225
#define FALSE
Definition: def.h:87
SCIP_RETCODE SCIPhashmapCreate(SCIP_HASHMAP **hashmap, BMS_BLKMEM *blkmem, int mapsize)
Definition: misc.c:3014
void SCIPsetSubscipDepth(SCIP *scip, int newdepth)
Definition: scip_copy.c:2612
const char * SCIPeventhdlrGetName(SCIP_EVENTHDLR *eventhdlr)
Definition: event.c:315
SCIP_RETCODE SCIPincludeHeurLpface(SCIP *scip)
Definition: heur_lpface.c:1300
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
int SCIPgetSubscipDepth(SCIP *scip)
Definition: scip_copy.c:2591
SCIP_Real SCIPinfinity(SCIP *scip)
int SCIPsnprintf(char *t, int len, const char *s,...)
Definition: misc.c:10755
#define TRUE
Definition: def.h:86
#define SCIPdebug(x)
Definition: pub_message.h:84
#define HEUR_MAXDEPTH
Definition: heur_lpface.c:63
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:54
SCIP_RETCODE SCIPwriteOrigProblem(SCIP *scip, const char *filename, const char *extension, SCIP_Bool genericnames)
Definition: scip_prob.c:600
SCIP_RETCODE SCIPsetPresolving(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
Definition: scip_param.c:923
SCIP_BRANCHRULE * SCIPfindBranchrule(SCIP *scip, const char *name)
Definition: scip_branch.c:288
int SCIPvarGetProbindex(SCIP_VAR *var)
Definition: var.c:17600
SCIP_Bool SCIPisDualfeasZero(SCIP *scip, SCIP_Real val)
struct SCIP_HeurData SCIP_HEURDATA
Definition: type_heur.h:67
public methods for problem variables
#define SCIPfreeBlockMemory(scip, ptr)
Definition: scip_mem.h:99
SCIP_RETCODE SCIPincludeHeurBasic(SCIP *scip, SCIP_HEUR **heur, const char *name, const char *desc, char dispchar, int priority, int freq, int freqofs, int maxdepth, SCIP_HEURTIMING timingmask, SCIP_Bool usessubscip, SCIP_DECL_HEUREXEC((*heurexec)), SCIP_HEURDATA *heurdata)
Definition: scip_heur.c:108
#define DEFAULT_KEEPSUBSCIP
Definition: heur_lpface.c:80
SCIP_RETCODE SCIPtranslateSubSols(SCIP *scip, SCIP *subscip, SCIP_HEUR *heur, SCIP_VAR **subvars, SCIP_Bool *success, int *solindex)
Definition: scip_copy.c:1439
#define DEFAULT_NODESQUOT
Definition: heur_lpface.c:71
#define HEUR_DISPCHAR
Definition: heur_lpface.c:59
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
void SCIPheurSetData(SCIP_HEUR *heur, SCIP_HEURDATA *heurdata)
Definition: heur.c:1362
public methods for SCIP variables
SCIP_RETCODE SCIPsetRealParam(SCIP *scip, const char *name, SCIP_Real value)
Definition: scip_param.c:594
SCIP_RETCODE SCIPcopyPlugins(SCIP *sourcescip, SCIP *targetscip, SCIP_Bool copyreaders, SCIP_Bool copypricers, SCIP_Bool copyconshdlrs, SCIP_Bool copyconflicthdlrs, SCIP_Bool copypresolvers, SCIP_Bool copyrelaxators, SCIP_Bool copyseparators, SCIP_Bool copycutselectors, SCIP_Bool copypropagators, SCIP_Bool copyheuristics, SCIP_Bool copyeventhdlrs, SCIP_Bool copynodeselectors, SCIP_Bool copybranchrules, SCIP_Bool copydisplays, SCIP_Bool copydialogs, SCIP_Bool copytables, SCIP_Bool copyexprhdlrs, SCIP_Bool copynlpis, SCIP_Bool passmessagehdlr, SCIP_Bool *valid)
Definition: scip_copy.c:266
SCIP_Real SCIProwGetDualsol(SCIP_ROW *row)
Definition: lp.c:17245
#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 SCIPcopyParamSettings(SCIP *sourcescip, SCIP *targetscip)
Definition: scip_copy.c:2550
static SCIP_DECL_HEUREXITSOL(heurExitsolLpface)
Definition: heur_lpface.c:1012
SCIP_Real SCIPgetPresolvingTime(SCIP *scip)
Definition: scip_timing.c:433
SCIP_RETCODE SCIPprintStatistics(SCIP *scip, FILE *file)
SCIP_RETCODE SCIPaddCoefLinear(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Real val)
void SCIPinfoMessage(SCIP *scip, FILE *file, const char *formatstr,...)
Definition: scip_message.c:199
SCIP_RETCODE SCIPcreateProbBasic(SCIP *scip, const char *name)
Definition: scip_prob.c:171
SCIP_Real SCIPgetLowerboundRoot(SCIP *scip)
public methods for numerical tolerances
public methods for querying solving statistics
const char * SCIPgetProbName(SCIP *scip)
Definition: scip_prob.c:1066
public methods for the branch-and-bound tree
SCIP_Bool SCIPisLPRelax(SCIP *scip)
Definition: scip_lp.c:216
static SCIP_RETCODE subscipdataFreeSubscip(SCIP *scip, SUBSCIPDATA *subscipdata)
Definition: heur_lpface.c:546
SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
Definition: var.c:17920
#define SCIPduplicateBlockMemoryArray(scip, ptr, source, num)
Definition: scip_mem.h:96
static SCIP_DECL_HEURINITSOL(heurInitsolLpface)
Definition: heur_lpface.c:987
#define DEFAULT_LPLIMFAC
Definition: heur_lpface.c:72
SCIP_RETCODE SCIPsetHeurInitsol(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURINITSOL((*heurinitsol)))
Definition: scip_heur.c:217
SCIP_RETCODE SCIPsolve(SCIP *scip)
Definition: scip_solve.c:2613
const char * SCIPheurGetName(SCIP_HEUR *heur)
Definition: heur.c:1441
static SCIP_DECL_HEUREXEC(heurExecLpface)
Definition: heur_lpface.c:1063
#define SCIPerrorMessage
Definition: pub_message.h:55
SCIP_Bool SCIPisParamFixed(SCIP *scip, const char *name)
Definition: scip_param.c:210
SCIP_RETCODE SCIPaddCons(SCIP *scip, SCIP_CONS *cons)
Definition: scip_prob.c:2769
SCIP_RETCODE SCIPsetHeurFree(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURFREE((*heurfree)))
Definition: scip_heur.c:169
SCIP_Bool SCIPisLT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
public methods for event handler plugins and event handlers
SCIP_Bool SCIProwIsLocal(SCIP_ROW *row)
Definition: lp.c:17334
SCIP_RETCODE SCIPcopyVars(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_VAR **fixedvars, SCIP_Real *fixedvals, int nfixedvars, SCIP_Bool global)
Definition: scip_copy.c:1169
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 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
struct SCIP_EventData SCIP_EVENTDATA
Definition: type_event.h:164
#define DEFAULT_MINFIXINGRATE
Definition: heur_lpface.c:69
void SCIPhashmapFree(SCIP_HASHMAP **hashmap)
Definition: misc.c:3048
SCIP_RETCODE SCIPgetBoolParam(SCIP *scip, const char *name, SCIP_Bool *value)
Definition: scip_param.c:241
#define NULL
Definition: lpi_spx1.cpp:155
static void subscipdataReset(SUBSCIPDATA *subscipdata)
Definition: heur_lpface.c:534
#define REALABS(x)
Definition: def.h:201
SCIP_Real SCIPvarGetLPSol(SCIP_VAR *var)
Definition: var.c:18284
public methods for problem copies
public methods for primal CIP solutions
#define SCIP_CALL(x)
Definition: def.h:384
SCIP_Real SCIPgetLowerbound(SCIP *scip)
SCIP_Bool SCIPvarIsRelaxationOnly(SCIP_VAR *var)
Definition: var.c:17538
SCIP_Real SCIProwGetRhs(SCIP_ROW *row)
Definition: lp.c:17235
void SCIPverbMessage(SCIP *scip, SCIP_VERBLEVEL msgverblevel, FILE *file, const char *formatstr,...)
Definition: scip_message.c:216
#define DEFAULT_DUALBASISEQUATIONS
Definition: heur_lpface.c:79
SCIP_Longint SCIPheurGetNCalls(SCIP_HEUR *heur)
Definition: heur.c:1567
SCIP_RETCODE SCIPgetLongintParam(SCIP *scip, const char *name, SCIP_Longint *value)
Definition: scip_param.c:279
SCIP_COL ** SCIProwGetCols(SCIP_ROW *row)
Definition: lp.c:17171
public methods for primal heuristic plugins and divesets
public methods for constraint handler plugins and constraints
SCIP_RETCODE SCIPchgVarObj(SCIP *scip, SCIP_VAR *var, SCIP_Real newobj)
Definition: scip_var.c:4510
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
static SCIP_RETCODE setupSubscipLpface(SCIP *scip, SCIP *subscip, SCIP_HEURDATA *heurdata, SCIP_VAR **subvars, SCIP_VAR **vars, SCIP_VAR **fixvars, SCIP_Real *fixvals, int nfixvars, int nvars)
Definition: heur_lpface.c:723
#define SCIPallocBufferArray(scip, ptr, num)
Definition: scip_mem.h:115
SCIP_Real * SCIProwGetVals(SCIP_ROW *row)
Definition: lp.c:17181
#define HEUR_FREQ
Definition: heur_lpface.c:61
SCIP * subscip
Definition: heur_lpface.c:95
public data structures and miscellaneous methods
#define DEFAULT_COPYCUTS
Definition: heur_lpface.c:76
#define SCIP_Bool
Definition: def.h:84
SCIP_RETCODE SCIPcatchEvent(SCIP *scip, SCIP_EVENTTYPE eventtype, SCIP_EVENTHDLR *eventhdlr, SCIP_EVENTDATA *eventdata, int *filterpos)
Definition: scip_event.c:277
static SCIP_DECL_HEURFREE(heurFreeLpface)
Definition: heur_lpface.c:941
SCIP_LPSOLSTAT SCIPgetLPSolstat(SCIP *scip)
Definition: scip_lp.c:159
static SCIP_RETCODE setSubscipParameters(SCIP *subscip)
Definition: heur_lpface.c:478
SCIP_EVENTTYPE SCIPeventGetType(SCIP_EVENT *event)
Definition: event.c:1021
enum SCIP_Status SCIP_STATUS
Definition: type_stat.h:58
static SCIP_RETCODE changeSubvariableObjective(SCIP *scip, SCIP *subscip, SCIP_VAR *var, SCIP_VAR *subvar, SCIP_HEURDATA *heurdata)
Definition: heur_lpface.c:633
int SCIPgetDepth(SCIP *scip)
Definition: scip_tree.c:661
#define MAX(x, y)
Definition: tclique_def.h:83
SCIP_RETCODE SCIPsetIntParam(SCIP *scip, const char *name, int value)
Definition: scip_param.c:478
public methods for LP management
SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
Definition: var.c:17758
int SCIPgetNSols(SCIP *scip)
Definition: scip_sol.c:2205
#define HEUR_NAME
Definition: heur_lpface.c:57
static SCIP_RETCODE setSubscipLimits(SCIP *scip, SCIP *subscip, SCIP_HEUR *heur, SCIP_HEURDATA *heurdata, SCIP_Bool *success)
Definition: heur_lpface.c:420
SCIP_COL * SCIPvarGetCol(SCIP_VAR *var)
Definition: var.c:17621
Constraint handler for linear constraints in their most general form, .
int SCIPgetNObjVars(SCIP *scip)
Definition: scip_prob.c:2219
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
SCIP_Real objbound
Definition: heur_lpface.c:98
static SCIP_DECL_EVENTEXEC(eventExecLpface)
Definition: heur_lpface.c:698
public methods for the LP relaxation, rows and columns
SCIP_RETCODE SCIPsetCharParam(SCIP *scip, const char *name, char value)
Definition: scip_param.c:652
#define HEUR_DESC
Definition: heur_lpface.c:58
int SCIPgetNVars(SCIP *scip)
Definition: scip_prob.c:1991
static void updateFailureStatistic(SCIP *scip, SCIP_HEURDATA *heurdata)
Definition: heur_lpface.c:374
#define SCIP_REAL_MAX
Definition: def.h:178
SCIP_RETCODE SCIPcreateConsLinear(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, SCIP_Real *vals, SCIP_Real lhs, SCIP_Real rhs, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode)
SCIP_Real SCIProwGetConstant(SCIP_ROW *row)
Definition: lp.c:17191
public methods for branching rule plugins and branching
SCIP_Bool SCIPisObjIntegral(SCIP *scip)
Definition: scip_prob.c:1561
public methods for managing events
general public methods
SCIP_Real SCIPgetLPObjval(SCIP *scip)
Definition: scip_lp.c:238
SCIP_SOL * SCIPgetBestSol(SCIP *scip)
Definition: scip_sol.c:2304
SCIP_Bool SCIPisGT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisIntegral(SCIP *scip, SCIP_Real val)
SCIP_RETCODE SCIPaddCharParam(SCIP *scip, const char *name, const char *desc, char *valueptr, SCIP_Bool isadvanced, char defaultvalue, const char *allowedvalues, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
Definition: scip_param.c:158
SCIP_VAR ** subvars
Definition: heur_lpface.c:96
SCIP_VAR * SCIPcolGetVar(SCIP_COL *col)
Definition: lp.c:16975
public methods for solutions
SCIP_Longint SCIPgetMemUsed(SCIP *scip)
Definition: scip_mem.c:91
static SCIP_RETCODE setupSubproblem(SCIP *scip, SCIP *subscip, SCIP_VAR **subvars, SCIP_HEURDATA *heurdata)
Definition: heur_lpface.c:325
SCIP_RETCODE SCIPreleaseCons(SCIP *scip, SCIP_CONS **cons)
Definition: scip_cons.c:1110
#define SCIP_DECL_HEUREXIT(x)
Definition: type_heur.h:111
public methods for message output
#define DEFAULT_MINPATHLEN
Definition: heur_lpface.c:81
SCIP_RETCODE SCIPsetHeurInit(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURINIT((*heurinit)))
Definition: scip_heur.c:185
SCIP_Real SCIPretransformObj(SCIP *scip, SCIP_Real obj)
Definition: scip_sol.c:1567
SCIP_Longint SCIPgetMemExternEstim(SCIP *scip)
Definition: scip_mem.c:117
SCIP_NODESEL * SCIPfindNodesel(SCIP *scip, const char *name)
Definition: scip_nodesel.c:225
#define HEUR_TIMING
Definition: heur_lpface.c:64
SCIP_VAR ** SCIPgetVars(SCIP *scip)
Definition: scip_prob.c:1946
SCIP_VARSTATUS SCIPvarGetStatus(SCIP_VAR *var)
Definition: var.c:17370
#define EVENTHDLR_NAME
Definition: heur_lpface.c:85
#define SCIP_Real
Definition: def.h:177
static SCIP_RETCODE solveSubscipLpface(SCIP *scip, SCIP *subscip, SCIP_HEUR *heur, SCIP_HEURDATA *heurdata, SCIP_VAR **subvars, SCIP_RESULT *result, SCIP_Real focusnodelb, SCIP_Bool *keepthisscip)
Definition: heur_lpface.c:807
SCIP_Bool SCIPisStopped(SCIP *scip)
Definition: scip_general.c:694
public methods for message handling
#define SCIP_INVALID
Definition: def.h:197
#define HEUR_USESSUBSCIP
Definition: heur_lpface.c:65
#define SCIP_Longint
Definition: def.h:162
SCIP_Bool SCIPallColsInLP(SCIP *scip)
Definition: scip_lp.c:640
SCIP_Real SCIPfrac(SCIP *scip, SCIP_Real val)
static SCIP_RETCODE subscipdataCopySubscip(SCIP *scip, SUBSCIPDATA *subscipdata, SCIP *subscip, SCIP_VAR **subvars, int nvars)
Definition: heur_lpface.c:575
SCIP_Real SCIPgetNodeLowerbound(SCIP *scip, SCIP_NODE *node)
Definition: scip_prob.c:3621
SCIP_RETCODE SCIPtransformProb(SCIP *scip)
Definition: scip_solve.c:358
SCIP_Bool SCIPisZero(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisLE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_RETCODE SCIPsetHeurCopy(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURCOPY((*heurcopy)))
Definition: scip_heur.c:153
SCIP_RETCODE SCIPwriteParams(SCIP *scip, const char *filename, SCIP_Bool comments, SCIP_Bool onlychanged)
Definition: scip_param.c:783
SCIP_RETCODE SCIPinterruptSolve(SCIP *scip)
Definition: scip_solve.c:3516
public methods for primal heuristics
SCIP_RETCODE SCIPgetLPRowsData(SCIP *scip, SCIP_ROW ***rows, int *nrows)
Definition: scip_lp.c:561
SCIPallocBlockMemory(scip, subsol))
#define SCIP_CALL_ABORT(x)
Definition: def.h:363
SCIP_HEURDATA * SCIPheurGetData(SCIP_HEUR *heur)
Definition: heur.c:1352
static SCIP_DECL_HEURINIT(heurInitLpface)
Definition: heur_lpface.c:961
SCIP_Longint SCIPgetNNodes(SCIP *scip)
SCIP_Longint SCIPgetNLPs(SCIP *scip)
public methods for global and local (sub)problems
SCIP_Bool SCIPvarIsIntegral(SCIP_VAR *var)
Definition: var.c:17442
#define DEFAULT_MINNODES
Definition: heur_lpface.c:68
SCIP_Real SCIPgetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var)
Definition: scip_sol.c:1352
default SCIP plugins
int SCIPsolGetIndex(SCIP_SOL *sol)
Definition: sol.c:2635
SCIP_RETCODE SCIPaddRealParam(SCIP *scip, const char *name, const char *desc, SCIP_Real *valueptr, SCIP_Bool isadvanced, SCIP_Real defaultvalue, SCIP_Real minvalue, SCIP_Real maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
Definition: scip_param.c:130
SCIP_RETCODE SCIPsetSubscipsOff(SCIP *scip, SCIP_Bool quiet)
Definition: scip_param.c:874
SCIP_RETCODE SCIPsetLongintParam(SCIP *scip, const char *name, SCIP_Longint value)
Definition: scip_param.c:536
SCIP_RETCODE SCIPaddBoolParam(SCIP *scip, const char *name, const char *desc, SCIP_Bool *valueptr, SCIP_Bool isadvanced, SCIP_Bool defaultvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
Definition: scip_param.c:48
LNS heuristic that tries to compute integral solution on optimal LP face.
SCIP_Real SCIPgetRowActivity(SCIP *scip, SCIP_ROW *row)
Definition: scip_lp.c:2089
SCIP_RETCODE SCIPfree(SCIP **scip)
Definition: scip_general.c:315
static SCIP_DECL_HEURCOPY(heurCopyLpface)
Definition: heur_lpface.c:927
memory allocation routines