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