Scippy

SCIP

Solving Constraint Integer Programs

pub_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-2021 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 scipopt.org. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file pub_heur.h
17  * @ingroup PUBLICCOREAPI
18  * @brief public 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_PUB_HEUR_H__
25 #define __SCIP_PUB_HEUR_H__
26 
27 #include "scip/def.h"
28 #include "scip/type_heur.h"
29 #include "scip/type_misc.h"
30 #include "scip/type_retcode.h"
31 #include "scip/type_scip.h"
32 #include "scip/type_sol.h"
33 #include "scip/type_timing.h"
34 #include "scip/type_var.h"
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 /**@addtogroup PublicHeuristicMethods
41  *
42  * @{
43  */
44 
45 
46 
47 /** compares two heuristics w. r. to their priority */
49 SCIP_DECL_SORTPTRCOMP(SCIPheurComp);
50 
51 /** comparison method for sorting heuristics w.r.t. to their name */
53 SCIP_DECL_SORTPTRCOMP(SCIPheurCompName);
54 
55 /** gets user data of primal heuristic */
58  SCIP_HEUR* heur /**< primal heuristic */
59  );
60 
61 /** sets user data of primal heuristic; user has to free old data in advance! */
63 void SCIPheurSetData(
64  SCIP_HEUR* heur, /**< primal heuristic */
65  SCIP_HEURDATA* heurdata /**< new primal heuristic user data */
66  );
67 
68 /** gets name of primal heuristic */
70 const char* SCIPheurGetName(
71  SCIP_HEUR* heur /**< primal heuristic */
72  );
73 
74 /** gets description of primal heuristic */
76 const char* SCIPheurGetDesc(
77  SCIP_HEUR* heur /**< primal heuristic */
78  );
79 
80 /** gets display character of primal heuristic */
83  SCIP_HEUR* heur /**< primal heuristic */
84  );
85 
86 /** returns the timing mask of the heuristic */
89  SCIP_HEUR* heur /**< primal heuristic */
90  );
91 
92 /** sets new timing mask for heuristic */
95  SCIP_HEUR* heur, /**< primal heuristic */
96  SCIP_HEURTIMING timingmask /**< new timing mask of heuristic */
97  );
98 
99 /** does the heuristic use a secondary SCIP instance? */
102  SCIP_HEUR* heur /**< primal heuristic */
103  );
104 
105 /** gets priority of primal heuristic */
108  SCIP_HEUR* heur /**< primal heuristic */
109  );
110 
111 /** gets frequency of primal heuristic */
113 int SCIPheurGetFreq(
114  SCIP_HEUR* heur /**< primal heuristic */
115  );
116 
117 /** sets frequency of primal heuristic */
119 void SCIPheurSetFreq(
120  SCIP_HEUR* heur, /**< primal heuristic */
121  int freq /**< new frequency of heuristic */
122  );
123 
124 /** gets frequency offset of primal heuristic */
127  SCIP_HEUR* heur /**< primal heuristic */
128  );
129 
130 /** gets maximal depth level for calling primal heuristic (returns -1, if no depth limit exists) */
133  SCIP_HEUR* heur /**< primal heuristic */
134  );
135 
136 /** gets the number of times, the heuristic was called and tried to find a solution */
139  SCIP_HEUR* heur /**< primal heuristic */
140  );
141 
142 /** gets the number of primal feasible solutions found by this heuristic */
145  SCIP_HEUR* heur /**< primal heuristic */
146  );
147 
148 /** gets the number of new best primal feasible solutions found by this heuristic */
151  SCIP_HEUR* heur /**< primal heuristic */
152  );
153 
154 /** is primal heuristic initialized? */
157  SCIP_HEUR* heur /**< primal heuristic */
158  );
159 
160 /** gets time in seconds used in this heuristic for setting up for next stages */
163  SCIP_HEUR* heur /**< primal heuristic */
164  );
165 
166 /** gets time in seconds used in this heuristic */
169  SCIP_HEUR* heur /**< primal heuristic */
170  );
171 
172 /** returns array of divesets of this primal heuristic, or NULL if it has no divesets */
175  SCIP_HEUR* heur /**< primal heuristic */
176  );
177 
178 /** returns the number of divesets of this primal heuristic */
181  SCIP_HEUR* heur /**< primal heuristic */
182  );
183 
184 /** @} */
185 
186 /** get the heuristic to which this diving setting belongs */
189  SCIP_DIVESET* diveset /**< diving settings */
190  );
191 
192 /** get the working solution of this dive set */
195  SCIP_DIVESET* diveset /**< diving settings */
196  );
197 
198 /** set the working solution for this dive set */
201  SCIP_DIVESET* diveset, /**< diving settings */
202  SCIP_SOL* sol /**< new working solution for this dive set, or NULL */
203  );
204 
205 /**@addtogroup PublicDivesetMethods
206  *
207  * @{
208  */
209 
210 /** get the name of the dive set */
212 const char* SCIPdivesetGetName(
213  SCIP_DIVESET* diveset /**< diving settings */
214  );
215 
216 /** get the minimum relative depth of the diving settings */
219  SCIP_DIVESET* diveset /**< diving settings */
220  );
221 
222 /** get the maximum relative depth of the diving settings */
225  SCIP_DIVESET* diveset /**< diving settings */
226  );
227 
228 /** get the number of successful runs of the diving settings */
231  SCIP_DIVESET* diveset, /**< diving settings */
232  SCIP_DIVECONTEXT divecontext /**< context for diving statistics */
233  );
234 
235 /** get the number of calls to this dive set */
238  SCIP_DIVESET* diveset, /**< diving settings */
239  SCIP_DIVECONTEXT divecontext /**< context for diving statistics */
240  );
241 
242 /** get the number of calls successfully terminated at a feasible leaf node */
245  SCIP_DIVESET* diveset, /**< diving settings */
246  SCIP_DIVECONTEXT divecontext /**< context for diving statistics */
247  );
248 
249 /** get the minimum depth reached by this dive set */
252  SCIP_DIVESET* diveset, /**< diving settings */
253  SCIP_DIVECONTEXT divecontext /**< context for diving statistics */
254  );
255 
256 /** get the maximum depth reached by this dive set */
259  SCIP_DIVESET* diveset, /**< diving settings */
260  SCIP_DIVECONTEXT divecontext /**< context for diving statistics */
261  );
262 
263 /** get the average depth this dive set reached during execution */
266  SCIP_DIVESET* diveset, /**< diving settings */
267  SCIP_DIVECONTEXT divecontext /**< context for diving statistics */
268  );
269 
270 /** get the minimum depth at which this dive set found a solution */
273  SCIP_DIVESET* diveset, /**< diving settings */
274  SCIP_DIVECONTEXT divecontext /**< context for diving statistics */
275  );
276 
277 /** get the maximum depth at which this dive set found a solution */
280  SCIP_DIVESET* diveset, /**< diving settings */
281  SCIP_DIVECONTEXT divecontext /**< context for diving statistics */
282  );
283 
284 /** get the average depth at which this dive set found a solution */
287  SCIP_DIVESET* diveset, /**< diving settings */
288  SCIP_DIVECONTEXT divecontext /**< context for diving statistics */
289  );
290 
291 /** get the total number of LP iterations used by this dive set */
294  SCIP_DIVESET* diveset, /**< diving settings */
295  SCIP_DIVECONTEXT divecontext /**< context for diving statistics */
296  );
297 
298 /** get the total number of probing nodes used by this dive set */
301  SCIP_DIVESET* diveset, /**< diving settings */
302  SCIP_DIVECONTEXT divecontext /**< context for diving statistics */
303  );
304 
305 /** get the total number of backtracks performed by this dive set */
308  SCIP_DIVESET* diveset, /**< diving settings */
309  SCIP_DIVECONTEXT divecontext /**< context for diving statistics */
310  );
311 
312 /** get the total number of conflicts found by this dive set */
315  SCIP_DIVESET* diveset, /**< diving settings */
316  SCIP_DIVECONTEXT divecontext /**< context for diving statistics */
317  );
318 
319 /** get the total number of solutions (leaf and rounded solutions) found by the dive set */
322  SCIP_DIVESET* diveset, /**< diving settings */
323  SCIP_DIVECONTEXT divecontext /**< context for diving statistics */
324  );
325 
326 /** get the maximum LP iterations quotient of the diving settings */
329  SCIP_DIVESET* diveset /**< diving settings */
330  );
331 
332 /** get the maximum LP iterations offset of the diving settings */
335  SCIP_DIVESET* diveset /**< diving settings */
336  );
337 
338 /** get the maximum upper bound quotient parameter of the diving settings if no solution is available */
341  SCIP_DIVESET* diveset /**< diving settings */
342  );
343 
344 /** get the average quotient parameter of the diving settings if no solution is available */
347  SCIP_DIVESET* diveset /**< diving settings */
348  );
349 
350 /** get the maximum upper bound quotient parameter of the diving settings if an incumbent solution exists */
353  SCIP_DIVESET* diveset /**< diving settings */
354  );
355 
356 /** get the average upper bound quotient parameter of the diving settings if an incumbent solution exists */
359  SCIP_DIVESET* diveset /**< diving settings */
360  );
361 
362 /** should backtracking be applied? */
365  SCIP_DIVESET* diveset /**< diving settings */
366  );
367 
368 /** returns the LP solve frequency for diving LPs (0: dynamically based on number of intermediate domain reductions) */
371  SCIP_DIVESET* diveset /**< diving settings */
372  );
373 
374 /** returns the domain reduction quotient for triggering an immediate resolve of the diving LP (0.0: always resolve)*/
377  SCIP_DIVESET* diveset /**< diving settings */
378  );
379 
380 /** should only LP branching candidates be considered instead of the slower but
381  * more general constraint handler diving variable selection?
382  */
385  SCIP_DIVESET* diveset /**< diving settings */
386  );
387 
388 /** returns TRUE if dive set supports diving of the specified type */
391  SCIP_DIVESET* diveset, /**< diving settings */
392  SCIP_DIVETYPE divetype /**< bit mask that represents the supported dive types by this dive set */
393  );
394 
395 /** returns the random number generator of this \p diveset for tie-breaking */
398  SCIP_DIVESET* diveset /**< diving settings */
399  );
400 
401 /** is this dive set publicly available (ie., can be used by other primal heuristics?) */
404  SCIP_DIVESET* diveset /**< diving settings */
405  );
406 
407 /** @} */
408 
409 /**@defgroup PublicVariableGraphMethods Public Variable Graph Methods
410  * @ingroup MiscellaneousMethods
411  *
412  * @brief methods to create a variable graph and perform breadth-first search
413  *
414  * @{
415  */
416 
417 /** Perform breadth-first (BFS) search on the variable constraint graph.
418  *
419  * The result of the algorithm is that the \p distances array contains the correct distances for
420  * every variable from the start variables. The distance of a variable can then be accessed through its
421  * problem index (calling SCIPvarGetProbindex()).
422  * Hence, The method assumes that the length of \p distances is at least
423  * SCIPgetNVars().
424  * Variables that are not connected through constraints to the start variables have a distance of -1.
425  *
426  * Limits can be provided to further restrict the breadth-first search. If a distance limit is given,
427  * the search will be performed until the first variable at this distance is popped from the queue, i.e.,
428  * all variables with a distance < maxdistance have been labeled by the search.
429  * If a variable limit is given, the search stops after it completes the distance level at which
430  * the limit was reached. Hence, more variables may be actually labeled.
431  * The start variables are accounted for those variable limits.
432  *
433  * If no variable variable constraint graph is provided, the method will create one and free it at the end
434  * This is useful for a single use of the variable constraint graph. For several consecutive uses,
435  * it is advised to create a variable constraint graph via SCIPvariableGraphCreate().
436  */
439  SCIP* scip, /**< SCIP data structure */
440  SCIP_VGRAPH* vargraph, /**< pointer to the variable graph, or NULL to let the function create a local graph */
441  SCIP_VAR** startvars, /**< array of start variables to calculate distance from */
442  int nstartvars, /**< number of starting variables, at least 1 */
443  int* distances, /**< array to keep distance in vargraph from start variables for every variable */
444  int maxdistance, /**< maximum distance >= 0 from start variable (INT_MAX for complete BFS) */
445  int maxvars, /**< maximum number of variables to compute distance for */
446  int maxbinintvars /**< maximum number of binary or integer variables to compute distance for */
447  );
448 
449 /** initialization method of variable graph data structure */
452  SCIP* scip, /**< SCIP data structure */
453  SCIP_VGRAPH** vargraph, /**< pointer to the variable graph */
454  SCIP_Bool relaxdenseconss, /**< should dense constraints (at least as dense as \p density) be
455  * ignored by connectivity graph? */
456  SCIP_Real relaxdensity, /**< density (with respect to number of variables) to relax constraint from graph */
457  int* nrelaxedconstraints /**< pointer to store the number of constraints that were relaxed, or NULL if not needed */
458  );
459 
460 /** deinitialization method of variable graph data structure */
463  SCIP* scip, /**< SCIP data structure */
464  SCIP_VGRAPH** vargraph /**< pointer to the variable graph */
465  );
466 
467 /** @} */
468 
469 
470 #ifdef __cplusplus
471 }
472 #endif
473 
474 #endif
SCIP_EXPORT SCIP_Longint SCIPheurGetNCalls(SCIP_HEUR *heur)
Definition: heur.c:1555
SCIP_EXPORT void SCIPheurSetFreq(SCIP_HEUR *heur, int freq)
Definition: heur.c:1524
SCIP_EXPORT int SCIPdivesetGetMaxLPIterOffset(SCIP_DIVESET *diveset)
Definition: heur.c:643
SCIP_EXPORT SCIP_Longint SCIPheurGetNSolsFound(SCIP_HEUR *heur)
Definition: heur.c:1565
SCIP_EXPORT const char * SCIPheurGetName(SCIP_HEUR *heur)
Definition: heur.c:1429
SCIP_EXPORT int SCIPheurGetFreq(SCIP_HEUR *heur)
Definition: heur.c:1514
type definitions for miscellaneous datastructures
timing definitions for SCIP
SCIP_EXPORT int SCIPdivesetGetMinDepth(SCIP_DIVESET *diveset, SCIP_DIVECONTEXT divecontext)
Definition: heur.c:491
SCIP_EXPORT SCIP_Bool SCIPdivesetSupportsType(SCIP_DIVESET *diveset, SCIP_DIVETYPE divetype)
Definition: heur.c:733
SCIP_EXPORT SCIP_HEURDATA * SCIPheurGetData(SCIP_HEUR *heur)
Definition: heur.c:1340
SCIP_EXPORT SCIP_Real SCIPdivesetGetLPResolveDomChgQuot(SCIP_DIVESET *diveset)
Definition: heur.c:711
SCIP_EXPORT SCIP_Real SCIPdivesetGetMinRelDepth(SCIP_DIVESET *diveset)
Definition: heur.c:435
unsigned int SCIP_HEURTIMING
Definition: type_timing.h:97
SCIP_EXPORT SCIP_RANDNUMGEN * SCIPdivesetGetRandnumgen(SCIP_DIVESET *diveset)
Definition: heur.c:700
#define SCIP_EXPORT
Definition: def.h:100
SCIP_EXPORT SCIP_RETCODE SCIPvariableGraphCreate(SCIP *scip, SCIP_VGRAPH **vargraph, SCIP_Bool relaxdenseconss, SCIP_Real relaxdensity, int *nrelaxedconstraints)
Definition: heur.c:1967
SCIP_EXPORT SCIP_RETCODE SCIPvariablegraphBreadthFirst(SCIP *scip, SCIP_VGRAPH *vargraph, SCIP_VAR **startvars, int nstartvars, int *distances, int maxdistance, int maxvars, int maxbinintvars)
Definition: heur.c:1666
SCIP_EXPORT int SCIPdivesetGetMaxSolutionDepth(SCIP_DIVESET *diveset, SCIP_DIVECONTEXT divecontext)
Definition: heur.c:543
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:54
SCIP_EXPORT SCIP_Bool SCIPdivesetUseBacktrack(SCIP_DIVESET *diveset)
Definition: heur.c:682
struct SCIP_HeurData SCIP_HEURDATA
Definition: type_heur.h:67
type definitions for return codes for SCIP methods
unsigned int SCIP_DIVETYPE
Definition: type_heur.h:54
SCIP_EXPORT SCIP_HEURTIMING SCIPheurGetTimingmask(SCIP_HEUR *heur)
Definition: heur.c:1459
SCIP_EXPORT SCIP_Real SCIPdivesetGetAvgSolutionDepth(SCIP_DIVESET *diveset, SCIP_DIVECONTEXT divecontext)
Definition: heur.c:556
SCIP_EXPORT SCIP_Longint SCIPheurGetNBestSolsFound(SCIP_HEUR *heur)
Definition: heur.c:1575
SCIP_EXPORT SCIP_Longint SCIPdivesetGetNConflicts(SCIP_DIVESET *diveset, SCIP_DIVECONTEXT divecontext)
Definition: heur.c:608
SCIP_EXPORT SCIP_Longint SCIPdivesetGetNSols(SCIP_DIVESET *diveset, SCIP_DIVECONTEXT divecontext)
Definition: heur.c:621
SCIP_EXPORT SCIP_Real SCIPdivesetGetMaxLPIterQuot(SCIP_DIVESET *diveset)
Definition: heur.c:635
SCIP_EXPORT int SCIPheurGetPriority(SCIP_HEUR *heur)
Definition: heur.c:1490
SCIP_EXPORT SCIP_Longint SCIPdivesetGetNLPIterations(SCIP_DIVESET *diveset, SCIP_DIVECONTEXT divecontext)
Definition: heur.c:569
SCIP_EXPORT SCIP_Bool SCIPdivesetIsPublic(SCIP_DIVESET *diveset)
Definition: heur.c:744
SCIP_EXPORT int SCIPheurGetNDivesets(SCIP_HEUR *heur)
Definition: heur.c:1637
type definitions for primal heuristics
SCIP_EXPORT SCIP_Longint SCIPdivesetGetNBacktracks(SCIP_DIVESET *diveset, SCIP_DIVECONTEXT divecontext)
Definition: heur.c:595
SCIP_EXPORT SCIP_HEUR * SCIPdivesetGetHeur(SCIP_DIVESET *diveset)
Definition: heur.c:396
type definitions for SCIP&#39;s main datastructure
SCIP_EXPORT SCIP_Real SCIPdivesetGetUbQuotNoSol(SCIP_DIVESET *diveset)
Definition: heur.c:651
SCIP_EXPORT void SCIPdivesetSetWorkSolution(SCIP_DIVESET *diveset, SCIP_SOL *sol)
Definition: heur.c:414
SCIP_EXPORT void SCIPheurSetData(SCIP_HEUR *heur, SCIP_HEURDATA *heurdata)
Definition: heur.c:1350
SCIP_EXPORT const char * SCIPdivesetGetName(SCIP_DIVESET *diveset)
Definition: heur.c:425
SCIP_EXPORT void SCIPheurSetTimingmask(SCIP_HEUR *heur, SCIP_HEURTIMING timingmask)
Definition: heur.c:1469
type definitions for problem variables
SCIP_EXPORT SCIP_Real SCIPdivesetGetAvgQuotNoSol(SCIP_DIVESET *diveset)
Definition: heur.c:659
SCIP_EXPORT SCIP_Longint SCIPdivesetGetNProbingNodes(SCIP_DIVESET *diveset, SCIP_DIVECONTEXT divecontext)
Definition: heur.c:582
SCIP_EXPORT SCIP_Bool SCIPheurIsInitialized(SCIP_HEUR *heur)
Definition: heur.c:1585
SCIP_EXPORT void SCIPvariableGraphFree(SCIP *scip, SCIP_VGRAPH **vargraph)
Definition: heur.c:2005
SCIP_EXPORT SCIP_Real SCIPdivesetGetMaxRelDepth(SCIP_DIVESET *diveset)
Definition: heur.c:443
SCIP_EXPORT char SCIPheurGetDispchar(SCIP_HEUR *heur)
Definition: heur.c:1449
SCIP_EXPORT int SCIPdivesetGetMaxDepth(SCIP_DIVESET *diveset, SCIP_DIVECONTEXT divecontext)
Definition: heur.c:504
SCIP_EXPORT SCIP_DIVESET ** SCIPheurGetDivesets(SCIP_HEUR *heur)
Definition: heur.c:1627
#define SCIP_Bool
Definition: def.h:70
SCIP_EXPORT SCIP_SOL * SCIPdivesetGetWorkSolution(SCIP_DIVESET *diveset)
Definition: heur.c:404
SCIP_EXPORT int SCIPdivesetGetMinSolutionDepth(SCIP_DIVESET *diveset, SCIP_DIVECONTEXT divecontext)
Definition: heur.c:530
SCIP_EXPORT int SCIPheurGetMaxdepth(SCIP_HEUR *heur)
Definition: heur.c:1545
SCIP_EXPORT SCIP_Bool SCIPdivesetUseOnlyLPBranchcands(SCIP_DIVESET *diveset)
Definition: heur.c:723
SCIP_EXPORT SCIP_Real SCIPdivesetGetUbQuot(SCIP_DIVESET *diveset)
Definition: heur.c:666
type definitions for storing primal CIP solutions
SCIP_EXPORT SCIP_Real SCIPdivesetGetAvgDepth(SCIP_DIVESET *diveset, SCIP_DIVECONTEXT divecontext)
Definition: heur.c:517
SCIP_EXPORT const char * SCIPheurGetDesc(SCIP_HEUR *heur)
Definition: heur.c:1439
SCIP_EXPORT int SCIPdivesetGetNCalls(SCIP_DIVESET *diveset, SCIP_DIVECONTEXT divecontext)
Definition: heur.c:465
enum SCIP_DiveContext SCIP_DIVECONTEXT
Definition: type_heur.h:63
SCIP_EXPORT int SCIPdivesetGetNSolutionCalls(SCIP_DIVESET *diveset, SCIP_DIVECONTEXT divecontext)
Definition: heur.c:478
SCIP_EXPORT SCIP_Real SCIPheurGetTime(SCIP_HEUR *heur)
Definition: heur.c:1617
SCIP_EXPORT int SCIPheurGetFreqofs(SCIP_HEUR *heur)
Definition: heur.c:1535
SCIP_EXPORT SCIP_Bool SCIPheurUsesSubscip(SCIP_HEUR *heur)
Definition: heur.c:1480
#define SCIP_Real
Definition: def.h:163
SCIP_EXPORT SCIP_Real SCIPheurGetSetupTime(SCIP_HEUR *heur)
Definition: heur.c:1607
SCIP_EXPORT int SCIPdivesetGetLPSolveFreq(SCIP_DIVESET *diveset)
Definition: heur.c:690
#define SCIP_Longint
Definition: def.h:148
common defines and data types used in all packages of SCIP
SCIP_EXPORT SCIP_Longint SCIPdivesetGetSolSuccess(SCIP_DIVESET *diveset, SCIP_DIVECONTEXT divecontext)
Definition: heur.c:451
SCIP_EXPORT SCIP_DECL_SORTPTRCOMP(SCIPheurComp)
Definition: heur.c:42
SCIP_EXPORT SCIP_Real SCIPdivesetGetAvgQuot(SCIP_DIVESET *diveset)
Definition: heur.c:674