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 struct_reopt.h 26 * @ingroup INTERNALAPI 27 * @brief data structures for collecting reoptimization information 28 * @author Jakob Witzig 29 */ 30 31 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ 32 33 #ifndef __SCIP_STRUCT_REOPT_H__ 34 #define __SCIP_STRUCT_REOPT_H__ 35 36 #include "scip/def.h" 37 #include "scip/type_clock.h" 38 #include "scip/type_cons.h" 39 #include "scip/type_history.h" 40 #include "scip/type_lp.h" 41 #include "scip/type_misc.h" 42 #include "scip/type_reopt.h" 43 #include "scip/type_sol.h" 44 #include "scip/type_var.h" 45 46 #ifdef __cplusplus 47 extern "C" { 48 #endif 49 50 /** nodes of SCIP_SolTree */ 51 struct SCIP_SolNode 52 { 53 SCIP_SOL* sol; /**< the stored solution */ 54 SCIP_SOLNODE* father; /**< pointer to the parent node */ 55 SCIP_SOLNODE* child; /**< pointer to left most child node, i.e., node representing the variable 56 * with smallest solution value 57 */ 58 SCIP_SOLNODE* sibling; /**< pointer to next sibling node */ 59 SCIP_Real value; /**< solution value represented by this node */ 60 SCIP_Bool updated; /**< flag if the solution is already updated 61 * w.r.t. the new objective function */ 62 #ifndef NDEBUG 63 SCIP_VAR* var; /**< variable represented by this node */ 64 #endif 65 }; 66 67 /** tree for solution */ 68 struct SCIP_SolTree 69 { 70 SCIP_SOLNODE*** sols; /**< array of arrays of solutions of the reoptimization runs */ 71 SCIP_SOLNODE* root; /**< root node of the solution tree */ 72 int* solssize; /**< size of sols[x] arrays */ 73 int* nsols; /**< number of solutions stored in sols[x] array */ 74 }; 75 76 /** data for constraints to split nodes during reoptimization */ 77 struct SCIP_ReoptConsData 78 { 79 SCIP_VAR** vars; /**< array of variables */ 80 SCIP_Real* vals; /**< array of variable coefficients or bounds */ 81 SCIP_BOUNDTYPE* boundtypes; /**< array of variable bounds */ 82 SCIP_Real lhs; /**< left hand side of the constraint */ 83 SCIP_Real rhs; /**< right hand side of the constraint */ 84 REOPT_CONSTYPE constype; /**< type of the constraint */ 85 SCIP_Bool linear; /**< TRUE, iff the constraint is linear, otherwise the constraint is of 86 * type bounddisjunction 87 */ 88 int varssize; /**< available size in the arrays */ 89 int nvars; /**< number of entries in the arrays */ 90 }; 91 92 /** nodes of SCIP_ReoptTree */ 93 struct SCIP_ReoptNode 94 { 95 SCIP_REOPTCONSDATA** conss; /**< array of constraints added to the node, i.e., logic-or constraints */ 96 SCIP_VAR** vars; /**< variables along the branching path up to the next stored node */ 97 SCIP_VAR** afterdualvars; /**< variables along the branching path after the first decision based on dual information */ 98 SCIP_REOPTCONSDATA* dualredscur; /**< dual reductions that need to be reconstructed the current round */ 99 SCIP_REOPTCONSDATA* dualredsnex; /**< dual reductions that need to be reconstructed the next round */ 100 SCIP_BOUNDTYPE* varboundtypes; /**< boundtypes along the branching path up to the next stored node */ 101 SCIP_BOUNDTYPE* afterdualvarboundtypes; /**< boundtypes along the branching path after the first dual information */ 102 SCIP_Real* varbounds; /**< bounds along the branching path up to the next stored node */ 103 SCIP_Real* afterdualvarbounds; /**< bounds along the branching path after the first decision based on dual information */ 104 SCIP_Real lowerbound; /**< the last lowerbound of this node in the previous iteration */ 105 SCIP_Bool dualreds; /**< flag whether dual reduction were performed */ 106 int nvars; /**< number of branching decisions up to the next stored node */ 107 int varssize; /**< size of allocated memory */ 108 int nafterdualvars; /**< number of branching decisions after the first dual information */ 109 int afterdualvarssize; /**< size of allocated memory */ 110 int nchilds; /**< number of child nodes */ 111 int allocchildmem; /**< allocated memory for child nodes */ 112 int nconss; /**< number of added constraints */ 113 int consssize; /**< allocated memory for constraints */ 114 unsigned int* childids; /**< array of child nodes that need to be reoptimized */ 115 116 unsigned int parentID:29; /**< id of the stored parent node */ 117 unsigned int reopttype:3; /**< reason for storing the node */ 118 }; 119 120 /* tree to store the current search tree */ 121 struct SCIP_ReoptTree 122 { 123 SCIP_REOPTNODE** reoptnodes; /**< array of SCIP_REOPTNODE */ 124 SCIP_QUEUE* openids; /**< queue of open positions in the reoptnodes array */ 125 int nreoptnodes; /**< number of saved nodes */ 126 int nfeasnodes; /**< number of feasible nodes in the current run */ 127 int ntotalfeasnodes; /**< number of feasible nodes over all runs */ 128 int ninfnodes; /**< number of (LP-)infeasible nodes in the current run */ 129 int ntotalinfnodes; /**< number of (LP-)infeasible nodes over all runs */ 130 int nprunednodes; /**< number of pruned nodes in the current run */ 131 int ntotalprunednodes; /**< number of pruned nodes over all runs */ 132 int ncutoffreoptnodes; /**< number of cut off reoptimized nodes in the current run */ 133 int ntotalcutoffreoptnodes; /**< number of cut off reoptimized nodes over all runs */ 134 SCIP_Bool initialized; /**< is the data structure initialized? */ 135 unsigned int reoptnodessize; /**< size of allocated memory for the reoptnodes array and the openid queue */ 136 }; 137 138 /** reoptimization data and solution storage */ 139 struct SCIP_Reopt 140 { 141 SCIP_SOL** prevbestsols; /**< list of best solutions of all previous rounds */ 142 SCIP_Real** objs; /**< list of objective coefficients */ 143 SCIP_HISTORY*** varhistory; /**< collected variable history */ 144 SCIP_REOPTCONSDATA** glbconss; /**< global constraints that need to be added at the beginning of the next iteration */ 145 SCIP_REOPTCONSDATA* dualreds; /**< dual reductions that probably need to be reconstructed at this node */ 146 SCIP_REOPTTREE* reopttree; /**< data structure to store the current reoptimization search tree */ 147 SCIP_SOLTREE* soltree; /**< tree to handle all saved solutions */ 148 SCIP_RANDNUMGEN* randnumgen; /**< random number generator */ 149 SCIP_CLOCK* savingtime; /**< time needed to store the nodes */ 150 SCIP_CONS** addedconss; /**< array of added constraints */ 151 SCIP_Real simtolastobj; /**< similarity to the last objective function */ 152 SCIP_Real simtofirstobj; /**< similarity to the first objective function */ 153 SCIP_Longint lastbranched; /**< number of the last branched node */ 154 SCIP_Longint lastseennode; /**< node number of the last caught event */ 155 int nobjvars; /**< number of variables in the objective function */ 156 int addedconsssize; /**< size of addedconss array */ 157 int naddedconss; /**< number of constraints added */ 158 SCIP_Bool objhaschanged; /**< TRUE iff the objective fucntion has changd */ 159 SCIP_Bool consadded; /**< TRUE iff a constraint was added */ 160 int nactiveconss; /**< number of active constraints stored in activeconss */ 161 SCIP_CONS** activeconss; /**< storage for active constraints */ 162 int nmaxactiveconss; /**< maximal number of active constraints stored in activeconss */ 163 164 /* hashmaps to track global bound reductions and constraints deletion during presolving */ 165 SCIP_HASHMAP* glblb; /**< global lower bounds after presolving of the first problem */ 166 SCIP_HASHMAP* glbub; /**< global upper bounds after presolving of the first problem */ 167 SCIP_HASHSET* activeconssset; /**< set of all active constraints after presolving the first problem */ 168 169 /* data structure to track decisions based on dual information */ 170 SCIP_Longint currentnode; /**< number of the current node */ 171 int run; /**< number of the current reoptimization run */ 172 int runsize; /**< allocated memory for runs */ 173 int firstobj; /**< first non empty objective function */ 174 int noptsolsbyreoptsol; /**< number of successive optimal solutions found by heur_reoptsols */ 175 int nglbconss; /**< number of stored global constraints */ 176 int allocmemglbconss; /**< allocated memory for global constraints */ 177 int ncheckedsols; /**< number of updated solutions by reoptsols */ 178 int nimprovingsols; /**< number of improving solutions found by reoptsols */ 179 int nglbrestarts; /**< number of global restarts */ 180 int ntotallocrestarts; /**< number of local restarts over all runs */ 181 int nlocrestarts; /**< number of local restarts in the current iteration */ 182 int firstrestart; /**< run with the first global restart or -1 of no restart */ 183 int lastrestart; /**< run with the last global restart or -1 if no restart */ 184 }; 185 186 #ifdef __cplusplus 187 } 188 #endif 189 190 #endif 191