Scippy

SCIP

Solving Constraint Integer Programs

heuristics.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 heuristics.h
17  * @ingroup PUBLICCOREAPI
18  * @brief methods commonly used by primal heuristics
19  * @author Gregor Hendel
20  */
21 
22 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
23 
24 #ifndef __SCIP_HEURISTICS_H__
25 #define __SCIP_HEURISTICS_H__
26 
27 #include "scip/def.h"
28 #include "scip/type_scip.h"
29 #include "scip/type_heur.h"
30 #include "scip/type_misc.h"
31 #include "scip/type_retcode.h"
32 #include "scip/type_sol.h"
33 #include "scip/type_var.h"
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 /**@defgroup PublicSpecialHeuristicMethods Special Methods
40  * @ingroup PublicHeuristicMethods
41  * @brief methods commonly used by primal heuristics
42  *
43  * @{
44  */
45 
46 /** performs a diving within the limits of the @p diveset parameters
47  *
48  * This method performs a diving according to the settings defined by the diving settings @p diveset; Contrary to the
49  * name, SCIP enters probing mode (not diving mode) and dives along a path into the tree. Domain propagation
50  * is applied at every node in the tree, whereas probing LPs might be solved less frequently.
51  *
52  * Starting from the current LP solution, the algorithm selects candidates which maximize the
53  * score defined by the @p diveset and whose solution value has not yet been rendered infeasible by propagation,
54  * and propagates the bound change on this candidate.
55  *
56  * The algorithm iteratively selects the the next (unfixed) candidate in the list, until either enough domain changes
57  * or the resolve frequency of the LP trigger an LP resolve (and hence, the set of potential candidates changes),
58  * or the last node is proven to be infeasible. It optionally backtracks and tries the
59  * other branching direction.
60  *
61  * After the set of remaining candidates is empty or the targeted depth is reached, the node LP is
62  * solved, and the old candidates are replaced by the new LP candidates.
63  *
64  * @see heur_guideddiving.c for an example implementation of a dive set controlling the diving algorithm.
65  *
66  * @note the node from where the algorithm is called is checked for a basic LP solution. If the solution
67  * is non-basic, e.g., when barrier without crossover is used, the method returns without performing a dive.
68  *
69  * @note currently, when multiple diving heuristics call this method and solve an LP at the same node, only the first
70  * call will be executed, @see SCIPgetLastDiveNode().
71  */
74  SCIP* scip, /**< SCIP data structure */
75  SCIP_DIVESET* diveset, /**< settings for diving */
76  SCIP_SOL* worksol, /**< non-NULL working solution */
77  SCIP_HEUR* heur, /**< the calling primal heuristic */
78  SCIP_RESULT* result, /**< SCIP result pointer */
79  SCIP_Bool nodeinfeasible, /**< is the current node known to be infeasible? */
80  SCIP_Longint iterlim, /**< nonnegative iteration limit for the LP solves, or -1 for dynamic setting */
81  SCIP_DIVECONTEXT divecontext /**< context for diving statistics */
82  );
83 
84 /** get a sub-SCIP copy of the transformed problem */
87  SCIP* sourcescip, /**< source SCIP data structure */
88  SCIP* subscip, /**< sub-SCIP used by the heuristic */
89  SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables to the corresponding
90  * target variables */
91  const char* suffix, /**< suffix for the problem name */
92  SCIP_VAR** fixedvars, /**< source variables whose copies should be fixed in the target SCIP environment, or NULL */
93  SCIP_Real* fixedvals, /**< array of fixing values for target SCIP variables, or NULL */
94  int nfixedvars, /**< number of source variables whose copies should be fixed in the target SCIP environment, or NULL */
95  SCIP_Bool uselprows, /**< should the linear relaxation of the problem defined by LP rows be copied? */
96  SCIP_Bool copycuts, /**< should cuts be copied (only if uselprows == FALSE) */
97  SCIP_Bool* success, /**< was the copying successful? */
98  SCIP_Bool* valid /**< pointer to store whether the copying was valid, or NULL */
99  );
100 
101 /** adds a trust region neighborhood constraint to the @p targetscip
102  *
103  * a trust region constraint measures the deviation from the current incumbent solution \f$x^*\f$ by an auxiliary
104  * continuous variable \f$v \geq 0\f$:
105  * \f[
106  * \sum\limits_{j\in B} |x_j^* - x_j| = v
107  * \f]
108  * Only binary variables are taken into account. The deviation is penalized in the objective function using
109  * a positive \p violpenalty.
110  *
111  * @note: the trust region constraint creates an auxiliary variable to penalize the deviation from
112  * the current incumbent solution. This variable can afterwards be accessed using SCIPfindVar() by its name
113  * 'trustregion_violationvar'
114  */
117  SCIP* scip, /**< the SCIP data structure */
118  SCIP* subscip, /**< SCIP data structure of the subproblem */
119  SCIP_VAR** subvars, /**< variables of the subproblem, NULL entries are ignored */
120  SCIP_Real violpenalty /**< the penalty for violating the trust region */
121  );
122 
123 /** @} */
124 
125 #ifdef __cplusplus
126 }
127 #endif
128 
129 #endif
enum SCIP_Result SCIP_RESULT
Definition: type_result.h:52
type definitions for miscellaneous datastructures
#define SCIP_EXPORT
Definition: def.h:100
SCIP_EXPORT SCIP_RETCODE SCIPperformGenericDivingAlgorithm(SCIP *scip, SCIP_DIVESET *diveset, SCIP_SOL *worksol, SCIP_HEUR *heur, SCIP_RESULT *result, SCIP_Bool nodeinfeasible, SCIP_Longint iterlim, SCIP_DIVECONTEXT divecontext)
Definition: heuristics.c:209
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:54
type definitions for return codes for SCIP methods
SCIP_EXPORT SCIP_RETCODE SCIPcopyLargeNeighborhoodSearch(SCIP *sourcescip, SCIP *subscip, SCIP_HASHMAP *varmap, const char *suffix, SCIP_VAR **fixedvars, SCIP_Real *fixedvals, int nfixedvars, SCIP_Bool uselprows, SCIP_Bool copycuts, SCIP_Bool *success, SCIP_Bool *valid)
Definition: heuristics.c:916
type definitions for primal heuristics
type definitions for SCIP&#39;s main datastructure
type definitions for problem variables
#define SCIP_Bool
Definition: def.h:70
type definitions for storing primal CIP solutions
enum SCIP_DiveContext SCIP_DIVECONTEXT
Definition: type_heur.h:63
SCIP_EXPORT SCIP_RETCODE SCIPaddTrustregionNeighborhoodConstraint(SCIP *scip, SCIP *subscip, SCIP_VAR **subvars, SCIP_Real violpenalty)
Definition: heuristics.c:990
#define SCIP_Real
Definition: def.h:163
#define SCIP_Longint
Definition: def.h:148
common defines and data types used in all packages of SCIP