1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 2 /* */ 3 /* This file is part of the program and library */ 4 /* SCIP --- Solving Constraint Integer Programs */ 5 /* */ 6 /* Copyright (c) 2002-2023 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 type_heur.h 26 * @ingroup TYPEDEFINITIONS 27 * @brief type definitions for primal heuristics 28 * @author Tobias Achterberg 29 * @author Timo Berthold 30 * 31 * This file defines the interface for primal heuristics implemented in C. 32 * 33 * - \ref HEUR "Instructions for implementing a primal heuristic" 34 * - \ref PRIMALHEURISTICS "List of available primal heuristics" 35 * - \ref scip::ObjHeur "C++ wrapper class" 36 */ 37 38 /** @defgroup DEFPLUGINS_HEUR Default Primal Heuristics 39 * @ingroup DEFPLUGINS 40 * @brief implementation files (.c files) of the default primal heuristics of SCIP 41 */ 42 43 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ 44 45 #ifndef __SCIP_TYPE_HEUR_H__ 46 #define __SCIP_TYPE_HEUR_H__ 47 48 #include "scip/def.h" 49 #include "scip/type_scip.h" 50 #include "scip/type_result.h" 51 #include "scip/type_timing.h" 52 #include "scip/type_var.h" 53 54 #ifdef __cplusplus 55 extern "C" { 56 #endif 57 58 /** represents different methods for a dive set to explore the next children */ 59 #define SCIP_DIVETYPE_NONE 0x000u /**< no method specified */ 60 #define SCIP_DIVETYPE_INTEGRALITY 0x001u /**< use branching on a variable by shrinking the domain in the child nodes */ 61 #define SCIP_DIVETYPE_SOS1VARIABLE 0x002u /**< branch on a variable solution value by exploiting special-ordered set conflict structure */ 62 63 typedef unsigned int SCIP_DIVETYPE; 64 65 /** context for diving statistics */ 66 enum SCIP_DiveContext 67 { 68 SCIP_DIVECONTEXT_TOTAL = 0, /**< all contexts combined */ 69 SCIP_DIVECONTEXT_SINGLE = 1, /**< single heuristic context */ 70 SCIP_DIVECONTEXT_ADAPTIVE = 2, /**< within adaptive diving */ 71 SCIP_DIVECONTEXT_SCHEDULER = 3 /**< within the scheduler heuristic */ 72 }; 73 typedef enum SCIP_DiveContext SCIP_DIVECONTEXT; 74 75 76 typedef struct SCIP_Heur SCIP_HEUR; /**< primal heuristic */ 77 typedef struct SCIP_HeurData SCIP_HEURDATA; /**< locally defined primal heuristic data */ 78 typedef struct SCIP_Diveset SCIP_DIVESET; /**< common parameters for all diving heuristics */ 79 typedef struct SCIP_VGraph SCIP_VGRAPH; /**< variable graph data structure to determine breadth-first 80 * distances between variables */ 81 82 /** commonly used display characters indicating special classes of primal heuristics */ 83 #define SCIP_HEURDISPCHAR_LNS 'L' /**< a 'L'arge Neighborhood or other local search heuristic */ 84 #define SCIP_HEURDISPCHAR_DIVING 'd' /**< a 'd'iving heuristic that dives down an auxiliary branch-and-bound path */ 85 #define SCIP_HEURDISPCHAR_ITERATIVE 'i' /**< an iterative improvement heuristic such as 1-opt or 2-opt */ 86 #define SCIP_HEURDISPCHAR_OBJDIVING 'o' /**< an 'o'bjective diving or feasibility pump heuristic */ 87 #define SCIP_HEURDISPCHAR_PROP 'p' /**< a 'p'ropagation heuristic, often applied before branch-and-bound starts */ 88 #define SCIP_HEURDISPCHAR_ROUNDING 'r' /**< a 'r'ounding heuristic that iteratively tries to round an LP or relaxation solution */ 89 #define SCIP_HEURDISPCHAR_TRIVIAL 't' /**< a 't'rivial or helper heuristic, usually applied before branch-and-bound starts */ 90 91 /** copy method for heuristic plugins (called when SCIP copies plugins) 92 * 93 * input: 94 * - scip : SCIP main data structure 95 * - heur : the primal heuristic itself 96 */ 97 #define SCIP_DECL_HEURCOPY(x) SCIP_RETCODE x (SCIP* scip, SCIP_HEUR* heur) 98 99 /** destructor of primal heuristic to free user data (called when SCIP is exiting) 100 * 101 * input: 102 * - scip : SCIP main data structure 103 * - heur : the primal heuristic itself 104 */ 105 #define SCIP_DECL_HEURFREE(x) SCIP_RETCODE x (SCIP* scip, SCIP_HEUR* heur) 106 107 /** initialization method of primal heuristic (called after problem was transformed) 108 * 109 * input: 110 * - scip : SCIP main data structure 111 * - heur : the primal heuristic itself 112 */ 113 #define SCIP_DECL_HEURINIT(x) SCIP_RETCODE x (SCIP* scip, SCIP_HEUR* heur) 114 115 /** deinitialization method of primal heuristic (called before transformed problem is freed) 116 * 117 * input: 118 * - scip : SCIP main data structure 119 * - heur : the primal heuristic itself 120 */ 121 #define SCIP_DECL_HEUREXIT(x) SCIP_RETCODE x (SCIP* scip, SCIP_HEUR* heur) 122 123 /** solving process initialization method of primal heuristic (called when branch and bound process is about to begin) 124 * 125 * This method is called when the presolving was finished and the branch and bound process is about to begin. 126 * The primal heuristic may use this call to initialize its branch and bound specific data. 127 * 128 * input: 129 * - scip : SCIP main data structure 130 * - heur : the primal heuristic itself 131 */ 132 #define SCIP_DECL_HEURINITSOL(x) SCIP_RETCODE x (SCIP* scip, SCIP_HEUR* heur) 133 134 /** solving process deinitialization method of primal heuristic (called before branch and bound process data is freed) 135 * 136 * This method is called before the branch and bound process is freed. 137 * The primal heuristic should use this call to clean up its branch and bound data. 138 * 139 * input: 140 * - scip : SCIP main data structure 141 * - heur : the primal heuristic itself 142 */ 143 #define SCIP_DECL_HEUREXITSOL(x) SCIP_RETCODE x (SCIP* scip, SCIP_HEUR* heur) 144 145 /** execution method of primal heuristic 146 * 147 * Searches for feasible primal solutions. The method is called in the node processing loop. 148 * 149 * input: 150 * - scip : SCIP main data structure 151 * - heur : the primal heuristic itself 152 * - heurtiming : current point in the node solving loop 153 * - nodeinfeasible : was the current node already detected to be infeasible? 154 * - result : pointer to store the result of the heuristic call 155 * 156 * possible return values for *result: 157 * - SCIP_FOUNDSOL : at least one feasible primal solution was found 158 * - SCIP_DIDNOTFIND : the heuristic searched, but did not find a feasible solution 159 * - SCIP_DIDNOTRUN : the heuristic was skipped 160 * - SCIP_DELAYED : the heuristic was skipped, but should be called again as soon as possible, disregarding 161 * its frequency 162 */ 163 #define SCIP_DECL_HEUREXEC(x) SCIP_RETCODE x (SCIP* scip, SCIP_HEUR* heur, SCIP_HEURTIMING heurtiming, \ 164 SCIP_Bool nodeinfeasible, SCIP_RESULT* result) 165 166 167 /* callbacks for diving heuristic specific settings */ 168 169 /** calculate score and preferred rounding direction for the candidate variable; the best candidate maximizes the 170 * score 171 * 172 * input: 173 * - scip : SCIP main data structure 174 * - diveset : diving settings for scoring 175 * - divetype : represents different methods for a dive set to explore the next children 176 * - cand : candidate variable for which the score should be determined 177 * - candsol : solution value of variable in LP relaxation solution 178 * - candsfrac : fractional part of solution value of variable 179 * - score : pointer for diving score value - the best candidate maximizes this score 180 * - roundup : pointer to store whether the preferred rounding direction is upwards 181 * 182 * returns SCIP_OKAY if everything worked, otherwise, a suitable error code 183 */ 184 #define SCIP_DECL_DIVESETGETSCORE(x) SCIP_RETCODE x (SCIP* scip, SCIP_DIVESET* diveset, \ 185 SCIP_DIVETYPE divetype, SCIP_VAR* cand, SCIP_Real candsol, SCIP_Real candsfrac, SCIP_Real* score, SCIP_Bool* roundup) 186 187 /** 188 * optional callback to check preconditions for diving, e.g., if an incumbent solution is available 189 * 190 * input: 191 * - scip : SCIP main data structure 192 * - diveset : diving settings for scoring 193 * 194 * output: 195 * - available : TRUE if diveset can run, otherwise FALSE 196 * 197 * returns SCIP_OKAY if everything worked, otherwise, a suitable error code 198 */ 199 #define SCIP_DECL_DIVESETAVAILABLE(x) SCIP_RETCODE x (SCIP* scip, SCIP_DIVESET* diveset, SCIP_Bool* available) 200 201 #ifdef __cplusplus 202 } 203 #endif 204 205 #endif 206