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