Scippy

SCIP

Solving Constraint Integer Programs

heur.h
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-2016 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.h
17  * @brief internal methods for primal heuristics
18  * @author Tobias Achterberg
19  */
20 
21 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
22 
23 #ifndef __SCIP_HEUR_H__
24 #define __SCIP_HEUR_H__
25 
26 
27 #include "scip/def.h"
28 #include "blockmemshell/memory.h"
29 #include "scip/type_retcode.h"
30 #include "scip/type_result.h"
31 #include "scip/type_set.h"
32 #include "scip/type_primal.h"
33 #include "scip/type_heur.h"
34 #include "scip/pub_heur.h"
35 #include "scip/stat.h"
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 /** create a set of diving heuristic settings */
42 extern
44  SCIP_DIVESET** diveset, /**< pointer to the freshly created diveset */
45  SCIP_HEUR* heur, /**< the heuristic to which this dive setting belongs */
46  const char* name, /**< name for the diveset, or NULL if the name of the heuristic should be used */
47  SCIP_SET* set, /**< global SCIP settings */
48  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
49  BMS_BLKMEM* blkmem, /**< block memory for parameter settings */
50  SCIP_Real minreldepth, /**< minimal relative depth to start diving */
51  SCIP_Real maxreldepth, /**< maximal relative depth to start diving */
52  SCIP_Real maxlpiterquot, /**< maximal fraction of diving LP iterations compared to node LP iterations */
53  SCIP_Real maxdiveubquot, /**< maximal quotient (curlowerbound - lowerbound)/(cutoffbound - lowerbound)
54  * where diving is performed (0.0: no limit) */
55  SCIP_Real maxdiveavgquot, /**< maximal quotient (curlowerbound - lowerbound)/(avglowerbound - lowerbound)
56  * where diving is performed (0.0: no limit) */
57  SCIP_Real maxdiveubquotnosol, /**< maximal UBQUOT when no solution was found yet (0.0: no limit) */
58  SCIP_Real maxdiveavgquotnosol,/**< maximal AVGQUOT when no solution was found yet (0.0: no limit) */
59  SCIP_Real lpresolvedomchgquot,/**< percentage of immediate domain changes during probing to trigger LP resolve */
60  int lpsolvefreq, /**< LP solve frequency for (0: only if enough domain reductions are found by propagation)*/
61  int maxlpiterofs, /**< additional number of allowed LP iterations */
62  SCIP_Bool backtrack, /**< use one level of backtracking if infeasibility is encountered? */
63  SCIP_Bool onlylpbranchcands, /**< should only LP branching candidates be considered instead of the slower but
64  * more general constraint handler diving variable selection? */
65  SCIP_DIVETYPE divetypemask, /**< bit mask that represents the supported dive types by this dive set */
66  SCIP_DECL_DIVESETGETSCORE((*divesetgetscore)) /**< method for candidate score and rounding direction */
67  );
68 
69 /** resets diving settings counters */
70 extern
71 void SCIPdivesetReset(
72  SCIP_DIVESET* diveset /**< diveset to be reset */
73  );
74 
75 /** update diveset statistics and global diveset statistics */
76 extern
78  SCIP_DIVESET* diveset, /**< diveset to be reset */
79  SCIP_STAT* stat, /**< global SCIP statistics */
80  int depth, /**< the depth reached this time */
81  int nprobingnodes, /**< the number of probing nodes explored this time */
82  int nbacktracks, /**< the number of backtracks during probing this time */
83  SCIP_Longint nsolsfound, /**< number of new solutions found this time */
84  SCIP_Longint nbestsolsfound, /**< number of new best solutions found this time */
85  SCIP_Bool leavesol /**< has the diving heuristic reached a feasible leaf */
86  );
87 
88 /** get the candidate score and preferred rounding direction for a candidate variable */
89 extern
91  SCIP_DIVESET* diveset, /**< general diving settings */
92  SCIP_SET* set, /**< SCIP settings */
93  SCIP_DIVETYPE divetype, /**< the type of diving that should be applied */
94  SCIP_VAR* divecand, /**< the candidate for which the branching direction is requested */
95  SCIP_Real divecandsol, /**< LP solution value of the candidate */
96  SCIP_Real divecandfrac, /**< fractionality of the candidate */
97  SCIP_Real* candscore, /**< pointer to store the candidate score */
98  SCIP_Bool* roundup /**< pointer to store whether preferred direction for diving is upwards */
99  );
100 
101 /** update diveset LP statistics, should be called after every LP solved by this diving heuristic */
102 extern
104  SCIP_DIVESET* diveset, /**< diving settings */
105  SCIP_STAT* stat, /**< global SCIP statistics */
106  SCIP_Longint niterstoadd /**< additional number of LP iterations to be added */
107  );
108 
109 /** copies the given primal heuristic to a new scip */
110 extern
112  SCIP_HEUR* heur, /**< primal heuristic */
113  SCIP_SET* set /**< SCIP_SET of SCIP to copy to */
114  );
115 
116 /** creates a primal heuristic */
117 extern
119  SCIP_HEUR** heur, /**< pointer to primal heuristic data structure */
120  SCIP_SET* set, /**< global SCIP settings */
121  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
122  BMS_BLKMEM* blkmem, /**< block memory for parameter settings */
123  const char* name, /**< name of primal heuristic */
124  const char* desc, /**< description of primal heuristic */
125  char dispchar, /**< display character of primal heuristic */
126  int priority, /**< priority of the primal heuristic */
127  int freq, /**< frequency for calling primal heuristic */
128  int freqofs, /**< frequency offset for calling primal heuristic */
129  int maxdepth, /**< maximal depth level to call heuristic at (-1: no limit) */
130  unsigned int timingmask, /**< positions in the node solving loop where heuristic should be executed */
131  SCIP_Bool usessubscip, /**< does the heuristic use a secondary SCIP instance? */
132  SCIP_DECL_HEURCOPY ((*heurcopy)), /**< copy method of primal heuristic or NULL if you don't want to copy your plugin into sub-SCIPs */
133  SCIP_DECL_HEURFREE ((*heurfree)), /**< destructor of primal heuristic */
134  SCIP_DECL_HEURINIT ((*heurinit)), /**< initialize primal heuristic */
135  SCIP_DECL_HEUREXIT ((*heurexit)), /**< deinitialize primal heuristic */
136  SCIP_DECL_HEURINITSOL ((*heurinitsol)), /**< solving process initialization method of primal heuristic */
137  SCIP_DECL_HEUREXITSOL ((*heurexitsol)), /**< solving process deinitialization method of primal heuristic */
138  SCIP_DECL_HEUREXEC ((*heurexec)), /**< execution method of primal heuristic */
139  SCIP_HEURDATA* heurdata /**< primal heuristic data */
140  );
141 
142 /** calls destructor and frees memory of primal heuristic */
143 extern
145  SCIP_HEUR** heur, /**< pointer to primal heuristic data structure */
146  SCIP_SET* set /**< global SCIP settings */
147  );
148 
149 /** initializes primal heuristic */
150 extern
152  SCIP_HEUR* heur, /**< primal heuristic */
153  SCIP_SET* set /**< global SCIP settings */
154  );
155 
156 /** calls exit method of primal heuristic */
157 extern
159  SCIP_HEUR* heur, /**< primal heuristic */
160  SCIP_SET* set /**< global SCIP settings */
161  );
162 
163 /** informs primal heuristic that the branch and bound process is being started */
164 extern
166  SCIP_HEUR* heur, /**< primal heuristic */
167  SCIP_SET* set /**< global SCIP settings */
168  );
169 
170 /** informs primal heuristic that the branch and bound process data is being freed */
171 extern
173  SCIP_HEUR* heur, /**< primal heuristic */
174  SCIP_SET* set /**< global SCIP settings */
175  );
176 
177 /** should the heuristic be executed at the given depth, frequency, timing, ... */
178 extern
180  SCIP_HEUR* heur, /**< primal heuristic */
181  int depth, /**< depth of current node */
182  int lpstateforkdepth, /**< depth of the last node with solved LP */
183  SCIP_HEURTIMING heurtiming, /**< current point in the node solving process */
184  SCIP_Bool* delayed /**< pointer to store whether the heuristic should be delayed */
185  );
186 
187 /** calls execution method of primal heuristic */
188 extern
190  SCIP_HEUR* heur, /**< primal heuristic */
191  SCIP_SET* set, /**< global SCIP settings */
192  SCIP_PRIMAL* primal, /**< primal data */
193  int depth, /**< depth of current node */
194  int lpstateforkdepth, /**< depth of the last node with solved LP */
195  SCIP_HEURTIMING heurtiming, /**< current point in the node solving process */
196  SCIP_Bool nodeinfeasible, /**< was the current node already detected to be infeasible? */
197  int* ndelayedheurs, /**< pointer to count the number of delayed heuristics */
198  SCIP_RESULT* result /**< pointer to store the result of the callback method */
199  );
200 
201 /** sets priority of primal heuristic */
202 extern
204  SCIP_HEUR* heur, /**< primal heuristic */
205  SCIP_SET* set, /**< global SCIP settings */
206  int priority /**< new priority of the primal heuristic */
207  );
208 
209 /** sets copy callback of primal heuristic */
210 extern
211 void SCIPheurSetCopy(
212  SCIP_HEUR* heur, /**< primal heuristic */
213  SCIP_DECL_HEURCOPY ((*heurcopy)) /**< copy callback of primal heuristic or NULL if you don't want to copy your plugin into sub-SCIPs */
214  );
215 
216 /** sets destructor callback of primal heuristic */
217 extern
218 void SCIPheurSetFree(
219  SCIP_HEUR* heur, /**< primal heuristic */
220  SCIP_DECL_HEURFREE ((*heurfree)) /**< destructor of primal heuristic */
221  );
222 
223 /** sets initialization callback of primal heuristic */
224 extern
225 void SCIPheurSetInit(
226  SCIP_HEUR* heur, /**< primal heuristic */
227  SCIP_DECL_HEURINIT ((*heurinit)) /**< initialize primal heuristic */
228  );
229 
230 /** sets deinitialization callback of primal heuristic */
231 extern
232 void SCIPheurSetExit(
233  SCIP_HEUR* heur, /**< primal heuristic */
234  SCIP_DECL_HEUREXIT ((*heurexit)) /**< deinitialize primal heuristic */
235  );
236 
237 /** sets solving process initialization callback of primal heuristic */
238 extern
239 void SCIPheurSetInitsol(
240  SCIP_HEUR* heur, /**< primal heuristic */
241  SCIP_DECL_HEURINITSOL ((*heurinitsol)) /**< solving process initialization callback of primal heuristic */
242  );
243 
244 /** sets solving process deinitialization callback of primal heuristic */
245 extern
246 void SCIPheurSetExitsol(
247  SCIP_HEUR* heur, /**< primal heuristic */
248  SCIP_DECL_HEUREXITSOL ((*heurexitsol)) /**< solving process deinitialization callback of primal heuristic */
249  );
250 
251 /** enables or disables all clocks of \p heur, depending on the value of the flag */
252 extern
254  SCIP_HEUR* heur, /**< the heuristic for which all clocks should be enabled or disabled */
255  SCIP_Bool enable /**< should the clocks of the heuristic be enabled? */
256  );
257 
258 #ifdef __cplusplus
259 }
260 #endif
261 
262 #endif
enum SCIP_Result SCIP_RESULT
Definition: type_result.h:51
#define SCIP_DECL_HEURINITSOL(x)
Definition: type_heur.h:95
SCIP_RETCODE SCIPdivesetGetScore(SCIP_DIVESET *diveset, SCIP_SET *set, SCIP_DIVETYPE divetype, SCIP_VAR *divecand, SCIP_Real divecandsol, SCIP_Real divecandfrac, SCIP_Real *candscore, SCIP_Bool *roundup)
Definition: heur.c:599
unsigned int SCIP_HEURTIMING
Definition: type_timing.h:95
SCIP_RETCODE SCIPdivesetCreate(SCIP_DIVESET **diveset, SCIP_HEUR *heur, const char *name, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, BMS_BLKMEM *blkmem, 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, SCIP_Bool backtrack, SCIP_Bool onlylpbranchcands, SCIP_DIVETYPE divetypemask, SCIP_DECL_DIVESETGETSCORE((*divesetgetscore)))
Definition: heur.c:176
void SCIPheurSetExitsol(SCIP_HEUR *heur, SCIP_DECL_HEUREXITSOL((*heurexitsol)))
Definition: heur.c:1136
SCIP_RETCODE SCIPheurExec(SCIP_HEUR *heur, SCIP_SET *set, SCIP_PRIMAL *primal, int depth, int lpstateforkdepth, SCIP_HEURTIMING heurtiming, SCIP_Bool nodeinfeasible, int *ndelayedheurs, SCIP_RESULT *result)
Definition: heur.c:958
SCIP_RETCODE SCIPheurInitsol(SCIP_HEUR *heur, SCIP_SET *set)
Definition: heur.c:842
void SCIPheurSetPriority(SCIP_HEUR *heur, SCIP_SET *set, int priority)
Definition: heur.c:1218
#define SCIP_DECL_HEURCOPY(x)
Definition: type_heur.h:60
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
#define SCIP_DECL_HEUREXEC(x)
Definition: type_heur.h:126
type definitions for global SCIP settings
struct SCIP_HeurData SCIP_HEURDATA
Definition: type_heur.h:51
type definitions for return codes for SCIP methods
unsigned int SCIP_DIVETYPE
Definition: type_heur.h:48
#define SCIP_DECL_DIVESETGETSCORE(x)
Definition: type_heur.h:146
SCIP_RETCODE SCIPheurCopyInclude(SCIP_HEUR *heur, SCIP_SET *set)
Definition: heur.c:624
void SCIPdivesetReset(SCIP_DIVESET *diveset)
Definition: heur.c:85
void SCIPdivesetUpdateLPStats(SCIP_DIVESET *diveset, SCIP_STAT *stat, SCIP_Longint niterstoadd)
Definition: heur.c:573
type definitions for primal heuristics
SCIP_Bool SCIPheurShouldBeExecuted(SCIP_HEUR *heur, int depth, int lpstateforkdepth, SCIP_HEURTIMING heurtiming, SCIP_Bool *delayed)
Definition: heur.c:896
void SCIPheurSetCopy(SCIP_HEUR *heur, SCIP_DECL_HEURCOPY((*heurcopy)))
Definition: heur.c:1081
void SCIPheurSetFree(SCIP_HEUR *heur, SCIP_DECL_HEURFREE((*heurfree)))
Definition: heur.c:1092
void SCIPdivesetUpdateStats(SCIP_DIVESET *diveset, SCIP_STAT *stat, int depth, int nprobingnodes, int nbacktracks, SCIP_Longint nsolsfound, SCIP_Longint nbestsolsfound, SCIP_Bool leavesol)
Definition: heur.c:108
#define SCIP_Bool
Definition: def.h:53
SCIP_RETCODE SCIPheurInit(SCIP_HEUR *heur, SCIP_SET *set)
Definition: heur.c:762
void SCIPheurEnableOrDisableClocks(SCIP_HEUR *heur, SCIP_Bool enable)
Definition: heur.c:1313
SCIP_RETCODE SCIPheurExit(SCIP_HEUR *heur, SCIP_SET *set)
Definition: heur.c:812
#define SCIP_DECL_HEUREXIT(x)
Definition: type_heur.h:84
SCIP_RETCODE SCIPheurCreate(SCIP_HEUR **heur, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, BMS_BLKMEM *blkmem, const char *name, const char *desc, char dispchar, int priority, int freq, int freqofs, int maxdepth, unsigned int 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: heur.c:643
#define SCIP_DECL_HEURINIT(x)
Definition: type_heur.h:76
#define SCIP_Real
Definition: def.h:127
internal methods for problem statistics
result codes for SCIP callback methods
#define SCIP_DECL_HEURFREE(x)
Definition: type_heur.h:68
SCIP_RETCODE SCIPheurExitsol(SCIP_HEUR *heur, SCIP_SET *set)
Definition: heur.c:872
#define SCIP_Longint
Definition: def.h:112
void SCIPheurSetExit(SCIP_HEUR *heur, SCIP_DECL_HEUREXIT((*heurexit)))
Definition: heur.c:1114
void SCIPheurSetInit(SCIP_HEUR *heur, SCIP_DECL_HEURINIT((*heurinit)))
Definition: heur.c:1103
type definitions for collecting primal CIP solutions and primal informations
public methods for primal heuristics
common defines and data types used in all packages of SCIP
struct BMS_BlkMem BMS_BLKMEM
Definition: memory.h:392
#define SCIP_DECL_HEUREXITSOL(x)
Definition: type_heur.h:106
void SCIPheurSetInitsol(SCIP_HEUR *heur, SCIP_DECL_HEURINITSOL((*heurinitsol)))
Definition: heur.c:1125
SCIP_RETCODE SCIPheurFree(SCIP_HEUR **heur, SCIP_SET *set)
Definition: heur.c:728
memory allocation routines