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