Scippy

SCIP

Solving Constraint Integer Programs

heur_locks.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_locks.c
17  * @brief rounding locks primal heuristic
18  * @author Michael Winkler
19  * @author Gerald Gamrath
20  */
21 
22 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
23 
24 #include <assert.h>
25 #include <string.h>
26 
27 #include "scip/heur_locks.h"
28 
29 #define HEUR_NAME "locks"
30 #define HEUR_DESC "heuristic that fixes variables based on their rounding locks"
31 #define HEUR_DISPCHAR 'k'
32 #define HEUR_PRIORITY 3000
33 #define HEUR_FREQ 0
34 #define HEUR_FREQOFS 0
35 #define HEUR_MAXDEPTH -1
36 #define HEUR_TIMING SCIP_HEURTIMING_BEFORENODE
37 #define HEUR_USESSUBSCIP TRUE /**< does the heuristic use a secondary SCIP instance? */
38 
39 #define DEFAULT_MAXNODES 5000LL /**< maximum number of nodes to regard in the subproblem */
40 #define DEFAULT_ROUNDUPPROBABILITY 0.67 /**< probability for rounding a variable up in case of ties */
41 #define DEFAULT_MINFIXINGRATE 0.65 /**< minimum percentage of variables that have to be fixed */
42 #define DEFAULT_MINIMPROVE 0.01 /**< factor by which locks heuristic should at least improve the
43  * incumbent
44  */
45 #define DEFAULT_MINNODES 500LL /**< minimum number of nodes to regard in the subproblem */
46 #define DEFAULT_NODESOFS 500LL /**< number of nodes added to the contingent of the total nodes */
47 #define DEFAULT_NODESQUOT 0.1 /**< subproblem nodes in relation to nodes of the original problem */
48 #define DEFAULT_MAXPROPROUNDS 2 /**< maximum number of propagation rounds during probing */
49 #define DEFAULT_UPDATELOCKS TRUE /**< should the locks be updated based on LP rows? */
50 #define DEFAULT_COPYCUTS TRUE /**< should all active cuts from the cutpool of the
51  * original scip be copied to constraints of the subscip? */
52 #define DEFAULT_USEFINALSUBMIP TRUE /**< should a final sub-MIP be solved to construct a feasible
53  * solution if the LP was not roundable? */
54 #define DEFAULT_RANDSEED 73 /**< initial random seed */
55 
56 /** primal heuristic data */
57 struct SCIP_HeurData
58 {
59  SCIP_RANDNUMGEN* randnumgen; /**< random number generation */
60  SCIP_Longint maxnodes; /**< maximum number of nodes to regard in the subproblem */
61  SCIP_Longint minnodes; /**< minimum number of nodes to regard in the subproblem */
62  SCIP_Longint nodesofs; /**< number of nodes added to the contingent of the total nodes */
63  SCIP_Longint usednodes; /**< nodes already used by locks heuristic in earlier calls */
64  SCIP_Real roundupprobability; /**< probability for rounding a variable up in case of ties */
65  SCIP_Real minfixingrate; /**< minimum percentage of variables that have to be fixed */
66  SCIP_Real minimprove; /**< factor by which locks heuristic should at least improve the incumbent */
67  SCIP_Real nodesquot; /**< subproblem nodes in relation to nodes of the original problem */
68  int maxproprounds; /**< maximum number of propagation rounds during probing */
69  SCIP_Bool updatelocks; /**< should the locks be updated based on LP rows? */
70  SCIP_Bool copycuts; /**< should all active cuts from cutpool be copied to constraints in
71  * the subproblem? */
72  SCIP_Bool usefinalsubmip; /**< should a final sub-MIP be solved to costruct a feasible solution if
73  * the LP was not roundable? */
74 };
75 
76 /*
77  * Local methods
78  */
79 
80 /** creates a new solution for the original problem by copying the solution of the subproblem */
81 static
83  SCIP* scip, /**< original SCIP data structure */
84  SCIP* subscip, /**< SCIP structure of the subproblem */
85  SCIP_VAR** subvars, /**< the variables of the subproblem */
86  SCIP_SOL* newsol, /**< working solution */
87  SCIP_SOL* subsol, /**< solution of the subproblem */
88  SCIP_Bool* success /**< used to store whether new solution was found or not */
89  )
90 {
91  SCIP_VAR** vars; /* the original problem's variables */
92  int nvars;
93  SCIP_Real* subsolvals; /* solution values of the subproblem */
94 
95  assert(scip != NULL);
96  assert(subscip != NULL);
97  assert(subvars != NULL);
98  assert(subsol != NULL);
99  assert(success != NULL);
100 
101  /* get variables' data */
102  SCIP_CALL( SCIPgetVarsData(scip, &vars, &nvars, NULL, NULL, NULL, NULL) );
103 
104  /* sub-SCIP may have more variables than the number of active (transformed) variables in the main SCIP
105  * since constraint copying may have required the copy of variables that are fixed in the main SCIP
106  */
107  assert(nvars <= SCIPgetNOrigVars(subscip));
108 
109  SCIP_CALL( SCIPallocBufferArray(scip, &subsolvals, nvars) );
110 
111  /* copy the solution */
112  SCIP_CALL( SCIPgetSolVals(subscip, subsol, nvars, subvars, subsolvals) );
113 
114  SCIP_CALL( SCIPsetSolVals(scip, newsol, nvars, vars, subsolvals) );
115 
116  /* try to add new solution to scip and free it immediately */
117  SCIP_CALL( SCIPtrySol(scip, newsol, FALSE, FALSE, TRUE, TRUE, TRUE, success) );
118 
119  SCIPfreeBufferArray(scip, &subsolvals);
120 
121  return SCIP_OKAY;
122 }
123 
124 /** copy method for primal heuristic plugins (called when SCIP copies plugins) */
125 static
126 SCIP_DECL_HEURCOPY(heurCopyLocks)
127 { /*lint --e{715}*/
128  assert(scip != NULL);
129  assert(heur != NULL);
130  assert(strcmp(SCIPheurGetName(heur), HEUR_NAME) == 0);
131 
132  /* call inclusion method of primal heuristic */
134 
135  return SCIP_OKAY;
136 }
137 
138 /** free method for primal heuristic plugins (called when SCIP is exiting) */
139 static
140 SCIP_DECL_HEURFREE(heurFreeLocks)
141 { /*lint --e{715}*/
142  SCIP_HEURDATA* heurdata;
143 
144  assert(scip != NULL);
145  assert(heur != NULL);
146  assert(strcmp(SCIPheurGetName(heur), HEUR_NAME) == 0);
147 
148  heurdata = SCIPheurGetData(heur);
149 
150  /* free primal heuristic data */
151  SCIPfreeBlockMemory(scip, &heurdata);
152 
153  return SCIP_OKAY;
154 }
155 
156 /** initialization method of primal heuristic (called after problem was transformed) */
157 static
158 SCIP_DECL_HEURINIT(heurInitLocks) /*lint --e{715}*/
159 { /*lint --e{715}*/
160  SCIP_HEURDATA* heurdata;
161 
162  assert(strcmp(SCIPheurGetName(heur), HEUR_NAME) == 0);
163  heurdata = SCIPheurGetData(heur);
164  assert(heurdata != NULL);
165 
166  /* initialize data */
167  heurdata->usednodes = 0;
168 
169  /* create random number generator */
170  SCIP_CALL( SCIPcreateRandom(scip, &heurdata->randnumgen,
171  DEFAULT_RANDSEED) );
172 
173  return SCIP_OKAY;
174 }
175 
176 /** deinitialization method of primal heuristic (called before transformed problem is freed) */
177 static
178 SCIP_DECL_HEUREXIT(heurExitLocks) /*lint --e{715}*/
179 { /*lint --e{715}*/
180  SCIP_HEURDATA* heurdata;
181 
182  assert(strcmp(SCIPheurGetName(heur), HEUR_NAME) == 0);
183 
184  /* free heuristic data */
185  heurdata = SCIPheurGetData(heur);
186  assert(heurdata != NULL);
187 
188  /* free random number generator */
189  SCIPfreeRandom(scip, &heurdata->randnumgen);
190 
191  return SCIP_OKAY;
192 }
193 
194 #define heurInitsolLocks NULL
195 #define heurExitsolLocks NULL
196 
197 /** apply fix-and-propagate scheme based on variable locks
198  *
199  * @note probing mode of SCIP needs to be enabled before
200  */
202  SCIP* scip, /**< SCIP data structure */
203  SCIP_HEURDATA* heurdata, /**< primal heuristic data */
204  SCIP_Bool* cutoff, /**< pointer to store if a cutoff was detected */
205  SCIP_Bool* allrowsfulfilled /**< pointer to store if all rows became redundant */
206  )
207 {
208  SCIP_ROW** lprows;
209  SCIP_VAR** vars;
210  SCIP_VAR** sortvars;
211  SCIP_Real* minact;
212  SCIP_Real* maxact;
213  SCIP_Bool* fulfilled;
214  SCIP_VAR* var;
215  SCIP_ROW* row;
216  SCIP_COL* col;
217  SCIP_ROW** colrows;
218  SCIP_Real* colvals;
219  int ncolrows;
220  int* ndownlocks;
221  int* nuplocks;
222  int* varpos = NULL;
223  SCIP_Real lastfixval;
224  SCIP_Real randnumber;
225  SCIP_Real roundupprobability;
226  SCIP_Bool propagate;
227  SCIP_Bool propagated;
228  SCIP_Bool haslhs;
229  SCIP_Bool hasrhs;
230  SCIP_Bool updatelocks;
231  int lastfixlocks;
232  int maxproprounds;
233  int nglbfulfilledrows;
234  int rowpos;
235  int nbinvars;
236  int nvars;
237  int nlprows;
238  int nfulfilledrows;
239  int bestpos;
240  int lastbestscore;
241  int bestscore;
242  int score;
243  int v;
244  int r;
245  int i;
246 
247  assert(scip != NULL);
248  assert(cutoff != NULL);
249  assert(allrowsfulfilled != NULL);
250  assert(SCIPinProbing(scip));
251 
252  if( heurdata == NULL )
253  {
254  SCIP_HEUR* heur = SCIPfindHeur(scip, HEUR_NAME);
255  heurdata = SCIPheurGetData(heur);
256  }
257  assert(heurdata != NULL);
258 
259  *cutoff = FALSE;
260  *allrowsfulfilled = FALSE;
261 
262  propagate = (heurdata->maxproprounds != 0);
263 
264  if( heurdata->maxproprounds == -2 )
265  maxproprounds = 0;
266  else
267  maxproprounds = heurdata->maxproprounds;
268 
269  roundupprobability = heurdata->roundupprobability;
270 
271 
272  updatelocks = heurdata->updatelocks && (SCIPgetNCheckConss(scip) == SCIPgetNLPRows(scip));
273 
274  SCIPdebugMsg(scip, "%d constraints: %d logicor, updatelocks=%d\n", SCIPgetNConss(scip), SCIPconshdlrGetNCheckConss(SCIPfindConshdlr(scip, "logicor")), updatelocks);
275 
276  SCIP_CALL( SCIPgetVarsData(scip, &vars, &nvars, &nbinvars, NULL, NULL, NULL) );
277  assert(vars != NULL);
278 
279  /* allocate memory */
280  SCIP_CALL( SCIPduplicateBufferArray(scip, &sortvars, vars, nbinvars) );
281  SCIP_CALL( SCIPallocBufferArray(scip, &nuplocks, nbinvars) );
282  SCIP_CALL( SCIPallocBufferArray(scip, &ndownlocks, nbinvars) );
283 
284  /* get LP data */
285  SCIP_CALL( SCIPgetLPRowsData(scip, &lprows, &nlprows) );
286  SCIP_CALL( SCIPallocBufferArray(scip, &minact, nlprows) );
287  SCIP_CALL( SCIPallocBufferArray(scip, &maxact, nlprows) );
288  SCIP_CALL( SCIPallocClearBufferArray(scip, &fulfilled, nlprows) );
289 
290  /* @todo add objective value as second sorting criteria */
291 
292  nglbfulfilledrows = 0;
293 
294  /* get locks of variables */
295  for( v = 0; v < nbinvars; ++v )
296  {
297  var = sortvars[v];
298  nuplocks[v] = SCIPvarGetNLocksUp(var);
299  ndownlocks[v] = SCIPvarGetNLocksDown(var);
300  }
301 
302  /* get activities of rows */
303  for( r = 0; r < nlprows; ++r )
304  {
305  row = lprows[r];
306  assert(SCIProwGetLPPos(row) == r);
307 
308  /* no trivial rows */
309  assert(!SCIPisInfinity(scip, -SCIProwGetLhs(row)) || !SCIPisInfinity(scip, SCIProwGetRhs(row)));
310 
311  minact[r] = SCIPgetRowMinActivity(scip, row);
312  maxact[r] = SCIPgetRowMaxActivity(scip, row);
313  }
314 
315  propagated = TRUE;
316  lastbestscore = INT_MAX;
317 
318  /* fix variables */
319  for( v = 0; v < nbinvars; v++ )
320  {
321  if( SCIPisStopped(scip) )
322  break;
323 
324  assert(!(*cutoff));
325 
326  nfulfilledrows = 0;
327 
328  while( v < nbinvars && (SCIPvarGetLbLocal(sortvars[v]) > 0.5 || SCIPvarGetUbLocal(sortvars[v]) < 0.5) )
329  {
330  ++v;
331  }
332  if( v == nbinvars )
333  break;
334 
335  bestpos = v;
336  bestscore = nuplocks[v] + ndownlocks[v];
337 
338  /* get best variable */
339  if( bestscore < lastbestscore )
340  {
341  for( i = v + 1; i < nbinvars; ++i )
342  {
343  var = sortvars[i];
344 
345  /* variable is already fixed; move it to the front and increment v to ignore it */
346  if( SCIPvarGetLbLocal(var) > 0.5 || SCIPvarGetUbLocal(var) < 0.5 )
347  {
348  int locks;
349 
350  sortvars[i] = sortvars[v];
351  sortvars[v] = var;
352 
353  locks = nuplocks[i];
354  nuplocks[i] = nuplocks[v];
355  nuplocks[v] = locks;
356 
357  locks = ndownlocks[i];
358  ndownlocks[i] = ndownlocks[v];
359  ndownlocks[v] = locks;
360 
361  if( varpos != NULL )
362  {
363  varpos[SCIPvarGetProbindex(sortvars[i])] = i;
364  varpos[SCIPvarGetProbindex(sortvars[v])] = v;
365  }
366 
367  if( bestpos == v )
368  bestpos = i;
369 
370  ++v;
371 
372  continue;
373  }
374 
375  score = nuplocks[i] + ndownlocks[i];
376  assert(score <= lastbestscore);
377 
378  if( score > bestscore )
379  {
380  bestscore = score;
381  bestpos = i;
382 
383  if( bestscore == lastbestscore )
384  break;
385  }
386  }
387  if( v == nbinvars )
388  break;
389  }
390  lastbestscore = bestscore;
391 
392  /* move best variable to the front (at position v) */
393  if( bestpos != v )
394  {
395  int locks;
396 
397  var = sortvars[bestpos];
398  sortvars[bestpos] = sortvars[v];
399  sortvars[v] = var;
400 
401  locks = nuplocks[bestpos];
402  nuplocks[bestpos] = nuplocks[v];
403  nuplocks[v] = locks;
404 
405  locks = ndownlocks[bestpos];
406  ndownlocks[bestpos] = ndownlocks[v];
407  ndownlocks[v] = locks;
408 
409  if( varpos != NULL )
410  {
411  varpos[SCIPvarGetProbindex(sortvars[bestpos])] = bestpos;
412  varpos[SCIPvarGetProbindex(sortvars[v])] = v;
413  }
414  }
415 
416  var = sortvars[v];
417 
418  /* all remaining variables are fixed, we can break the fix-and-propagate loop */
419  if( SCIPvarGetLbLocal(var) > 0.5 || SCIPvarGetUbLocal(var) < 0.5 )
420  {
421  assert(v == nbinvars);
422 
423  break;
424  }
425 
426  /* stop if we reached the depth limit */
427  if( SCIP_MAXTREEDEPTH <= SCIPgetDepth(scip) )
428  break;
429 
430  if( propagated )
431  {
432  SCIP_CALL( SCIPnewProbingNode(scip) );
433  propagated = FALSE;
434  }
435 
436  /* set variables to the bound with fewer locks, if tie choose an average value */
437  if( ndownlocks[v] > nuplocks[v] )
438  lastfixval = 1.0;
439  else if( ndownlocks[v] < nuplocks[v] )
440  lastfixval = 0.0;
441  else
442  {
443  /* prefer one-fixing if objective value is not positive */
444  if( !SCIPisPositive(scip, SCIPvarGetObj(var)) )
445  lastfixval = 1.0;
446  else
447  {
448  randnumber = SCIPrandomGetReal(heurdata->randnumgen, 0.0, 1.0);
449 
450  /* if a tie occurs, we randomly round the variable based on the parameter 'roundupprobability' */
451  if( randnumber < roundupprobability )
452  lastfixval = 1.0;
453  else
454  lastfixval = 0.0;
455  }
456  }
457 
458  lastfixlocks = lastfixval > 0.5 ? nuplocks[v] : ndownlocks[v];
459 
460  SCIP_CALL( SCIPfixVarProbing(scip, var, lastfixval) );
461 
462  SCIPdebugMsg(scip, "iteration %d: fixing variable <%s> to %d with locks (%d, %d)\n", v, SCIPvarGetName(var), lastfixval > 0.5 ? 1 : 0, ndownlocks[v], nuplocks[v]);
463 
464  if( propagate && lastfixlocks > 0 )
465  {
466  /* apply propagation */
467  SCIP_CALL( SCIPpropagateProbing(scip, maxproprounds, cutoff, NULL) );
468  propagated = TRUE;
469 
470  if( *cutoff )
471  {
472  SCIPdebugMsg(scip, "last fixing led to infeasibility trying other bound\n");
473 
474  /* fix cutoff variable in other direction */
476  *cutoff = FALSE;
477 
478  if( lastfixval < 0.5 )
479  {
480  lastfixval = 1.0;
481 
482  if( SCIPvarGetUbLocal(var) > 0.5 )
483  {
484  SCIP_CALL( SCIPfixVarProbing(scip, var, 1.0) );
485  }
486  /* because of the limited number of propagation rounds, it may happen that conflict analysis finds a
487  * valid global fixing for the last fixed variable that conflicts with applying the reverse fixing
488  * after backtracking; in that case, we ran into a deadend and stop
489  */
490  else
491  *cutoff = TRUE;
492  }
493  else
494  {
495  lastfixval = 0.0;
496 
497  if( SCIPvarGetLbLocal(var) < 0.5 )
498  {
499  SCIP_CALL( SCIPfixVarProbing(scip, var, 0.0) );
500  }
501  /* because of the limited number of propagation rounds, it may happen that conflict analysis finds a
502  * valid global fixing for the last fixed variable that conflicts with applying the reverse fixing
503  * after backtracking; in that case, we ran into a deadend and stop
504  */
505  else
506  *cutoff = TRUE;
507  }
508 
509  if( !(*cutoff) )
510  {
511  SCIP_CALL( SCIPpropagateProbing(scip, maxproprounds, cutoff, NULL) );
512  }
513  if( *cutoff )
514  {
515  SCIPdebugMsg(scip, "probing was infeasible\n");
516 
517  break;
518  }
519  }
520  /* @todo collect propagated bounds and use them to update row activities as well */
521  }
522 
523  if( updatelocks )
524  {
526  continue;
527 
528  col = SCIPvarGetCol(var);
529  assert(col != NULL);
530 
531  colrows = SCIPcolGetRows(col);
532  colvals = SCIPcolGetVals(col);
533  ncolrows = SCIPcolGetNNonz(col);
534 
535  /* update activities */
536  for( r = 0; r < ncolrows; ++r )
537  {
538  row = colrows[r];
539  rowpos = SCIProwGetLPPos(row);
540 
541  /* the row is not in the LP */
542  if( rowpos == -1 )
543  continue;
544 
545  assert(lprows[rowpos] == row);
546 
547  /* we disregard cuts */
548  if( SCIProwGetRank(row) > 0 )
549  continue;
550 
551  /* the row is already fulfilled */
552  if( fulfilled[rowpos] )
553  continue;
554 
555  haslhs = !SCIPisInfinity(scip, -SCIProwGetLhs(row));
556  hasrhs = !SCIPisInfinity(scip, SCIProwGetRhs(row));
557 
558  /* no trivial rows */
559  assert(hasrhs || haslhs);
560 
561  if( ((colvals[r] > 0) == (lastfixval < 0.5)) )
562  {
563  maxact[rowpos] -= REALABS(colvals[r]);
564  }
565  if( ((colvals[r] > 0) == (lastfixval > 0.5)) )
566  {
567  minact[rowpos] += REALABS(colvals[r]);
568  }
569 
570  /* check if the row cannot be violated anymore */
571  if( (!haslhs || SCIPisFeasGE(scip, minact[rowpos], SCIProwGetLhs(row)))
572  && (!hasrhs || SCIPisFeasLE(scip, maxact[rowpos], SCIProwGetRhs(row))) )
573  {
574  SCIP_COL** cols;
575  SCIP_VAR* colvar;
576  SCIP_Real* vals;
577  int ncols;
578  int pos;
579  int w;
580 
581  SCIPdebugMsg(scip, "Row <%s> has activity [%g, %g], lhs=%g, rhs=%g\n", SCIProwGetName(row), minact[rowpos], maxact[rowpos], SCIProwGetLhs(row), SCIProwGetRhs(row));
582  SCIPdebug( SCIP_CALL( SCIPprintRow(scip, row, NULL) ) );
583 
584  if( varpos == NULL )
585  {
586  SCIP_CALL( SCIPallocBufferArray(scip, &varpos, nbinvars) );
587 
588  for( pos = 0; pos < nbinvars; ++pos )
589  varpos[SCIPvarGetProbindex(sortvars[pos])] = pos;
590  }
591 
592  ++nfulfilledrows;
593  fulfilled[rowpos] = TRUE;
594  cols = SCIProwGetCols(row);
595  vals = SCIProwGetVals(row);
596  ncols = SCIProwGetNNonz(row);
597 
598  /* we assume that all rows are locking the variables */
599  for( w = ncols - 1; w >= 0; --w )
600  {
601  colvar = SCIPcolGetVar(cols[w]);
602  if( SCIPvarGetType(colvar) == SCIP_VARTYPE_BINARY && colvar != var )
603  {
604  assert(sortvars[varpos[SCIPvarGetProbindex(colvar)]] == colvar);
605  pos = varpos[SCIPvarGetProbindex(colvar)];
606 
607  if( haslhs )
608  {
609  if( vals[w] > 0.0 )
610  --(ndownlocks[pos]);
611  else
612  --(nuplocks[pos]);
613  }
614  if( hasrhs )
615  {
616  if( vals[w] > 0.0 )
617  --(nuplocks[pos]);
618  else
619  --(ndownlocks[pos]);
620  }
621  }
622  }
623 
624  continue;
625  }
626  else if( SCIPisFeasLT(scip, maxact[rowpos], SCIProwGetLhs(row)) || SCIPisFeasGT(scip, minact[rowpos], SCIProwGetRhs(row)) )
627  {
628  *cutoff = TRUE;
629  break;
630  }
631  }
632 
633  if( *cutoff )
634  {
635  SCIPdebugMsg(scip, "found infeasible row, stopping heur\n");
636  break;
637  }
638 
639  nglbfulfilledrows += nfulfilledrows;
640  SCIPdebugMsg(scip, "last fixing led to %d fulfilled rows, now %d of %d rows are fulfilled\n", nfulfilledrows, nglbfulfilledrows, nlprows);
641 
642  if( nglbfulfilledrows == nlprows )
643  {
644  *allrowsfulfilled = TRUE;
645  break;
646  }
647  }
648  } /*lint --e{850}*/
649 
650  SCIPfreeBufferArrayNull(scip, &varpos);
651  SCIPfreeBufferArray(scip, &fulfilled);
652  SCIPfreeBufferArray(scip, &maxact);
653  SCIPfreeBufferArray(scip, &minact);
654  SCIPfreeBufferArray(scip, &ndownlocks);
655  SCIPfreeBufferArray(scip, &nuplocks);
656  SCIPfreeBufferArray(scip, &sortvars);
657 
658  return SCIP_OKAY;
659 }
660 
661 
662 
663 
664 /** execution method of primal heuristic */
665 static
666 SCIP_DECL_HEUREXEC(heurExecLocks)
667 { /*lint --e{715}*/
668  SCIP_HEURDATA* heurdata;
669  SCIP_SOL* sol;
670  SCIP_VAR** vars;
672  SCIP_Real lowerbound;
673  SCIP_Bool cutoff;
674  SCIP_Bool lperror;
675  SCIP_Bool allrowsfulfilled = FALSE;
676 #ifdef NOCONFLICT
677  SCIP_Bool enabledconflicts;
678 #endif
679  int oldnpscands;
680  int npscands;
681 
682  int nvars;
683  int i;
684 
685  *result = SCIP_DIDNOTRUN;
686 
687  /* only run once */
688  if( SCIPgetNRuns(scip) > 1 )
689  return SCIP_OKAY;
690 
691  if( SCIPgetNBinVars(scip) == 0 )
692  return SCIP_OKAY;
693 
694  /* only run if we are allowed to solve an LP at the current node in the tree */
695  if( !SCIPhasCurrentNodeLP(scip) )
696  return SCIP_OKAY;
697 
698  if( !SCIPisLPConstructed(scip) )
699  {
700  SCIP_CALL( SCIPconstructLP(scip, &cutoff) );
701 
702  /* manually cut off the node if the LP construction detected infeasibility (heuristics cannot return such a result) */
703  if( cutoff )
704  {
706  return SCIP_OKAY;
707  }
708 
709  SCIP_CALL( SCIPflushLP(scip) );
710 
711  /* we need an LP */
712  if( SCIPgetNLPRows(scip) == 0 )
713  return SCIP_OKAY;
714  }
715 
716  *result = SCIP_DIDNOTFIND;
717 
718  heurdata = SCIPheurGetData(heur);
719  assert(heurdata != NULL);
720 
721 #ifdef NOCONFLICT
722  /* disable conflict analysis */
723  SCIP_CALL( SCIPgetBoolParam(scip, "conflict/enable", &enabledconflicts) );
724 
725  if( !SCIPisParamFixed(scip, "conflict/enable") )
726  {
727  SCIP_CALL( SCIPsetBoolParam(scip, "conflict/enable", FALSE) );
728  }
729 #endif
730 
731  /* create solution */
732  SCIP_CALL( SCIPcreateSol(scip, &sol, heur) );
733 
734  lowerbound = SCIPgetLowerbound(scip);
735  oldnpscands = SCIPgetNPseudoBranchCands(scip);
736 
737  /* start probing mode */
738  SCIP_CALL( SCIPstartProbing(scip) );
739 
740 #ifdef COLLECTSTATISTICS
741  SCIPenableVarHistory(scip);
742 #endif
743 
744  cutoff = FALSE;
745  lperror = FALSE;
746 
747  SCIP_CALL( SCIPapplyLockFixings(scip, heurdata, &cutoff, &allrowsfulfilled) );
748 
749  if( cutoff || SCIPisStopped(scip) )
750  goto TERMINATE;
751 
752  /* check that we had enough fixings */
753  npscands = SCIPgetNPseudoBranchCands(scip);
754 
755  SCIPdebugMsg(scip, "npscands=%d, oldnpscands=%d, allrowsfulfilled=%u heurdata->minfixingrate=%g\n",
756  npscands, oldnpscands, allrowsfulfilled, heurdata->minfixingrate);
757 
758  if( !allrowsfulfilled && npscands > oldnpscands * (1 - heurdata->minfixingrate) )
759  {
760  SCIPdebugMsg(scip, "--> too few fixings\n");
761 
762  goto TERMINATE;
763  }
764  else
765  {
766  SCIPdebugMsg(scip, "starting solving locks-lp at time %g\n", SCIPgetSolvingTime(scip));
767 
768  /* solve LP;
769  * errors in the LP solver should not kill the overall solving process, if the LP is just needed for a heuristic.
770  * hence in optimized mode, the return code is caught and a warning is printed, only in debug mode, SCIP will stop.
771  */
772 #ifdef NDEBUG
773  {
774  SCIP_Bool retstat;
775  retstat = SCIPsolveProbingLP(scip, -1, &lperror, &cutoff);
776  if( retstat != SCIP_OKAY )
777  {
778  SCIPwarningMessage(scip, "Error while solving LP in LOCKS heuristic; LP solve terminated with code <%d>\n",
779  retstat);
780  }
781  }
782 #else
783  SCIP_CALL( SCIPsolveProbingLP(scip, -1, &lperror, &cutoff) );
784 #endif
785  SCIPdebugMsg(scip, "ending solving locks-lp at time %g\n", SCIPgetSolvingTime(scip));
786 
787  lpstatus = SCIPgetLPSolstat(scip);
788 
789  SCIPdebugMsg(scip, " -> new LP iterations: %" SCIP_LONGINT_FORMAT "\n", SCIPgetNLPIterations(scip));
790  SCIPdebugMsg(scip, " -> error=%u, status=%d\n", lperror, SCIPgetLPSolstat(scip));
791 
792  /* check if this is a feasible solution */
793  if( !lperror && lpstatus == SCIP_LPSOLSTAT_OPTIMAL )
794  {
795  SCIP_Bool success;
796 
797  lowerbound = SCIPgetLPObjval(scip);
798 
799  /* copy the current LP solution to the working solution */
800  SCIP_CALL( SCIPlinkLPSol(scip, sol) );
801 
802  SCIP_CALL( SCIProundSol(scip, sol, &success) );
803 
804  if( success )
805  {
806  SCIP_Bool stored;
807 
808  /* check solution for feasibility, and add it to solution store if possible.
809  * Neither integrality nor feasibility of LP rows have to be checked, because they
810  * are guaranteed by the heuristic at this stage.
811  */
812  SCIP_CALL( SCIPtrySol(scip, sol, FALSE, FALSE, FALSE, FALSE, FALSE, &stored) );
813 
814  if( stored )
815  {
816 #ifdef SCIP_MORE_DEBUG
817  SCIP_Bool feasible;
818  SCIP_CALL( SCIPcheckSol(scip, sol, TRUE, TRUE, TRUE, TRUE, TRUE, &feasible) );
819  assert(feasible);
820 #endif
821 
822  SCIPdebugMsg(scip, "found feasible solution:\n");
823  SCIPdebug(SCIP_CALL( SCIPprintSol(scip, sol, NULL, FALSE)) );
824  *result = SCIP_FOUNDSOL;
825  }
826 
827  /* we found a solution, so we are done */
828  goto TERMINATE;
829  }
830  }
831  }
832 
833  if( heurdata->usefinalsubmip && !cutoff && !lperror && lpstatus != SCIP_LPSOLSTAT_INFEASIBLE && lpstatus != SCIP_LPSOLSTAT_OBJLIMIT )
834  {
835  SCIP* subscip;
836  SCIP_VAR** subvars;
837  SCIP_HASHMAP* varmap;
838  SCIP_Longint nstallnodes;
839  SCIP_Bool valid;
840 
841  /* calculate the maximal number of branching nodes until heuristic is aborted */
842  nstallnodes = (SCIP_Longint)(heurdata->nodesquot * SCIPgetNNodes(scip));
843 
844  /* reward locks heuristic if it succeeded often */
845  nstallnodes = (SCIP_Longint)(nstallnodes * 3.0 * (SCIPheurGetNBestSolsFound(heur)+1.0)/(SCIPheurGetNCalls(heur) + 1.0));
846  nstallnodes -= 100 * SCIPheurGetNCalls(heur); /* count the setup costs for the sub-MIP as 100 nodes */
847  nstallnodes += heurdata->nodesofs;
848 
849  /* determine the node limit for the current process */
850  nstallnodes -= heurdata->usednodes;
851  nstallnodes = MIN(nstallnodes, heurdata->maxnodes);
852 
853  /* check whether we have enough nodes left to call subproblem solving */
854  if( nstallnodes < heurdata->minnodes )
855  {
856  SCIPdebugMsg(scip, "skipping " HEUR_NAME ": nstallnodes=%" SCIP_LONGINT_FORMAT ", minnodes=%" SCIP_LONGINT_FORMAT "\n", nstallnodes, heurdata->minnodes);
857  goto TERMINATE;
858  }
859 
860  /* check whether there is enough time and memory left */
861  SCIP_CALL( SCIPcheckCopyLimits(scip, &valid) );
862 
863  if( !valid )
864  goto TERMINATE;
865 
866  /* get all variables */
867  SCIP_CALL( SCIPgetVarsData(scip, &vars, &nvars, NULL, NULL, NULL, NULL) );
868 
869  /* create subproblem */
870  SCIP_CALL( SCIPcreate(&subscip) );
871 
872  /* allocate temporary memory for subscip variables */
873  SCIP_CALL( SCIPallocBufferArray(scip, &subvars, nvars) );
874 
875  /* create the variable mapping hash map */
876  SCIP_CALL( SCIPhashmapCreate(&varmap, SCIPblkmem(subscip), nvars) );
877 
878  SCIP_CALL( SCIPcopy(scip, subscip, varmap, NULL, "_locks", FALSE, FALSE, TRUE, &valid) );
879 
880  if( heurdata->copycuts )
881  {
882  /* copies all active cuts from cutpool of sourcescip to linear constraints in targetscip */
883  SCIP_CALL( SCIPcopyCuts(scip, subscip, varmap, NULL, FALSE, NULL) );
884  }
885 
886  for( i = 0; i < nvars; i++ )
887  subvars[i] = (SCIP_VAR*) SCIPhashmapGetImage(varmap, vars[i]);
888 
889  /* free hash map */
890  SCIPhashmapFree(&varmap);
891 
892  /* do not abort subproblem on CTRL-C */
893  SCIP_CALL( SCIPsetBoolParam(subscip, "misc/catchctrlc", FALSE) );
894 
895 #ifdef SCIP_DEBUG
896  /* for debugging, enable full output */
897  SCIP_CALL( SCIPsetIntParam(subscip, "display/verblevel", 5) );
898  SCIP_CALL( SCIPsetIntParam(subscip, "display/freq", 100000000) );
899 #else
900  /* disable statistic timing inside sub SCIP and output to console */
901  SCIP_CALL( SCIPsetIntParam(subscip, "display/verblevel", 0) );
902  SCIP_CALL( SCIPsetBoolParam(subscip, "timing/statistictiming", FALSE) );
903 #endif
904 
905  /* set limits for the subproblem */
906  SCIP_CALL( SCIPcopyLimits(scip, subscip) );
907  SCIP_CALL( SCIPsetLongintParam(subscip, "limits/stallnodes", nstallnodes) );
908  SCIP_CALL( SCIPsetLongintParam(subscip, "limits/nodes", heurdata->maxnodes) );
909 
910  /* forbid call of heuristics and separators solving sub-CIPs */
911  SCIP_CALL( SCIPsetSubscipsOff(subscip, TRUE) );
912 
913  /* disable cutting plane separation */
915 
916  /* disable expensive presolving */
918 
919  /* use inference branching */
920  if( SCIPfindBranchrule(subscip, "inference") != NULL && !SCIPisParamFixed(subscip, "branching/inference/priority") )
921  {
922  SCIP_CALL( SCIPsetIntParam(subscip, "branching/inference/priority", INT_MAX/4) );
923  }
924 
925  /* speed up sub-SCIP by not checking dual LP feasibility */
926  SCIP_CALL( SCIPsetBoolParam(subscip, "lp/checkdualfeas", FALSE) );
927 
928  /* employ a limit on the number of enforcement rounds in the quadratic constraint handler; this fixes the issue that
929  * sometimes the quadratic constraint handler needs hundreds or thousands of enforcement rounds to determine the
930  * feasibility status of a single node without fractional branching candidates by separation (namely for uflquad
931  * instances); however, the solution status of the sub-SCIP might get corrupted by this; hence no deductions shall be
932  * made for the original SCIP
933  */
934  if( SCIPfindConshdlr(subscip, "quadratic") != NULL && !SCIPisParamFixed(subscip, "constraints/quadratic/enfolplimit") )
935  {
936  SCIP_CALL( SCIPsetIntParam(subscip, "constraints/quadratic/enfolplimit", 10) );
937  }
938 
939  /* if there is already a solution, add an objective cutoff */
940  if( SCIPgetNSols(scip) > 0 )
941  {
942  SCIP_Real upperbound;
943  SCIP_Real minimprove;
944  SCIP_Real cutoffbound;
945 
946  minimprove = heurdata->minimprove;
947  assert( !SCIPisInfinity(scip,SCIPgetUpperbound(scip)) );
948 
949  upperbound = SCIPgetUpperbound(scip) - SCIPsumepsilon(scip);
950 
951  if( !SCIPisInfinity(scip, -1.0 * lowerbound) )
952  {
953  cutoffbound = (1-minimprove) * SCIPgetUpperbound(scip) + minimprove * lowerbound;
954  }
955  else
956  {
957  if( SCIPgetUpperbound ( scip ) >= 0 )
958  cutoffbound = (1 - minimprove) * SCIPgetUpperbound(scip);
959  else
960  cutoffbound = (1 + minimprove) * SCIPgetUpperbound(scip);
961  }
962  cutoffbound = MIN(upperbound, cutoffbound);
963  SCIP_CALL( SCIPsetObjlimit(subscip, cutoffbound) );
964  SCIPdebugMsg(scip, "setting objlimit for subscip to %g\n", cutoffbound);
965  }
966 
967  SCIPdebugMsg(scip, "starting solving locks-submip at time %g\n", SCIPgetSolvingTime(scip));
968 
969  /* solve the subproblem */
970  /* Errors in the LP solver should not kill the overall solving process, if the LP is just needed for a heuristic.
971  * Hence in optimized mode, the return code is caught and a warning is printed, only in debug mode, SCIP will stop.
972  */
973 #ifdef NDEBUG
974  {
975  SCIP_RETCODE retstat;
976  retstat = SCIPpresolve(subscip);
977  if( retstat != SCIP_OKAY )
978  {
979  SCIPwarningMessage(scip, "Error while presolving subMIP in locks heuristic; sub-SCIP terminated with code <%d>\n", retstat);
980 
981  goto FREESCIPANDTERMINATE;
982  }
983  }
984 #else
985  SCIP_CALL_ABORT( SCIPpresolve(subscip) );
986 #endif
987 
988  SCIPdebugMsg(scip, "locks heuristic presolved subproblem at time %g : %d vars, %d cons; fixing value = %g\n", SCIPgetSolvingTime(scip), SCIPgetNVars(subscip), SCIPgetNConss(subscip), ((nvars - SCIPgetNVars(subscip)) / (SCIP_Real)nvars));
989 
990  /* after presolving, we should have at least reached a certain fixing rate over ALL variables (including continuous)
991  * to ensure that not only the MIP but also the LP relaxation is easy enough
992  */
993  if( ((nvars - SCIPgetNVars(subscip)) / (SCIP_Real)nvars) >= heurdata->minfixingrate )
994  {
995  SCIP_SOL** subsols;
996  SCIP_Bool success;
997  int nsubsols;
998 
999  SCIPdebugMsg(scip, "solving subproblem: nstallnodes=%" SCIP_LONGINT_FORMAT ", maxnodes=%" SCIP_LONGINT_FORMAT "\n", nstallnodes, heurdata->maxnodes);
1000 
1001 #ifdef NDEBUG
1002  {
1003  SCIP_RETCODE retstat;
1004  retstat = SCIPsolve(subscip);
1005  if( retstat != SCIP_OKAY )
1006  {
1007  SCIPwarningMessage(scip, "Error while solving subMIP in locks heuristic; sub-SCIP terminated with code <%d>\n",retstat);
1008 
1009  goto FREESCIPANDTERMINATE;
1010  }
1011  }
1012 #else
1013  SCIP_CALL_ABORT( SCIPsolve(subscip) );
1014 #endif
1015  SCIPdebugMsg(scip, "ending solving locks-submip at time %g, status = %d\n", SCIPgetSolvingTime(scip), SCIPgetStatus(subscip));
1016 
1017  /* check, whether a solution was found; due to numerics, it might happen that not all solutions are feasible ->
1018  * try all solutions until one was accepted
1019  */
1020  nsubsols = SCIPgetNSols(subscip);
1021  subsols = SCIPgetSols(subscip);
1022  success = FALSE;
1023 
1024  for( i = 0; i < nsubsols && !success; ++i )
1025  {
1026  SCIP_CALL( createNewSol(scip, subscip, subvars, sol, subsols[i], &success) );
1027  }
1028  if( success )
1029  *result = SCIP_FOUNDSOL;
1030  }
1031 
1032 #ifdef SCIP_DEBUG
1033  SCIP_CALL( SCIPprintStatistics(subscip, NULL) );
1034 #endif
1035 
1036  heurdata->usednodes += SCIPgetNNodes(subscip);
1037 #ifdef NDEBUG
1038  FREESCIPANDTERMINATE:
1039 #endif
1040  /* free subproblem */
1041  SCIPfreeBufferArray(scip, &subvars);
1042  SCIP_CALL( SCIPfree(&subscip) );
1043  }
1044 
1045 
1046  TERMINATE:
1047  /* exit probing mode */
1048  SCIP_CALL( SCIPendProbing(scip) );
1049 
1050 #ifdef NOCONFLICT
1051  /* reset the conflict analysis */
1052  if( !SCIPisParamFixed(scip, "conflict/enable") )
1053  {
1054  SCIP_CALL( SCIPsetBoolParam(scip, "conflict/enable", enabledconflicts) );
1055  }
1056 #endif
1057 
1058  /* free all allocated memory */
1059  SCIP_CALL( SCIPfreeSol(scip, &sol) );
1060 
1061  return SCIP_OKAY;
1062 }
1063 
1064 
1065 /*
1066  * primal heuristic specific interface methods
1067  */
1068 
1069 /** creates the locks primal heuristic and includes it in SCIP */
1071  SCIP* scip /**< SCIP data structure */
1072  )
1073 {
1074  SCIP_HEURDATA* heurdata;
1075 
1076  /* create primal heuristic data */
1077  SCIP_CALL( SCIPallocBlockMemory(scip, &heurdata) );
1078 
1079  /* include primal heuristic */
1082  heurCopyLocks,
1083  heurFreeLocks, heurInitLocks, heurExitLocks,
1084  heurInitsolLocks, heurExitsolLocks, heurExecLocks,
1085  heurdata) );
1086 
1087  SCIP_CALL( SCIPaddIntParam(scip, "heuristics/" HEUR_NAME "/maxproprounds",
1088  "maximum number of propagation rounds to be performed in each propagation call (-1: no limit, -2: parameter settings)",
1089  &heurdata->maxproprounds, TRUE, DEFAULT_MAXPROPROUNDS, -2, INT_MAX, NULL, NULL) );
1090 
1091  SCIP_CALL( SCIPaddRealParam(scip, "heuristics/" HEUR_NAME "/minfixingrate",
1092  "minimum percentage of integer variables that have to be fixable",
1093  &heurdata->minfixingrate, FALSE, DEFAULT_MINFIXINGRATE, 0.0, 1.0, NULL, NULL) );
1094 
1095  SCIP_CALL( SCIPaddRealParam(scip, "heuristics/" HEUR_NAME "/roundupprobability",
1096  "probability for rounding a variable up in case of ties",
1097  &heurdata->roundupprobability, FALSE, DEFAULT_ROUNDUPPROBABILITY, 0.0, 1.0, NULL, NULL) );
1098 
1099  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/" HEUR_NAME "/usefinalsubmip",
1100  "should a final sub-MIP be solved to costruct a feasible solution if the LP was not roundable?",
1101  &heurdata->usefinalsubmip, TRUE, DEFAULT_USEFINALSUBMIP, NULL, NULL) );
1102 
1103  SCIP_CALL( SCIPaddLongintParam(scip, "heuristics/" HEUR_NAME "/maxnodes",
1104  "maximum number of nodes to regard in the subproblem",
1105  &heurdata->maxnodes, TRUE, DEFAULT_MAXNODES, 0LL, SCIP_LONGINT_MAX, NULL, NULL) );
1106 
1107  SCIP_CALL( SCIPaddLongintParam(scip, "heuristics/" HEUR_NAME "/nodesofs",
1108  "number of nodes added to the contingent of the total nodes",
1109  &heurdata->nodesofs, FALSE, DEFAULT_NODESOFS, 0LL, SCIP_LONGINT_MAX, NULL, NULL) );
1110 
1111  SCIP_CALL( SCIPaddLongintParam(scip, "heuristics/" HEUR_NAME "/minnodes",
1112  "minimum number of nodes required to start the subproblem",
1113  &heurdata->minnodes, TRUE, DEFAULT_MINNODES, 0LL, SCIP_LONGINT_MAX, NULL, NULL) );
1114 
1115  SCIP_CALL( SCIPaddRealParam(scip, "heuristics/" HEUR_NAME "/nodesquot",
1116  "contingent of sub problem nodes in relation to the number of nodes of the original problem",
1117  &heurdata->nodesquot, FALSE, DEFAULT_NODESQUOT, 0.0, 1.0, NULL, NULL) );
1118 
1119  SCIP_CALL( SCIPaddRealParam(scip, "heuristics/" HEUR_NAME "/minimprove",
1120  "factor by which " HEUR_NAME " heuristic should at least improve the incumbent",
1121  &heurdata->minimprove, TRUE, DEFAULT_MINIMPROVE, 0.0, 1.0, NULL, NULL) );
1122 
1123  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/" HEUR_NAME "/copycuts",
1124  "should all active cuts from cutpool be copied to constraints in subproblem?",
1125  &heurdata->copycuts, TRUE, DEFAULT_COPYCUTS, NULL, NULL) );
1126 
1127  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/" HEUR_NAME "/updatelocks",
1128  "should the locks be updated based on LP rows?",
1129  &heurdata->updatelocks, TRUE, DEFAULT_UPDATELOCKS, NULL, NULL) );
1130 
1131  return SCIP_OKAY;
1132 }
void SCIPfreeRandom(SCIP *scip, SCIP_RANDNUMGEN **randnumgen)
Definition: scip.c:48620
#define DEFAULT_NODESOFS
Definition: heur_locks.c:48
int SCIPgetNCheckConss(SCIP *scip)
Definition: scip.c:12998
SCIP_RETCODE SCIPlinkLPSol(SCIP *scip, SCIP_SOL *sol)
Definition: scip.c:38570
SCIP_Real SCIPgetSolvingTime(SCIP *scip)
Definition: scip.c:46300
SCIP_RETCODE SCIPsetSeparating(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
Definition: scip.c:5158
#define DEFAULT_MINIMPROVE
Definition: heur_locks.c:42
SCIP_NODE * SCIPgetCurrentNode(SCIP *scip)
Definition: scip.c:41398
SCIP_RETCODE SCIPbacktrackProbing(SCIP *scip, int probingdepth)
Definition: scip.c:35958
SCIP_Longint SCIPgetNLPIterations(SCIP *scip)
Definition: scip.c:42327
SCIP_Bool SCIPisFeasLT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
Definition: scip.c:47305
SCIP_CONSHDLR * SCIPfindConshdlr(SCIP *scip, const char *name)
Definition: scip.c:6604
int SCIPgetProbingDepth(SCIP *scip)
Definition: scip.c:35931
#define SCIPallocClearBufferArray(scip, ptr, num)
Definition: scip.h:22622
SCIP_Longint SCIPheurGetNBestSolsFound(SCIP_HEUR *heur)
Definition: heur.c:1344
SCIP_RETCODE SCIPcreateRandom(SCIP *scip, SCIP_RANDNUMGEN **randnumgen, unsigned int initialseed)
Definition: scip.c:48602
SCIP_Real * SCIPcolGetVals(SCIP_COL *col)
Definition: lp.c:16360
int SCIProwGetNNonz(SCIP_ROW *row)
Definition: lp.c:16402
SCIP_Bool SCIPisPositive(SCIP *scip, SCIP_Real val)
Definition: scip.c:47082
int SCIPgetNOrigVars(SCIP *scip)
Definition: scip.c:12246
SCIP_Real SCIPvarGetLbLocal(SCIP_VAR *var)
Definition: var.c:17332
int SCIPgetNPseudoBranchCands(SCIP *scip)
Definition: scip.c:37359
const char * SCIProwGetName(SCIP_ROW *row)
Definition: lp.c:16540
static SCIP_DECL_HEUREXEC(heurExecLocks)
Definition: heur_locks.c:670
static SCIP_RETCODE createNewSol(SCIP *scip, SCIP *subscip, SCIP_VAR **subvars, SCIP_SOL *newsol, SCIP_SOL *subsol, SCIP_Bool *success)
Definition: heur_locks.c:86
SCIP_Bool SCIPisFeasGE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
Definition: scip.c:47344
SCIP_RETCODE SCIPgetVarsData(SCIP *scip, SCIP_VAR ***vars, int *nvars, int *nbinvars, int *nintvars, int *nimplvars, int *ncontvars)
Definition: scip.c:11680
SCIP_SOL ** SCIPgetSols(SCIP *scip)
Definition: scip.c:39826
SCIP_Real SCIProwGetLhs(SCIP_ROW *row)
Definition: lp.c:16481
#define FALSE
Definition: def.h:64
SCIP_RETCODE SCIPhashmapCreate(SCIP_HASHMAP **hashmap, BMS_BLKMEM *blkmem, int mapsize)
Definition: misc.c:2793
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:4293
SCIP_RETCODE SCIPcopyLimits(SCIP *sourcescip, SCIP *targetscip)
Definition: scip.c:4192
#define DEFAULT_RANDSEED
Definition: heur_locks.c:58
SCIP_RETCODE SCIPcutoffNode(SCIP *scip, SCIP_NODE *node)
Definition: scip.c:41741
#define TRUE
Definition: def.h:63
#define SCIPdebug(x)
Definition: pub_message.h:74
SCIP_RETCODE SCIPapplyLockFixings(SCIP *scip, SCIP_HEURDATA *heurdata, SCIP_Bool *cutoff, SCIP_Bool *allrowsfulfilled)
Definition: heur_locks.c:205
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
#define HEUR_DESC
Definition: heur_locks.c:30
SCIP_RETCODE SCIPincludeHeur(SCIP *scip, const char *name, const char *desc, char dispchar, int priority, int freq, int freqofs, int maxdepth, SCIP_HEURTIMING timingmask, SCIP_Bool usessubscip, SCIP_DECL_HEURCOPY((*heurcopy)), SCIP_DECL_HEURFREE((*heurfree)), SCIP_DECL_HEURINIT((*heurinit)), SCIP_DECL_HEUREXIT((*heurexit)), SCIP_DECL_HEURINITSOL((*heurinitsol)), SCIP_DECL_HEUREXITSOL((*heurexitsol)), SCIP_DECL_HEUREXEC((*heurexec)), SCIP_HEURDATA *heurdata)
Definition: scip.c:8034
SCIP_RETCODE SCIPsetPresolving(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
Definition: scip.c:5132
SCIP_BRANCHRULE * SCIPfindBranchrule(SCIP *scip, const char *name)
Definition: scip.c:9269
int SCIPvarGetProbindex(SCIP_VAR *var)
Definition: var.c:16969
struct SCIP_HeurData SCIP_HEURDATA
Definition: type_heur.h:51
#define SCIPfreeBlockMemory(scip, ptr)
Definition: scip.h:22602
#define HEUR_FREQ
Definition: heur_locks.c:33
#define SCIPduplicateBufferArray(scip, ptr, source, num)
Definition: scip.h:22628
void * SCIPhashmapGetImage(SCIP_HASHMAP *hashmap, void *origin)
Definition: misc.c:2931
SCIP_RETCODE SCIPconstructLP(SCIP *scip, SCIP_Bool *cutoff)
Definition: scip.c:29243
#define SCIP_LONGINT_MAX
Definition: def.h:135
#define SCIPfreeBufferArray(scip, ptr)
Definition: scip.h:22632
enum SCIP_LPSolStat SCIP_LPSOLSTAT
Definition: type_lp.h:42
SCIP_RETCODE SCIPcreate(SCIP **scip)
Definition: scip.c:748
#define SCIPallocBlockMemory(scip, ptr)
Definition: scip.h:22585
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
Definition: scip.c:1267
#define SCIPdebugMsg
Definition: scip.h:455
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:4265
#define DEFAULT_COPYCUTS
Definition: heur_locks.c:52
SCIP_RETCODE SCIPprintStatistics(SCIP *scip, FILE *file)
Definition: scip.c:45645
static SCIP_DECL_HEUREXIT(heurExitLocks)
Definition: heur_locks.c:182
#define DEFAULT_MINNODES
Definition: heur_locks.c:47
SCIP_Real SCIPgetRowMaxActivity(SCIP *scip, SCIP_ROW *row)
Definition: scip.c:30917
#define DEFAULT_ROUNDUPPROBABILITY
Definition: heur_locks.c:40
#define DEFAULT_MAXNODES
Definition: heur_locks.c:39
SCIP_Bool SCIPisLPConstructed(SCIP *scip)
Definition: scip.c:29220
SCIP_RETCODE SCIPsolve(SCIP *scip)
Definition: scip.c:16109
const char * SCIPheurGetName(SCIP_HEUR *heur)
Definition: heur.c:1198
SCIP_HEUR * SCIPfindHeur(SCIP *scip, const char *name)
Definition: scip.c:8225
SCIP_Bool SCIPisParamFixed(SCIP *scip, const char *name)
Definition: scip.c:4401
SCIP_ROW ** SCIPcolGetRows(SCIP_COL *col)
Definition: lp.c:16350
SCIP_RETCODE SCIPpropagateProbing(SCIP *scip, int maxproprounds, SCIP_Bool *cutoff, SCIP_Longint *ndomredsfound)
Definition: scip.c:36308
SCIP_RETCODE SCIPgetSolVals(SCIP *scip, SCIP_SOL *sol, int nvars, SCIP_VAR **vars, SCIP_Real *vals)
Definition: scip.c:38942
SCIP_RETCODE SCIPfixVarProbing(SCIP *scip, SCIP_VAR *var, SCIP_Real fixedval)
Definition: scip.c:36151
#define SCIPfreeBufferArrayNull(scip, ptr)
Definition: scip.h:22633
SCIP_RETCODE SCIPsetBoolParam(SCIP *scip, const char *name, SCIP_Bool value)
Definition: scip.c:4630
SCIP_STATUS SCIPgetStatus(SCIP *scip)
Definition: scip.c:928
SCIP_RETCODE SCIPpresolve(SCIP *scip)
Definition: scip.c:15948
static SCIP_DECL_HEURINIT(heurInitLocks)
Definition: heur_locks.c:162
SCIP_RETCODE SCIPcopyCuts(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool global, int *ncutsadded)
Definition: scip.c:3065
BMS_BLKMEM * SCIPblkmem(SCIP *scip)
Definition: scip.c:46725
static SCIP_DECL_HEURCOPY(heurCopyLocks)
Definition: heur_locks.c:130
SCIP_RETCODE SCIPendProbing(SCIP *scip)
Definition: scip.c:35993
const char * SCIPvarGetName(SCIP_VAR *var)
Definition: var.c:16662
void SCIPhashmapFree(SCIP_HASHMAP **hashmap)
Definition: misc.c:2826
SCIP_RETCODE SCIPgetBoolParam(SCIP *scip, const char *name, SCIP_Bool *value)
Definition: scip.c:4432
#define DEFAULT_NODESQUOT
Definition: heur_locks.c:49
#define DEFAULT_UPDATELOCKS
Definition: heur_locks.c:51
#define heurInitsolLocks
Definition: heur_locks.c:198
#define REALABS(x)
Definition: def.h:173
int SCIPgetNLPRows(SCIP *scip)
Definition: scip.c:29690
#define SCIP_CALL(x)
Definition: def.h:350
SCIP_Real SCIPgetLowerbound(SCIP *scip)
Definition: scip.c:43271
SCIP_Bool SCIPisFeasGT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
Definition: scip.c:47331
SCIP_RETCODE SCIPsolveProbingLP(SCIP *scip, int itlim, SCIP_Bool *lperror, SCIP_Bool *cutoff)
Definition: scip.c:36544
SCIP_Bool SCIPisFeasLE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
Definition: scip.c:47318
SCIP_Real SCIProwGetRhs(SCIP_ROW *row)
Definition: lp.c:16491
SCIP_Longint SCIPheurGetNCalls(SCIP_HEUR *heur)
Definition: heur.c:1324
SCIP_COL ** SCIProwGetCols(SCIP_ROW *row)
Definition: lp.c:16427
SCIP_Bool SCIPhasCurrentNodeLP(SCIP *scip)
Definition: scip.c:29202
#define SCIPallocBufferArray(scip, ptr, num)
Definition: scip.h:22620
SCIP_Real * SCIProwGetVals(SCIP_ROW *row)
Definition: lp.c:16437
#define HEUR_FREQOFS
Definition: heur_locks.c:34
SCIP_RETCODE SCIPcheckSol(SCIP *scip, SCIP_SOL *sol, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *feasible)
Definition: scip.c:40974
#define SCIP_Bool
Definition: def.h:61
SCIP_LPSOLSTAT SCIPgetLPSolstat(SCIP *scip)
Definition: scip.c:29287
#define HEUR_USESSUBSCIP
Definition: heur_locks.c:37
SCIP_RETCODE SCIProundSol(SCIP *scip, SCIP_SOL *sol, SCIP_Bool *success)
Definition: scip.c:40018
SCIP_RETCODE SCIPsetObjlimit(SCIP *scip, SCIP_Real objlimit)
Definition: scip.c:11240
#define DEFAULT_MAXPROPROUNDS
Definition: heur_locks.c:50
int SCIPgetDepth(SCIP *scip)
Definition: scip.c:43039
int SCIPvarGetNLocksUp(SCIP_VAR *var)
Definition: var.c:3217
#define heurExitsolLocks
Definition: heur_locks.c:199
SCIP_RETCODE SCIPsetIntParam(SCIP *scip, const char *name, int value)
Definition: scip.c:4688
SCIP_RETCODE SCIPincludeHeurLocks(SCIP *scip)
Definition: heur_locks.c:1074
SCIP_RETCODE SCIPfreeSol(SCIP *scip, SCIP_SOL **sol)
Definition: scip.c:38529
void SCIPenableVarHistory(SCIP *scip)
Definition: scip.c:25952
SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
Definition: var.c:17124
int SCIPgetNSols(SCIP *scip)
Definition: scip.c:39777
#define DEFAULT_USEFINALSUBMIP
Definition: heur_locks.c:55
int SCIPgetNRuns(SCIP *scip)
Definition: scip.c:42044
SCIP_COL * SCIPvarGetCol(SCIP_VAR *var)
Definition: var.c:16990
SCIP_RETCODE SCIPflushLP(SCIP *scip)
Definition: scip.c:29267
locks primal heuristic
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
Definition: scip.c:47033
SCIP_RETCODE SCIPtrySol(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:40694
#define SCIP_MAXTREEDEPTH
Definition: def.h:286
int SCIPgetNBinVars(SCIP *scip)
Definition: scip.c:11851
SCIP_Real SCIPrandomGetReal(SCIP_RANDNUMGEN *randnumgen, SCIP_Real minrandval, SCIP_Real maxrandval)
Definition: misc.c:9388
SCIP_Bool SCIPinProbing(SCIP *scip)
Definition: scip.c:35830
int SCIProwGetRank(SCIP_ROW *row)
Definition: lp.c:16570
int SCIPgetNVars(SCIP *scip)
Definition: scip.c:11806
#define HEUR_PRIORITY
Definition: heur_locks.c:32
#define HEUR_DISPCHAR
Definition: heur_locks.c:31
#define HEUR_NAME
Definition: heur_locks.c:29
int SCIPcolGetNNonz(SCIP_COL *col)
Definition: lp.c:16325
int SCIPvarGetNLocksDown(SCIP_VAR *var)
Definition: var.c:3162
SCIP_Real SCIPgetLPObjval(SCIP *scip)
Definition: scip.c:29366
SCIP_VAR * SCIPcolGetVar(SCIP_COL *col)
Definition: lp.c:16251
int SCIPgetNConss(SCIP *scip)
Definition: scip.c:12856
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:3795
SCIP_VARSTATUS SCIPvarGetStatus(SCIP_VAR *var)
Definition: var.c:16781
int SCIProwGetLPPos(SCIP_ROW *row)
Definition: lp.c:16670
#define SCIP_Real
Definition: def.h:149
#define HEUR_TIMING
Definition: heur_locks.c:36
SCIP_Bool SCIPisStopped(SCIP *scip)
Definition: scip.c:1145
SCIP_Real SCIPgetRowMinActivity(SCIP *scip, SCIP_ROW *row)
Definition: scip.c:30900
int SCIPconshdlrGetNCheckConss(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4535
static SCIP_DECL_HEURFREE(heurFreeLocks)
Definition: heur_locks.c:144
SCIP_RETCODE SCIPprintRow(SCIP *scip, SCIP_ROW *row, FILE *file)
Definition: scip.c:31154
#define SCIP_Longint
Definition: def.h:134
SCIP_RETCODE SCIPcheckCopyLimits(SCIP *sourcescip, SCIP_Bool *success)
Definition: scip.c:4156
SCIP_VARTYPE SCIPvarGetType(SCIP_VAR *var)
Definition: var.c:16827
SCIP_RETCODE SCIPsetSolVals(SCIP *scip, SCIP_SOL *sol, int nvars, SCIP_VAR **vars, SCIP_Real *vals)
Definition: scip.c:38807
#define HEUR_MAXDEPTH
Definition: heur_locks.c:35
SCIP_Real SCIPvarGetUbLocal(SCIP_VAR *var)
Definition: var.c:17342
SCIP_RETCODE SCIPnewProbingNode(SCIP *scip)
Definition: scip.c:35898
SCIP_Real SCIPsumepsilon(SCIP *scip)
Definition: scip.c:46423
SCIP_Real SCIPgetUpperbound(SCIP *scip)
Definition: scip.c:43420
SCIP_RETCODE SCIPstartProbing(SCIP *scip)
Definition: scip.c:35852
SCIP_RETCODE SCIPgetLPRowsData(SCIP *scip, SCIP_ROW ***rows, int *nrows)
Definition: scip.c:29634
#define SCIP_CALL_ABORT(x)
Definition: def.h:329
SCIP_HEURDATA * SCIPheurGetData(SCIP_HEUR *heur)
Definition: heur.c:1109
SCIP_Longint SCIPgetNNodes(SCIP *scip)
Definition: scip.c:42127
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:4321
SCIP_RETCODE SCIPsetSubscipsOff(SCIP *scip, SCIP_Bool quiet)
Definition: scip.c:5083
SCIP_RETCODE SCIPsetLongintParam(SCIP *scip, const char *name, SCIP_Longint value)
Definition: scip.c:4746
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:4239
SCIP_RETCODE SCIPfree(SCIP **scip)
Definition: scip.c:780
#define DEFAULT_MINFIXINGRATE
Definition: heur_locks.c:41
SCIP_RETCODE SCIPcreateSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
Definition: scip.c:37872
SCIP_RETCODE SCIPprintSol(SCIP *scip, SCIP_SOL *sol, FILE *file, SCIP_Bool printzeros)
Definition: scip.c:39319