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-2024 Zuse Institute Berlin (ZIB) */
7/* */
8/* Licensed under the Apache License, Version 2.0 (the "License"); */
9/* you may not use this file except in compliance with the License. */
10/* You may obtain a copy of the License at */
11/* */
12/* http://www.apache.org/licenses/LICENSE-2.0 */
13/* */
14/* Unless required by applicable law or agreed to in writing, software */
15/* distributed under the License is distributed on an "AS IS" BASIS, */
16/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
17/* See the License for the specific language governing permissions and */
18/* limitations under the License. */
19/* */
20/* You should have received a copy of the Apache-2.0 license */
21/* along with SCIP; see the file LICENSE. If not visit scipopt.org. */
22/* */
23/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
24
25/**@file pub_heur.h
26 * @ingroup PUBLICCOREAPI
27 * @brief public methods for primal heuristics
28 * @author Tobias Achterberg
29 */
30
31/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
32
33#ifndef __SCIP_PUB_HEUR_H__
34#define __SCIP_PUB_HEUR_H__
35
36#include "scip/def.h"
37#include "scip/type_heur.h"
38#include "scip/type_misc.h"
39#include "scip/type_retcode.h"
40#include "scip/type_scip.h"
41#include "scip/type_sol.h"
42#include "scip/type_timing.h"
43#include "scip/type_var.h"
44
45#ifdef __cplusplus
46extern "C" {
47#endif
48
49/**@addtogroup PublicHeuristicMethods
50 *
51 * @{
52 */
53
54
55
56/** compares two heuristics w.r.t. to their delay positions and priorities */
57SCIP_EXPORT
58SCIP_DECL_SORTPTRCOMP(SCIPheurComp);
59
60/** compares two heuristics w.r.t. to their priority values */
61SCIP_EXPORT
62SCIP_DECL_SORTPTRCOMP(SCIPheurCompPriority);
63
64/** comparison method for sorting heuristics w.r.t. to their name */
65SCIP_EXPORT
66SCIP_DECL_SORTPTRCOMP(SCIPheurCompName);
67
68/** gets user data of primal heuristic */
69SCIP_EXPORT
71 SCIP_HEUR* heur /**< primal heuristic */
72 );
73
74/** sets user data of primal heuristic; user has to free old data in advance! */
75SCIP_EXPORT
77 SCIP_HEUR* heur, /**< primal heuristic */
78 SCIP_HEURDATA* heurdata /**< new primal heuristic user data */
79 );
80
81/** gets name of primal heuristic */
82SCIP_EXPORT
83const char* SCIPheurGetName(
84 SCIP_HEUR* heur /**< primal heuristic */
85 );
86
87/** gets description of primal heuristic */
88SCIP_EXPORT
89const char* SCIPheurGetDesc(
90 SCIP_HEUR* heur /**< primal heuristic */
91 );
92
93/** gets display character of primal heuristic */
94SCIP_EXPORT
96 SCIP_HEUR* heur /**< primal heuristic */
97 );
98
99/** returns the timing mask of the heuristic */
100SCIP_EXPORT
102 SCIP_HEUR* heur /**< primal heuristic */
103 );
104
105/** sets new timing mask for heuristic */
106SCIP_EXPORT
108 SCIP_HEUR* heur, /**< primal heuristic */
109 SCIP_HEURTIMING timingmask /**< new timing mask of heuristic */
110 );
111
112/** does the heuristic use a secondary SCIP instance? */
113SCIP_EXPORT
115 SCIP_HEUR* heur /**< primal heuristic */
116 );
117
118/** gets priority of primal heuristic */
119SCIP_EXPORT
121 SCIP_HEUR* heur /**< primal heuristic */
122 );
123
124/** gets frequency of primal heuristic */
125SCIP_EXPORT
127 SCIP_HEUR* heur /**< primal heuristic */
128 );
129
130/** sets frequency of primal heuristic */
131SCIP_EXPORT
132void SCIPheurSetFreq(
133 SCIP_HEUR* heur, /**< primal heuristic */
134 int freq /**< new frequency of heuristic */
135 );
136
137/** gets frequency offset of primal heuristic */
138SCIP_EXPORT
140 SCIP_HEUR* heur /**< primal heuristic */
141 );
142
143/** gets maximal depth level for calling primal heuristic (returns -1, if no depth limit exists) */
144SCIP_EXPORT
146 SCIP_HEUR* heur /**< primal heuristic */
147 );
148
149/** gets the number of times, the heuristic was called and tried to find a solution */
150SCIP_EXPORT
152 SCIP_HEUR* heur /**< primal heuristic */
153 );
154
155/** gets the number of primal feasible solutions found by this heuristic */
156SCIP_EXPORT
158 SCIP_HEUR* heur /**< primal heuristic */
159 );
160
161/** gets the number of new best primal feasible solutions found by this heuristic */
162SCIP_EXPORT
164 SCIP_HEUR* heur /**< primal heuristic */
165 );
166
167/** is primal heuristic initialized? */
168SCIP_EXPORT
170 SCIP_HEUR* heur /**< primal heuristic */
171 );
172
173/** gets time in seconds used in this heuristic for setting up for next stages */
174SCIP_EXPORT
176 SCIP_HEUR* heur /**< primal heuristic */
177 );
178
179/** gets time in seconds used in this heuristic */
180SCIP_EXPORT
182 SCIP_HEUR* heur /**< primal heuristic */
183 );
184
185/** returns array of divesets of this primal heuristic, or NULL if it has no divesets */
186SCIP_EXPORT
188 SCIP_HEUR* heur /**< primal heuristic */
189 );
190
191/** returns the number of divesets of this primal heuristic */
192SCIP_EXPORT
194 SCIP_HEUR* heur /**< primal heuristic */
195 );
196
197/** @} */
198
199/** get the heuristic to which this diving setting belongs */
200SCIP_EXPORT
202 SCIP_DIVESET* diveset /**< diving settings */
203 );
204
205/** get the working solution of this dive set */
206SCIP_EXPORT
208 SCIP_DIVESET* diveset /**< diving settings */
209 );
210
211/** set the working solution for this dive set */
212SCIP_EXPORT
214 SCIP_DIVESET* diveset, /**< diving settings */
215 SCIP_SOL* sol /**< new working solution for this dive set, or NULL */
216 );
217
218/**@addtogroup PublicDivesetMethods
219 *
220 * @{
221 */
222
223/** get the name of the dive set */
224SCIP_EXPORT
225const char* SCIPdivesetGetName(
226 SCIP_DIVESET* diveset /**< diving settings */
227 );
228
229/** get the minimum relative depth of the diving settings */
230SCIP_EXPORT
232 SCIP_DIVESET* diveset /**< diving settings */
233 );
234
235/** get the maximum relative depth of the diving settings */
236SCIP_EXPORT
238 SCIP_DIVESET* diveset /**< diving settings */
239 );
240
241/** get the number of successful runs of the diving settings */
242SCIP_EXPORT
244 SCIP_DIVESET* diveset, /**< diving settings */
245 SCIP_DIVECONTEXT divecontext /**< context for diving statistics */
246 );
247
248/** get the number of calls to this dive set */
249SCIP_EXPORT
251 SCIP_DIVESET* diveset, /**< diving settings */
252 SCIP_DIVECONTEXT divecontext /**< context for diving statistics */
253 );
254
255/** get the number of calls successfully terminated at a feasible leaf node */
256SCIP_EXPORT
258 SCIP_DIVESET* diveset, /**< diving settings */
259 SCIP_DIVECONTEXT divecontext /**< context for diving statistics */
260 );
261
262/** get the minimum depth reached by this dive set */
263SCIP_EXPORT
265 SCIP_DIVESET* diveset, /**< diving settings */
266 SCIP_DIVECONTEXT divecontext /**< context for diving statistics */
267 );
268
269/** get the maximum depth reached by this dive set */
270SCIP_EXPORT
272 SCIP_DIVESET* diveset, /**< diving settings */
273 SCIP_DIVECONTEXT divecontext /**< context for diving statistics */
274 );
275
276/** get the average depth this dive set reached during execution */
277SCIP_EXPORT
279 SCIP_DIVESET* diveset, /**< diving settings */
280 SCIP_DIVECONTEXT divecontext /**< context for diving statistics */
281 );
282
283/** get the minimum depth at which this dive set found a solution */
284SCIP_EXPORT
286 SCIP_DIVESET* diveset, /**< diving settings */
287 SCIP_DIVECONTEXT divecontext /**< context for diving statistics */
288 );
289
290/** get the maximum depth at which this dive set found a solution */
291SCIP_EXPORT
293 SCIP_DIVESET* diveset, /**< diving settings */
294 SCIP_DIVECONTEXT divecontext /**< context for diving statistics */
295 );
296
297/** get the average depth at which this dive set found a solution */
298SCIP_EXPORT
300 SCIP_DIVESET* diveset, /**< diving settings */
301 SCIP_DIVECONTEXT divecontext /**< context for diving statistics */
302 );
303
304/** get the total number of LP iterations used by this dive set */
305SCIP_EXPORT
307 SCIP_DIVESET* diveset, /**< diving settings */
308 SCIP_DIVECONTEXT divecontext /**< context for diving statistics */
309 );
310
311/** get the total number of probing nodes used by this dive set */
312SCIP_EXPORT
314 SCIP_DIVESET* diveset, /**< diving settings */
315 SCIP_DIVECONTEXT divecontext /**< context for diving statistics */
316 );
317
318/** get the total number of backtracks performed by this dive set */
319SCIP_EXPORT
321 SCIP_DIVESET* diveset, /**< diving settings */
322 SCIP_DIVECONTEXT divecontext /**< context for diving statistics */
323 );
324
325/** get the total number of conflicts found by this dive set */
326SCIP_EXPORT
328 SCIP_DIVESET* diveset, /**< diving settings */
329 SCIP_DIVECONTEXT divecontext /**< context for diving statistics */
330 );
331
332/** get the total number of solutions (leaf and rounded solutions) found by the dive set */
333SCIP_EXPORT
335 SCIP_DIVESET* diveset, /**< diving settings */
336 SCIP_DIVECONTEXT divecontext /**< context for diving statistics */
337 );
338
339/** get the maximum LP iterations quotient of the diving settings */
340SCIP_EXPORT
342 SCIP_DIVESET* diveset /**< diving settings */
343 );
344
345/** get the maximum LP iterations offset of the diving settings */
346SCIP_EXPORT
348 SCIP_DIVESET* diveset /**< diving settings */
349 );
350
351/** get the maximum upper bound quotient parameter of the diving settings if no solution is available */
352SCIP_EXPORT
354 SCIP_DIVESET* diveset /**< diving settings */
355 );
356
357/** get the average quotient parameter of the diving settings if no solution is available */
358SCIP_EXPORT
360 SCIP_DIVESET* diveset /**< diving settings */
361 );
362
363/** get the maximum upper bound quotient parameter of the diving settings if an incumbent solution exists */
364SCIP_EXPORT
366 SCIP_DIVESET* diveset /**< diving settings */
367 );
368
369/** get the average upper bound quotient parameter of the diving settings if an incumbent solution exists */
370SCIP_EXPORT
372 SCIP_DIVESET* diveset /**< diving settings */
373 );
374
375/** should backtracking be applied? */
376SCIP_EXPORT
378 SCIP_DIVESET* diveset /**< diving settings */
379 );
380
381/** returns the LP solve frequency for diving LPs (0: dynamically based on number of intermediate domain reductions) */
382SCIP_EXPORT
384 SCIP_DIVESET* diveset /**< diving settings */
385 );
386
387/** returns the domain reduction quotient for triggering an immediate resolve of the diving LP (0.0: always resolve)*/
388SCIP_EXPORT
390 SCIP_DIVESET* diveset /**< diving settings */
391 );
392
393/** should only LP branching candidates be considered instead of the slower but
394 * more general constraint handler diving variable selection?
395 */
396SCIP_EXPORT
398 SCIP_DIVESET* diveset /**< diving settings */
399 );
400
401/** returns TRUE if dive set supports diving of the specified type */
402SCIP_EXPORT
404 SCIP_DIVESET* diveset, /**< diving settings */
405 SCIP_DIVETYPE divetype /**< bit mask that represents the supported dive types by this dive set */
406 );
407
408/** returns the random number generator of this \p diveset for tie-breaking */
409SCIP_EXPORT
411 SCIP_DIVESET* diveset /**< diving settings */
412 );
413
414/** is this dive set publicly available (ie., can be used by other primal heuristics?) */
415SCIP_EXPORT
417 SCIP_DIVESET* diveset /**< diving settings */
418 );
419
420/** @} */
421
422/**@defgroup PublicVariableGraphMethods Public Variable Graph Methods
423 * @ingroup MiscellaneousMethods
424 *
425 * @brief methods to create a variable graph and perform breadth-first search
426 *
427 * @{
428 */
429
430/** Perform breadth-first (BFS) search on the variable constraint graph.
431 *
432 * The result of the algorithm is that the \p distances array contains the correct distances for
433 * every variable from the start variables. The distance of a variable can then be accessed through its
434 * problem index (calling SCIPvarGetProbindex()).
435 * Hence, The method assumes that the length of \p distances is at least
436 * SCIPgetNVars().
437 * Variables that are not connected through constraints to the start variables have a distance of -1.
438 *
439 * Limits can be provided to further restrict the breadth-first search. If a distance limit is given,
440 * the search will be performed until the first variable at this distance is popped from the queue, i.e.,
441 * all variables with a distance < maxdistance have been labeled by the search.
442 * If a variable limit is given, the search stops after it completes the distance level at which
443 * the limit was reached. Hence, more variables may be actually labeled.
444 * The start variables are accounted for those variable limits.
445 *
446 * If no variable variable constraint graph is provided, the method will create one and free it at the end
447 * This is useful for a single use of the variable constraint graph. For several consecutive uses,
448 * it is advised to create a variable constraint graph via SCIPvariableGraphCreate().
449 */
450SCIP_EXPORT
452 SCIP* scip, /**< SCIP data structure */
453 SCIP_VGRAPH* vargraph, /**< pointer to the variable graph, or NULL to let the function create a local graph */
454 SCIP_VAR** startvars, /**< array of start variables to calculate distance from */
455 int nstartvars, /**< number of starting variables, at least 1 */
456 int* distances, /**< array to keep distance in vargraph from start variables for every variable */
457 int maxdistance, /**< maximum distance >= 0 from start variable (INT_MAX for complete BFS) */
458 int maxvars, /**< maximum number of variables to compute distance for */
459 int maxbinintvars /**< maximum number of binary or integer variables to compute distance for */
460 );
461
462/** initialization method of variable graph data structure */
463SCIP_EXPORT
465 SCIP* scip, /**< SCIP data structure */
466 SCIP_VGRAPH** vargraph, /**< pointer to the variable graph */
467 SCIP_Bool relaxdenseconss, /**< should dense constraints (at least as dense as \p density) be
468 * ignored by connectivity graph? */
469 SCIP_Real relaxdensity, /**< density (with respect to number of variables) to relax constraint from graph */
470 int* nrelaxedconstraints /**< pointer to store the number of constraints that were relaxed, or NULL if not needed */
471 );
472
473/** deinitialization method of variable graph data structure */
474SCIP_EXPORT
476 SCIP* scip, /**< SCIP data structure */
477 SCIP_VGRAPH** vargraph /**< pointer to the variable graph */
478 );
479
480/** @} */
481
482
483#ifdef __cplusplus
484}
485#endif
486
487#endif
common defines and data types used in all packages of SCIP
#define SCIP_Longint
Definition: def.h:158
#define SCIP_Bool
Definition: def.h:91
#define SCIP_Real
Definition: def.h:173
SCIP_Real SCIPdivesetGetMaxLPIterQuot(SCIP_DIVESET *diveset)
Definition: heur.c:655
SCIP_Bool SCIPdivesetIsPublic(SCIP_DIVESET *diveset)
Definition: heur.c:764
SCIP_Real SCIPdivesetGetUbQuotNoSol(SCIP_DIVESET *diveset)
Definition: heur.c:671
SCIP_Real SCIPdivesetGetMaxRelDepth(SCIP_DIVESET *diveset)
Definition: heur.c:463
SCIP_Longint SCIPdivesetGetNBacktracks(SCIP_DIVESET *diveset, SCIP_DIVECONTEXT divecontext)
Definition: heur.c:615
SCIP_Longint SCIPdivesetGetNSols(SCIP_DIVESET *diveset, SCIP_DIVECONTEXT divecontext)
Definition: heur.c:641
int SCIPdivesetGetMaxSolutionDepth(SCIP_DIVESET *diveset, SCIP_DIVECONTEXT divecontext)
Definition: heur.c:563
SCIP_Longint SCIPdivesetGetNConflicts(SCIP_DIVESET *diveset, SCIP_DIVECONTEXT divecontext)
Definition: heur.c:628
SCIP_Real SCIPdivesetGetAvgQuot(SCIP_DIVESET *diveset)
Definition: heur.c:694
SCIP_Bool SCIPdivesetUseBacktrack(SCIP_DIVESET *diveset)
Definition: heur.c:702
int SCIPdivesetGetLPSolveFreq(SCIP_DIVESET *diveset)
Definition: heur.c:710
SCIP_Real SCIPdivesetGetMinRelDepth(SCIP_DIVESET *diveset)
Definition: heur.c:455
SCIP_Real SCIPdivesetGetUbQuot(SCIP_DIVESET *diveset)
Definition: heur.c:686
SCIP_Real SCIPdivesetGetAvgSolutionDepth(SCIP_DIVESET *diveset, SCIP_DIVECONTEXT divecontext)
Definition: heur.c:576
int SCIPdivesetGetMaxDepth(SCIP_DIVESET *diveset, SCIP_DIVECONTEXT divecontext)
Definition: heur.c:524
int SCIPdivesetGetMinDepth(SCIP_DIVESET *diveset, SCIP_DIVECONTEXT divecontext)
Definition: heur.c:511
SCIP_Bool SCIPdivesetSupportsType(SCIP_DIVESET *diveset, SCIP_DIVETYPE divetype)
Definition: heur.c:753
SCIP_Real SCIPdivesetGetAvgDepth(SCIP_DIVESET *diveset, SCIP_DIVECONTEXT divecontext)
Definition: heur.c:537
SCIP_Bool SCIPdivesetUseOnlyLPBranchcands(SCIP_DIVESET *diveset)
Definition: heur.c:743
SCIP_Longint SCIPdivesetGetNLPIterations(SCIP_DIVESET *diveset, SCIP_DIVECONTEXT divecontext)
Definition: heur.c:589
SCIP_Longint SCIPdivesetGetSolSuccess(SCIP_DIVESET *diveset, SCIP_DIVECONTEXT divecontext)
Definition: heur.c:471
int SCIPdivesetGetMinSolutionDepth(SCIP_DIVESET *diveset, SCIP_DIVECONTEXT divecontext)
Definition: heur.c:550
const char * SCIPdivesetGetName(SCIP_DIVESET *diveset)
Definition: heur.c:445
int SCIPdivesetGetNCalls(SCIP_DIVESET *diveset, SCIP_DIVECONTEXT divecontext)
Definition: heur.c:485
SCIP_Real SCIPdivesetGetAvgQuotNoSol(SCIP_DIVESET *diveset)
Definition: heur.c:679
SCIP_RANDNUMGEN * SCIPdivesetGetRandnumgen(SCIP_DIVESET *diveset)
Definition: heur.c:720
SCIP_Longint SCIPdivesetGetNProbingNodes(SCIP_DIVESET *diveset, SCIP_DIVECONTEXT divecontext)
Definition: heur.c:602
SCIP_Real SCIPdivesetGetLPResolveDomChgQuot(SCIP_DIVESET *diveset)
Definition: heur.c:731
int SCIPdivesetGetNSolutionCalls(SCIP_DIVESET *diveset, SCIP_DIVECONTEXT divecontext)
Definition: heur.c:498
int SCIPdivesetGetMaxLPIterOffset(SCIP_DIVESET *diveset)
Definition: heur.c:663
char SCIPheurGetDispchar(SCIP_HEUR *heur)
Definition: heur.c:1473
SCIP_HEURDATA * SCIPheurGetData(SCIP_HEUR *heur)
Definition: heur.c:1364
SCIP_HEURTIMING SCIPheurGetTimingmask(SCIP_HEUR *heur)
Definition: heur.c:1483
const char * SCIPheurGetDesc(SCIP_HEUR *heur)
Definition: heur.c:1463
SCIP_Longint SCIPheurGetNSolsFound(SCIP_HEUR *heur)
Definition: heur.c:1589
int SCIPheurGetPriority(SCIP_HEUR *heur)
Definition: heur.c:1514
SCIP_Bool SCIPheurUsesSubscip(SCIP_HEUR *heur)
Definition: heur.c:1504
SCIP_Longint SCIPheurGetNBestSolsFound(SCIP_HEUR *heur)
Definition: heur.c:1599
void SCIPheurSetFreq(SCIP_HEUR *heur, int freq)
Definition: heur.c:1548
void SCIPheurSetTimingmask(SCIP_HEUR *heur, SCIP_HEURTIMING timingmask)
Definition: heur.c:1493
SCIP_Longint SCIPheurGetNCalls(SCIP_HEUR *heur)
Definition: heur.c:1579
int SCIPheurGetFreqofs(SCIP_HEUR *heur)
Definition: heur.c:1559
SCIP_DECL_SORTPTRCOMP(SCIPheurComp)
Definition: heur.c:51
SCIP_Real SCIPheurGetSetupTime(SCIP_HEUR *heur)
Definition: heur.c:1631
int SCIPheurGetMaxdepth(SCIP_HEUR *heur)
Definition: heur.c:1569
int SCIPheurGetNDivesets(SCIP_HEUR *heur)
Definition: heur.c:1661
int SCIPheurGetFreq(SCIP_HEUR *heur)
Definition: heur.c:1538
SCIP_Real SCIPheurGetTime(SCIP_HEUR *heur)
Definition: heur.c:1641
const char * SCIPheurGetName(SCIP_HEUR *heur)
Definition: heur.c:1453
SCIP_Bool SCIPheurIsInitialized(SCIP_HEUR *heur)
Definition: heur.c:1609
SCIP_DIVESET ** SCIPheurGetDivesets(SCIP_HEUR *heur)
Definition: heur.c:1651
void SCIPheurSetData(SCIP_HEUR *heur, SCIP_HEURDATA *heurdata)
Definition: heur.c:1374
void SCIPvariableGraphFree(SCIP *scip, SCIP_VGRAPH **vargraph)
Definition: heur.c:2035
SCIP_RETCODE SCIPvariablegraphBreadthFirst(SCIP *scip, SCIP_VGRAPH *vargraph, SCIP_VAR **startvars, int nstartvars, int *distances, int maxdistance, int maxvars, int maxbinintvars)
Definition: heur.c:1690
SCIP_RETCODE SCIPvariableGraphCreate(SCIP *scip, SCIP_VGRAPH **vargraph, SCIP_Bool relaxdenseconss, SCIP_Real relaxdensity, int *nrelaxedconstraints)
Definition: heur.c:1997
SCIP_HEUR * SCIPdivesetGetHeur(SCIP_DIVESET *diveset)
Definition: heur.c:416
SCIP_SOL * SCIPdivesetGetWorkSolution(SCIP_DIVESET *diveset)
Definition: heur.c:424
void SCIPdivesetSetWorkSolution(SCIP_DIVESET *diveset, SCIP_SOL *sol)
Definition: heur.c:434
type definitions for primal heuristics
enum SCIP_DiveContext SCIP_DIVECONTEXT
Definition: type_heur.h:73
struct SCIP_HeurData SCIP_HEURDATA
Definition: type_heur.h:77
unsigned int SCIP_DIVETYPE
Definition: type_heur.h:63
type definitions for miscellaneous datastructures
type definitions for return codes for SCIP methods
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:63
type definitions for SCIP's main datastructure
type definitions for storing primal CIP solutions
timing definitions for SCIP
unsigned int SCIP_HEURTIMING
Definition: type_timing.h:101
type definitions for problem variables