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