Scippy

SCIP

Solving Constraint Integer Programs

heur_farkasdiving.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_farkasdiving.c
17  * @brief LP diving heuristic that tries to construct a Farkas-proof
18  * @author Jakob Witzig
19  *
20  * The heuristic dives into the direction of the pseudosolution, i.e., variables get rounded
21  * towards their best bound w.r.t there objective coefficient. This strategy is twofold, if
22  * a feasible solution is found the solution has potentially a very good objective value; on the other
23  * hand, the left-hand side of a potential Farkas-proof \f$y^Tb - y^TA{l',u'} > 0\f$ (i.e., infeasibility proof)
24  * gets increased, where \f$l',u'\f$ are the local bounds. The contribution of each variable \f$x_i\f$ to the
25  * Farkas-proof can be approximated by \f$c_i = y^TA_i\f$ because we only dive on basic variables with
26  * reduced costs \f$c_i - y^TA_i = 0\f$.
27  */
28 
29 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
30 
31 #include "blockmemshell/memory.h"
32 #include "scip/heur_farkasdiving.h"
33 #include "scip/heuristics.h"
34 #include "scip/pub_heur.h"
35 #include "scip/pub_message.h"
36 #include "scip/pub_misc.h"
37 #include "scip/pub_misc_sort.h"
38 #include "scip/pub_tree.h"
39 #include "scip/pub_var.h"
40 #include "scip/scip_branch.h"
41 #include "scip/scip_heur.h"
42 #include "scip/scip_lp.h"
43 #include "scip/scip_mem.h"
44 #include "scip/scip_message.h"
45 #include "scip/scip_numerics.h"
46 #include "scip/scip_param.h"
47 #include "scip/scip_prob.h"
48 #include "scip/scip_sol.h"
49 #include "scip/scip_tree.h"
50 #include <string.h>
51 
52 #define HEUR_NAME "farkasdiving"
53 #define HEUR_DESC "LP diving heuristic that tries to construct a Farkas-proof"
54 #define HEUR_DISPCHAR 'u'
55 #define HEUR_PRIORITY -900000
56 #define HEUR_FREQ 10
57 #define HEUR_FREQOFS 0
58 #define HEUR_MAXDEPTH -1
59 #define HEUR_TIMING SCIP_HEURTIMING_AFTERLPPLUNGE
60 #define HEUR_USESSUBSCIP FALSE /**< does the heuristic use a secondary SCIP instance? */
61 #define DIVESET_DIVETYPES SCIP_DIVETYPE_INTEGRALITY | SCIP_DIVETYPE_SOS1VARIABLE /**< bit mask that represents all supported dive types */
62 
63 
64 /*
65  * Default parameter settings
66  */
67 
68 #define DEFAULT_MINRELDEPTH 0.0 /**< minimal relative depth to start diving */
69 #define DEFAULT_MAXRELDEPTH 1.0 /**< maximal relative depth to start diving */
70 #define DEFAULT_MAXLPITERQUOT 0.05 /**< maximal fraction of diving LP iterations compared to node LP iterations */
71 #define DEFAULT_MAXLPITEROFS 1000 /**< additional number of allowed LP iterations */
72 #define DEFAULT_MAXDIVEUBQUOT 0.8 /**< maximal quotient (curlowerbound - lowerbound)/(cutoffbound - lowerbound)
73  * where diving is performed (0.0: no limit) */
74 #define DEFAULT_MAXDIVEAVGQUOT 0.0 /**< maximal quotient (curlowerbound - lowerbound)/(avglowerbound - lowerbound)
75  * where diving is performed (0.0: no limit) */
76 #define DEFAULT_MAXDIVEUBQUOTNOSOL 0.1 /**< maximal UBQUOT when no solution was found yet (0.0: no limit) */
77 #define DEFAULT_MAXDIVEAVGQUOTNOSOL 0.0 /**< maximal AVGQUOT when no solution was found yet (0.0: no limit) */
78 #define DEFAULT_BACKTRACK TRUE /**< use one level of backtracking if infeasibility is encountered? */
79 #define DEFAULT_LPRESOLVEDOMCHGQUOT 0.15 /**< percentage of immediate domain changes during probing to trigger LP resolve */
80 #define DEFAULT_LPSOLVEFREQ 1 /**< LP solve frequency for diving heuristics */
81 #define DEFAULT_ONLYLPBRANCHCANDS FALSE /**< should only LP branching candidates be considered instead of the slower but
82  * more general constraint handler diving variable selection? */
83 #define DEFAULT_RANDSEED 151 /**< initial seed for random number generation */
84 
85 #define DEFAULT_MAXOBJOCC 1.0 /**< maximal occurance factor of an objective coefficient */
86 #define DEFAULT_OBJDYN 0.0001 /**< minimal objective dynamism (log) */
87 #define DEFAULT_CHECKCANDS FALSE /**< should diving candidates be checked before running? */
88 #define DEFAULT_SCALESCORE TRUE /**< should the score be scaled? */
89 #define DEFAULT_ROOTSUCCESS TRUE /**< should the heuristic only run within the tree if at least one solution
90  * was found at the root node? */
91 #define DEFAULT_SCALETYPE 'i' /**< scale score by [f]ractionality or [i]mpact on farkasproof */
92 
93 /* locally defined heuristic data */
94 struct SCIP_HeurData
95 {
96  SCIP_SOL* sol; /**< working solution */
97  SCIP_Real maxobjocc; /**< maximal occurance factor of an objective coefficient */
98  SCIP_Real objdynamism; /**< minimal objective dynamism (log) */
99  SCIP_Bool disabled; /**< remember if the heuristic should not run at all */
100  SCIP_Bool glbchecked; /**< remember whether one global check was performed */
101  SCIP_Bool checkcands; /**< should diving candidates be checked before running? */
102  SCIP_Bool scalescore; /**< should score be scaled by fractionality */
103  SCIP_Bool rootsuccess; /**< run if successfull at root */
104  SCIP_Bool foundrootsol; /**< was a solution found at the root node? */
105  char scaletype; /**< scale score by [f]ractionality or [i]mpact on farkasproof */
106 };
107 
108 
109 /** check whether the diving candidates fulfill requirements */
110 static
112  SCIP* scip, /**< SCIP data structure */
113  SCIP_HEURDATA* heurdata, /**< heuristic data */
114  SCIP_VAR** divecandvars, /**< diving candidates to check */
115  int ndivecands, /**< number of diving candidates */
116  SCIP_Bool* success /**< pointer to store whether the check was successfull */
117  )
118 {
119  SCIP_Real* objcoefs;
120  SCIP_Real lastobjcoef;
121  SCIP_Real objdynamism;
122  int maxfreq;
123  int nnzobjcoefs;
124 #ifdef SCIP_DEBUG
125  int ndiffnnzobjs;
126 #endif
127  int i;
128 
129  *success = TRUE;
130 
131  assert(heurdata != NULL);
132  assert(divecandvars != NULL);
133  assert(ndivecands >= 0);
134 
135  SCIP_CALL( SCIPallocBufferArray(scip, &objcoefs, ndivecands) );
136 
137  /* collect all absolute values of objective coefficients and count binary, integer,
138  * and implicit integer in the objective function
139  */
140  nnzobjcoefs = 0;
141 
142  if( SCIPgetNObjVars(scip) > 0 )
143  {
144  for( i = 0; i < ndivecands; i++ )
145  {
146  SCIP_Real obj = SCIPvarGetObj(divecandvars[i]);
147 
148  if( SCIPisZero(scip, obj) )
149  continue;
150 
151  objcoefs[nnzobjcoefs] = REALABS(obj);
152  ++nnzobjcoefs;
153  }
154  }
155 
156  if( nnzobjcoefs == 0 )
157  {
158  *success = FALSE;
159  goto TERMINATE;
160  }
161  assert(nnzobjcoefs > 0);
162 
163  /* skip here if we are cheching the global properties and want to check the local candidates, too */
164  if( !heurdata->glbchecked && heurdata->checkcands )
165  goto TERMINATE;
166 
167  /* sort in increasing order */
168  SCIPsortReal(objcoefs, nnzobjcoefs);
169  assert(!SCIPisZero(scip, objcoefs[0]));
170 
171  lastobjcoef = objcoefs[0];
172 #ifdef SCIP_DEBUG
173  ndiffnnzobjs = 1;
174 #endif
175 
176  objdynamism = log10(objcoefs[nnzobjcoefs-1] / objcoefs[0]);
177 
178  SCIPdebugMsg(scip, "minabscoef: %g, maxabscoef: %g, objdym: %g\n", objcoefs[0], objcoefs[nnzobjcoefs-1], objdynamism);
179 
180  /* CHECK#2: check objective dynamism */
181  if( objdynamism < heurdata->objdynamism )
182  {
183  SCIPdebugMsg(scip, " ---> disable farkasdiving at node %lld\n", SCIPnodeGetNumber(SCIPgetCurrentNode(scip)));
184 
185  *success = FALSE;
186  goto TERMINATE;
187  }
188 
189  /* CHECK#4: the check would be always fulfilled for heurdata->maxobjocc = 1.0 */
190  if( heurdata->maxobjocc < 1.0 )
191  {
192  int tmpmaxfreq;
193 
194  tmpmaxfreq = 0;
195  maxfreq = 0;
196 
197  /* count number of different absolute objective values */
198  for( i = 1; i < nnzobjcoefs; i++ )
199  {
200  if( SCIPisGT(scip, objcoefs[i], lastobjcoef) )
201  {
202  if( tmpmaxfreq > maxfreq )
203  maxfreq = tmpmaxfreq;
204  tmpmaxfreq = 0;
205 
206  lastobjcoef = objcoefs[i];
207 #ifdef SCIP_DEBUG
208  ++ndiffnnzobjs;
209 #endif
210  }
211  else
212  {
213  ++tmpmaxfreq;
214  }
215  }
216 
217 #ifdef SCIP_DEBUG
218  SCIPdebugMsg(scip, "%d divecands; %d nnzobjs; %d diffnnzobjs; %d maxfreq\n", ndivecands, nnzobjcoefs, ndiffnnzobjs,
219  maxfreq, heurdata->maxobjocc * nnzobjcoefs);
220 #endif
221 
222  if( maxfreq > heurdata->maxobjocc * nnzobjcoefs )
223  {
224  SCIPdebugMsg(scip, " ---> disable farkasdiving at node %lld\n", SCIPnodeGetNumber(SCIPgetCurrentNode(scip)));
225 
226  *success = FALSE;
227  }
228  }
229 
230  TERMINATE:
231  SCIPfreeBufferArray(scip, &objcoefs);
232 
233  return SCIP_OKAY;
234 }
235 
236 
237 /** check whether the objective functions has nonzero coefficients corresponding to binary and integer variables */
238 static
240  SCIP* scip, /**< SCIP data structure */
241  SCIP_HEURDATA* heurdata /**< heuristic data */
242  )
243 {
244  SCIP_VAR** vars;
245  SCIP_Bool success;
246  int nbinvars;
247  int nintvars;
248 
249  assert(scip != NULL);
250  assert(heurdata != NULL);
251 
252  vars = SCIPgetVars(scip);
253  nbinvars = SCIPgetNBinVars(scip);
254  nintvars = SCIPgetNIntVars(scip);
255 
256  SCIP_CALL( checkDivingCandidates(scip, heurdata, vars, nbinvars+nintvars, &success) );
257 
258  if( !success )
259  {
260  SCIPdebugMsg(scip, " ---> disable farkasdiving (at least one global property is violated)\n");
261  heurdata->disabled = TRUE;
262  }
263 
264  heurdata->glbchecked = TRUE;
265 
266  return SCIP_OKAY;
267 }
268 
269 /*
270  * Callback methods
271  */
272 
273 /** copy method for primal heuristic plugins (called when SCIP copies plugins) */
274 static
275 SCIP_DECL_HEURCOPY(heurCopyFarkasdiving)
276 { /*lint --e{715}*/
277  assert(scip != NULL);
278  assert(heur != NULL);
279  assert(strcmp(SCIPheurGetName(heur), HEUR_NAME) == 0);
280 
281  /* call inclusion method of primal heuristic */
283 
284  return SCIP_OKAY;
285 }
286 
287 /** destructor of primal heuristic to free user data (called when SCIP is exiting) */
288 static
289 SCIP_DECL_HEURFREE(heurFreeFarkasdiving)
290 { /*lint --e{715}*/
291  SCIP_HEURDATA* heurdata;
292 
293  assert(heur != NULL);
294  assert(strcmp(SCIPheurGetName(heur), HEUR_NAME) == 0);
295  assert(scip != NULL);
296 
297  /* free heuristic data */
298  heurdata = SCIPheurGetData(heur);
299  assert(heurdata != NULL);
300 
301  SCIPfreeBlockMemory(scip, &heurdata);
302  SCIPheurSetData(heur, NULL);
303 
304  return SCIP_OKAY;
305 }
306 
307 
308 /** initialization method of primal heuristic (called after problem was transformed) */
309 static
310 SCIP_DECL_HEURINIT(heurInitFarkasdiving)
311 { /*lint --e{715}*/
312  SCIP_HEURDATA* heurdata;
313 
314  assert(heur != NULL);
315  assert(strcmp(SCIPheurGetName(heur), HEUR_NAME) == 0);
316 
317  /* get heuristic data */
318  heurdata = SCIPheurGetData(heur);
319  assert(heurdata != NULL);
320 
321  /* create working solution */
322  SCIP_CALL( SCIPcreateSol(scip, &heurdata->sol, heur) );
323 
324  heurdata->disabled = FALSE;
325  heurdata->glbchecked = FALSE;
326 
327  return SCIP_OKAY;
328 }
329 
330 
331 /** deinitialization method of primal heuristic (called before transformed problem is freed) */
332 static
333 SCIP_DECL_HEUREXIT(heurExitFarkasdiving)
334 { /*lint --e{715}*/
335  SCIP_HEURDATA* heurdata;
336 
337  assert(heur != NULL);
338  assert(strcmp(SCIPheurGetName(heur), HEUR_NAME) == 0);
339 
340  /* get heuristic data */
341  heurdata = SCIPheurGetData(heur);
342  assert(heurdata != NULL);
343 
344  /* free working solution */
345  SCIP_CALL( SCIPfreeSol(scip, &heurdata->sol) );
346 
347  return SCIP_OKAY;
348 }
349 
350 /** solving process initialization method of primal heuristic (called when branch and bound process is about to begin) */
351 static
352 SCIP_DECL_HEURINITSOL(heurInitsolFarkasdiving)
353 { /*lint --e{715}*/
354  SCIP_HEURDATA* heurdata;
355 
356  assert(heur != NULL);
357  assert(strcmp(SCIPheurGetName(heur), HEUR_NAME) == 0);
358 
359  /* get heuristic data */
360  heurdata = SCIPheurGetData(heur);
361  assert(heurdata != NULL);
362 
363  heurdata->glbchecked = FALSE;
364  heurdata->disabled = FALSE;
365  heurdata->foundrootsol = FALSE;
366 
367  return SCIP_OKAY;
368 }
369 
370 /** execution method of primal heuristic */
371 static
372 SCIP_DECL_HEUREXEC(heurExecFarkasdiving)
373 { /*lint --e{715}*/
374  SCIP_HEURDATA* heurdata;
375  SCIP_DIVESET* diveset;
376  SCIP_Bool success;
377 
378  heurdata = SCIPheurGetData(heur);
379  assert(SCIPheurGetNDivesets(heur) > 0);
380  assert(SCIPheurGetDivesets(heur) != NULL);
381 
382  diveset = SCIPheurGetDivesets(heur)[0];
383  assert(diveset != NULL);
384 
385  *result = SCIP_DIDNOTRUN;
386 
387  /* check some simple global properties that are needed to run this heuristic */
388  if( !heurdata->glbchecked )
389  {
390  SCIP_CALL( checkGlobalProperties(scip, heurdata) );
391  }
392 
393  /* terminate if the heuristic has been disabled */
394  if( heurdata->disabled )
395  return SCIP_OKAY;
396 
397  if( heurdata->rootsuccess && !heurdata->foundrootsol && SCIPgetDepth(scip) > 0 )
398  {
399  heurdata->disabled = TRUE;
400  return SCIP_OKAY;
401  }
402 
403  success = TRUE;
404 
405  /* check diving candidates in detail */
406  if( heurdata->checkcands )
407  {
408  SCIP_VAR** divecandvars;
409  int ndivecands;
410 
411  /* we can only access the branching candidates if the LP is solved to optimality */
413  {
414  SCIP_CALL( SCIPgetLPBranchCands(scip, &divecandvars, NULL, NULL, &ndivecands, NULL, NULL) );
415 
416  SCIP_CALL( checkDivingCandidates(scip, heurdata, divecandvars, ndivecands, &success) );
417  }
418  else
419  {
420  success = FALSE;
421  }
422  }
423 
424  if( success )
425  {
426  SCIP_CALL( SCIPperformGenericDivingAlgorithm(scip, diveset, heurdata->sol, heur, result, nodeinfeasible) );
427 
428  if( heurdata->rootsuccess && SCIPgetDepth(scip) == 0 && SCIPdivesetGetNSols(diveset) > 0 )
429  heurdata->foundrootsol = TRUE;
430  }
431 
432  return SCIP_OKAY;
433 }
434 
435 #define MIN_RAND 1e-06
436 #define MAX_RAND 1e-05
437 
438 /** calculate score and preferred rounding direction for the candidate variable */
439 static
440 SCIP_DECL_DIVESETGETSCORE(divesetGetScoreFarkasdiving)
441 { /*lint --e{715}*/
442  SCIP_HEUR* heur;
443  SCIP_HEURDATA* heurdata;
444  SCIP_RANDNUMGEN* randnumgen;
445  SCIP_Real obj;
446 
447  heur = SCIPdivesetGetHeur(diveset);
448  assert(heur != NULL);
449 
450  heurdata = SCIPheurGetData(heur);
451  assert(heurdata != NULL);
452 
453  randnumgen = SCIPdivesetGetRandnumgen(diveset);
454  assert(randnumgen != NULL);
455 
456  obj = SCIPvarGetObj(cand);
457 
458  /* dive towards the pseudosolution, at the same time approximate the contribution to
459  * a potentially Farkas-proof (infeasibility proof) by y^TA_i = c_i.
460  */
461  if( SCIPisNegative(scip, obj) )
462  {
463  *roundup = TRUE;
464  }
465  else if( SCIPisPositive(scip, obj) )
466  {
467  *roundup = FALSE;
468  }
469  else
470  {
471  if( SCIPisEQ(scip, candsfrac, 0.5) )
472  *roundup = !SCIPrandomGetInt(randnumgen, 0, 1);
473  else
474  *roundup = (candsfrac > 0.5);
475  }
476 
477  /* larger score is better */
478  *score = REALABS(obj) + SCIPrandomGetReal(randnumgen, MIN_RAND, MAX_RAND);
479 
480  if( heurdata->scalescore )
481  {
482  if( heurdata->scaletype == 'f' )
483  {
484  if( *roundup )
485  *score *= (1.0 - candsfrac);
486  else
487  *score *= candsfrac;
488  }
489  else
490  {
491  assert(heurdata->scaletype == 'i');
492 
493  if( *roundup )
494  *score *= (SCIPceil(scip, candsol) - SCIPvarGetLbLocal(cand));
495  else
496  *score *= (SCIPvarGetUbLocal(cand) - SCIPfloor(scip, candsol));
497  }
498  }
499 
500  /* prefer decisions on binary variables */
501  if( SCIPvarGetType(cand) != SCIP_VARTYPE_BINARY )
502  *score = -1.0 / *score;
503 
504  return SCIP_OKAY;
505 }
506 
507 /*
508  * heuristic specific interface methods
509  */
510 
511 /** creates the farkasdiving heuristic and includes it in SCIP */
513  SCIP* scip /**< SCIP data structure */
514  )
515 {
516  SCIP_HEURDATA* heurdata;
517  SCIP_HEUR* heur;
518 
519  /* create Farkasdiving primal heuristic data */
520  SCIP_CALL( SCIPallocBlockMemory(scip, &heurdata) );
521 
522  /* include primal heuristic */
523  SCIP_CALL( SCIPincludeHeurBasic(scip, &heur,
525  HEUR_MAXDEPTH, HEUR_TIMING, HEUR_USESSUBSCIP, heurExecFarkasdiving, heurdata) );
526 
527  assert(heur != NULL);
528 
529  /* set non-NULL pointers to callback methods */
530  SCIP_CALL( SCIPsetHeurCopy(scip, heur, heurCopyFarkasdiving) );
531  SCIP_CALL( SCIPsetHeurFree(scip, heur, heurFreeFarkasdiving) );
532  SCIP_CALL( SCIPsetHeurInit(scip, heur, heurInitFarkasdiving) );
533  SCIP_CALL( SCIPsetHeurExit(scip, heur, heurExitFarkasdiving) );
534  SCIP_CALL( SCIPsetHeurInitsol(scip, heur, heurInitsolFarkasdiving) );
535 
536  /* farkasdiving heuristic parameters */
537  /* create a diveset (this will automatically install some additional parameters for the heuristic) */
541 
542  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/" HEUR_NAME "/checkcands",
543  "should diving candidates be checked before running?",
544  &heurdata->checkcands, TRUE, DEFAULT_CHECKCANDS, NULL, NULL) );
545 
546  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/" HEUR_NAME "/scalescore",
547  "should the score be scaled?",
548  &heurdata->scalescore, TRUE, DEFAULT_SCALESCORE, NULL, NULL) );
549 
550  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/" HEUR_NAME "/rootsuccess",
551  "should the heuristic only run within the tree if at least one solution was found at the root node?",
552  &heurdata->rootsuccess, TRUE, DEFAULT_ROOTSUCCESS, NULL, NULL) );
553 
554  SCIP_CALL( SCIPaddRealParam(scip, "heuristics/" HEUR_NAME "/maxobjocc",
555  "maximal occurance factor of an objective coefficient",
556  &heurdata->maxobjocc, TRUE, DEFAULT_MAXOBJOCC, 0.0, 1.0, NULL, NULL) );
557 
558  SCIP_CALL( SCIPaddRealParam(scip, "heuristics/" HEUR_NAME "/objdynamism",
559  "minimal objective dynamism (log) to run",
560  &heurdata->objdynamism, TRUE, DEFAULT_OBJDYN, 0.0, SCIPinfinity(scip), NULL, NULL) );
561 
562  SCIP_CALL( SCIPaddCharParam(scip, "heuristics/" HEUR_NAME "/scaletype",
563  "scale score by [f]ractionality or [i]mpact on farkasproof",
564  &heurdata->scaletype, TRUE, DEFAULT_SCALETYPE, "fi", NULL, NULL) );
565 
566 
567  return SCIP_OKAY;
568 }
569 
SCIP_RETCODE SCIPgetLPBranchCands(SCIP *scip, SCIP_VAR ***lpcands, SCIP_Real **lpcandssol, SCIP_Real **lpcandsfrac, int *nlpcands, int *npriolpcands, int *nfracimplvars)
Definition: scip_branch.c:384
int SCIPgetNIntVars(SCIP *scip)
Definition: scip_prob.c:2134
#define DEFAULT_MINRELDEPTH
#define NULL
Definition: def.h:239
#define DEFAULT_SCALESCORE
static SCIP_RETCODE checkGlobalProperties(SCIP *scip, SCIP_HEURDATA *heurdata)
public methods for SCIP parameter handling
SCIP_NODE * SCIPgetCurrentNode(SCIP *scip)
Definition: scip_tree.c:158
public methods for branch and bound tree
public methods for memory management
#define HEUR_TIMING
SCIP_RETCODE SCIPsetHeurExit(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEUREXIT((*heurexit)))
Definition: scip_heur.c:280
SCIP_Bool SCIPisPositive(SCIP *scip, SCIP_Real val)
SCIP_Real SCIPvarGetLbLocal(SCIP_VAR *var)
Definition: var.c:17399
#define HEUR_DISPCHAR
#define DEFAULT_RANDSEED
SCIP_DIVESET ** SCIPheurGetDivesets(SCIP_HEUR *heur)
Definition: heur.c:1452
static SCIP_DECL_HEURINIT(heurInitFarkasdiving)
#define DEFAULT_MAXDIVEAVGQUOTNOSOL
#define DEFAULT_CHECKCANDS
#define FALSE
Definition: def.h:65
#define DEFAULT_MAXOBJOCC
SCIP_Real SCIPinfinity(SCIP *scip)
SCIP_Bool SCIPisNegative(SCIP *scip, SCIP_Real val)
#define TRUE
Definition: def.h:64
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
methods commonly used by primal heuristics
#define DEFAULT_MAXDIVEUBQUOTNOSOL
SCIP_Longint SCIPdivesetGetNSols(SCIP_DIVESET *diveset)
Definition: heur.c:508
struct SCIP_HeurData SCIP_HEURDATA
Definition: type_heur.h:51
public methods for problem variables
#define SCIPfreeBlockMemory(scip, ptr)
Definition: scip_mem.h:114
SCIP_RETCODE SCIPincludeHeurBasic(SCIP *scip, SCIP_HEUR **heur, const char *name, const char *desc, char dispchar, int priority, int freq, int freqofs, int maxdepth, SCIP_HEURTIMING timingmask, SCIP_Bool usessubscip, SCIP_DECL_HEUREXEC((*heurexec)), SCIP_HEURDATA *heurdata)
Definition: scip_heur.c:187
int SCIPrandomGetInt(SCIP_RANDNUMGEN *randnumgen, int minrandval, int maxrandval)
Definition: misc.c:9372
SCIP_Bool SCIPisEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
#define DEFAULT_SCALETYPE
#define SCIPfreeBufferArray(scip, ptr)
Definition: scip_mem.h:142
void SCIPheurSetData(SCIP_HEUR *heur, SCIP_HEURDATA *heurdata)
Definition: heur.c:1175
#define MAX_RAND
#define SCIPallocBlockMemory(scip, ptr)
Definition: scip_mem.h:97
#define DEFAULT_BACKTRACK
#define SCIPdebugMsg
Definition: scip_message.h:88
public methods for numerical tolerances
#define DEFAULT_OBJDYN
public methods for the branch-and-bound tree
SCIP_HEUR * SCIPdivesetGetHeur(SCIP_DIVESET *diveset)
Definition: heur.c:325
SCIP_Longint SCIPnodeGetNumber(SCIP_NODE *node)
Definition: tree.c:7344
static SCIP_DECL_HEUREXEC(heurExecFarkasdiving)
#define HEUR_PRIORITY
#define DEFAULT_MAXLPITERQUOT
static SCIP_DECL_HEURFREE(heurFreeFarkasdiving)
SCIP_RETCODE SCIPsetHeurInitsol(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURINITSOL((*heurinitsol)))
Definition: scip_heur.c:296
const char * SCIPheurGetName(SCIP_HEUR *heur)
Definition: heur.c:1254
SCIP_RETCODE SCIPincludeHeurFarkasdiving(SCIP *scip)
LP diving heuristic that tries to construct a Farkas-proof.
SCIP_RETCODE SCIPsetHeurFree(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURFREE((*heurfree)))
Definition: scip_heur.c:248
#define DEFAULT_MAXDIVEUBQUOT
#define MIN_RAND
void SCIPsortReal(SCIP_Real *realarray, int len)
SCIP_SOL * sol
Definition: struct_heur.h:41
static SCIP_RETCODE checkDivingCandidates(SCIP *scip, SCIP_HEURDATA *heurdata, SCIP_VAR **divecandvars, int ndivecands, SCIP_Bool *success)
static SCIP_DECL_DIVESETGETSCORE(divesetGetScoreFarkasdiving)
#define REALABS(x)
Definition: def.h:174
#define SCIP_CALL(x)
Definition: def.h:351
#define DEFAULT_LPRESOLVEDOMCHGQUOT
int SCIPheurGetNDivesets(SCIP_HEUR *heur)
Definition: heur.c:1462
public methods for primal heuristic plugins and divesets
#define DEFAULT_ONLYLPBRANCHCANDS
#define SCIPallocBufferArray(scip, ptr, num)
Definition: scip_mem.h:130
#define DEFAULT_MAXRELDEPTH
public data structures and miscellaneous methods
#define SCIP_Bool
Definition: def.h:62
SCIP_LPSOLSTAT SCIPgetLPSolstat(SCIP *scip)
Definition: scip_lp.c:226
#define HEUR_DESC
int SCIPgetDepth(SCIP *scip)
Definition: scip_tree.c:715
SCIP_RANDNUMGEN * SCIPdivesetGetRandnumgen(SCIP_DIVESET *diveset)
Definition: heur.c:584
SCIP_RETCODE SCIPcreateDiveset(SCIP *scip, SCIP_DIVESET **diveset, SCIP_HEUR *heur, const char *name, SCIP_Real minreldepth, SCIP_Real maxreldepth, SCIP_Real maxlpiterquot, SCIP_Real maxdiveubquot, SCIP_Real maxdiveavgquot, SCIP_Real maxdiveubquotnosol, SCIP_Real maxdiveavgquotnosol, SCIP_Real lpresolvedomchgquot, int lpsolvefreq, int maxlpiterofs, unsigned int initialseed, SCIP_Bool backtrack, SCIP_Bool onlylpbranchcands, SCIP_Bool specificsos1score, SCIP_DECL_DIVESETGETSCORE((*divesetgetscore)))
Definition: scip_heur.c:390
SCIP_RETCODE SCIPfreeSol(SCIP *scip, SCIP_SOL **sol)
Definition: scip_sol.c:1034
SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
Definition: var.c:17191
int SCIPgetNObjVars(SCIP *scip)
Definition: scip_prob.c:2272
#define HEUR_USESSUBSCIP
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
public methods for the LP relaxation, rows and columns
SCIP_RETCODE SCIPperformGenericDivingAlgorithm(SCIP *scip, SCIP_DIVESET *diveset, SCIP_SOL *worksol, SCIP_HEUR *heur, SCIP_RESULT *result, SCIP_Bool nodeinfeasible)
Definition: heuristics.c:192
static SCIP_DECL_HEURCOPY(heurCopyFarkasdiving)
#define DEFAULT_MAXDIVEAVGQUOT
methods for sorting joint arrays of various types
#define DEFAULT_LPSOLVEFREQ
public methods for branching rule plugins and branching
#define HEUR_NAME
#define DIVESET_DIVETYPES
SCIP_Bool SCIPisGT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_RETCODE SCIPaddCharParam(SCIP *scip, const char *name, const char *desc, char *valueptr, SCIP_Bool isadvanced, char defaultvalue, const char *allowedvalues, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
Definition: scip_param.c:239
public methods for solutions
static SCIP_DECL_HEURINITSOL(heurInitsolFarkasdiving)
public methods for message output
SCIP_RETCODE SCIPsetHeurInit(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURINIT((*heurinit)))
Definition: scip_heur.c:264
SCIP_VAR ** SCIPgetVars(SCIP *scip)
Definition: scip_prob.c:1999
#define HEUR_FREQOFS
#define SCIP_Real
Definition: def.h:150
static SCIP_DECL_HEUREXIT(heurExitFarkasdiving)
public methods for message handling
#define HEUR_FREQ
SCIP_VARTYPE SCIPvarGetType(SCIP_VAR *var)
Definition: var.c:16894
SCIP_Bool SCIPisZero(SCIP *scip, SCIP_Real val)
#define DEFAULT_ROOTSUCCESS
SCIP_RETCODE SCIPsetHeurCopy(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURCOPY((*heurcopy)))
Definition: scip_heur.c:232
SCIP_Real SCIPvarGetUbLocal(SCIP_VAR *var)
Definition: var.c:17409
#define DEFAULT_MAXLPITEROFS
public methods for primal heuristics
SCIP_Real SCIPceil(SCIP *scip, SCIP_Real val)
SCIP_HEURDATA * SCIPheurGetData(SCIP_HEUR *heur)
Definition: heur.c:1165
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_Real SCIPfloor(SCIP *scip, SCIP_Real val)
#define HEUR_MAXDEPTH
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 SCIPcreateSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
Definition: scip_sol.c:377
memory allocation routines