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 concurrent.h 26 * @ingroup PARALLEL 27 * @brief helper functions for concurrent scip solvers 28 * @author Leona Gottwald 29 */ 30 31 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ 32 33 #include "scip/type_concurrent.h" 34 #include "scip/type_scip.h" 35 #include "scip/type_concsolver.h" 36 #include "scip/type_sol.h" 37 #include "scip/type_var.h" 38 #include "scip/type_syncstore.h" 39 #include "scip/def.h" 40 41 #ifndef __SCIP_CONCURRENT_H__ 42 #define __SCIP_CONCURRENT_H__ 43 44 #ifdef __cplusplus 45 extern "C" { 46 #endif 47 48 /** create concurrent data */ 49 SCIP_RETCODE SCIPcreateConcurrent( 50 SCIP* scip, /**< SCIP datastructure */ 51 SCIP_CONCSOLVER* concsolver, /**< concurrent solver of given SCIP instance */ 52 int* varperm /**< permutation of variables for communication */ 53 ); 54 55 /** get number of initialized concurrent solvers */ 56 int SCIPgetNConcurrentSolvers( 57 SCIP* scip /**< SCIP datastructure */ 58 ); 59 60 /** gets the concurrent solvers */ 61 SCIP_CONCSOLVER** SCIPgetConcurrentSolvers( 62 SCIP* scip /**< SCIP datastructure */ 63 ); 64 65 /** adds a concurrent solver */ 66 SCIP_RETCODE SCIPaddConcurrentSolver( 67 SCIP* scip, /**< SCIP datastructure */ 68 SCIP_CONCSOLVER* concsolver /**< concurrent solver of given SCIP instance */ 69 ); 70 71 /** frees concurrent data */ 72 SCIP_RETCODE SCIPfreeConcurrent( 73 SCIP* scip /**< SCIP datastructure */ 74 ); 75 76 /** increments the time counter for synchronization */ 77 SCIP_RETCODE SCIPincrementConcurrentTime( 78 SCIP* scip, /**< SCIP datastructure */ 79 SCIP_Real val /**< value by which the time counter for synchronization is incremented */ 80 ); 81 82 /** synchronize with other concurrent solvers */ 83 SCIP_RETCODE SCIPsynchronize( 84 SCIP* scip /**< SCIP datastructure */ 85 ); 86 87 /** pass a solution to the given SCIP instance using that was received via synchronization by using 88 * the sync heuristic */ 89 SCIP_RETCODE SCIPaddConcurrentSol( 90 SCIP* scip, /**< SCIP datastructure */ 91 SCIP_SOL* sol /**< solution */ 92 ); 93 94 /** adds a global boundchange to the given SCIP, by passing it to the sync propagator */ 95 SCIP_RETCODE SCIPaddConcurrentBndchg( 96 SCIP* scip, /**< SCIP data structure */ 97 SCIP_VAR* var, /**< variable for bound */ 98 SCIP_Real val, /**< value of bound */ 99 SCIP_BOUNDTYPE bndtype /**< type of bound */ 100 ); 101 102 /** copy the nodenumber, depth, time, and runnumber of one solution to another one */ 103 SCIP_RETCODE SCIPcopySolStats( 104 SCIP_SOL* source, /**< source for solution statistics */ 105 SCIP_SOL* target /**< target for solution statistics */ 106 ); 107 108 /** copy solving statistics */ 109 SCIP_RETCODE SCIPcopyConcurrentSolvingStats( 110 SCIP* source, /**< SCIP data structure */ 111 SCIP* target /**< target SCIP data structure */ 112 ); 113 114 /** get variable index of original variable that is the same between concurrent solvers */ 115 int SCIPgetConcurrentVaridx( 116 SCIP* scip, /**< SCIP data structure */ 117 SCIP_VAR* var /**< variable */ 118 ); 119 120 /** has the solution been created after the last synchronization point */ 121 SCIP_Bool SCIPIsConcurrentSolNew( 122 SCIP* scip, /**< SCIP data structure */ 123 SCIP_SOL* sol /**< the solution */ 124 ); 125 126 /** gets the global bound changes since the last synchronization point */ 127 SCIP_BOUNDSTORE* SCIPgetConcurrentGlobalBoundChanges( 128 SCIP* scip /**< SCIP data structure */ 129 ); 130 131 /** start solving in parallel using the given set of concurrent solvers */ 132 SCIP_RETCODE SCIPconcurrentSolve( 133 SCIP* scip /**< pointer to scip datastructure */ 134 ); 135 136 /** disables storing global bound changes */ 137 void SCIPdisableConcurrentBoundStorage( 138 SCIP* scip /**< SCIP data structure */ 139 ); 140 141 /** enables storing global bound changes */ 142 void SCIPenableConcurrentBoundStorage( 143 SCIP* scip /**< SCIP data structure */ 144 ); 145 146 /** gets total memory usage of all concurrent solvers together */ 147 SCIP_Longint SCIPgetConcurrentMemTotal( 148 SCIP* scip /**< SCIP data structure */ 149 ); 150 151 /** gets the dualbound in the last synchronization */ 152 SCIP_Real SCIPgetConcurrentDualbound( 153 SCIP* scip /**< SCIP data structure */ 154 ); 155 156 /** gets the primalbound in the last synchronization */ 157 SCIP_Real SCIPgetConcurrentPrimalbound( 158 SCIP* scip /**< SCIP data structure */ 159 ); 160 161 /** gets the gap in the last synchronization */ 162 SCIP_Real SCIPgetConcurrentGap( 163 SCIP* scip /**< SCIP data structure */ 164 ); 165 166 /** gives the total number of tightened bounds received from other concurrent solvers */ 167 SCIP_Longint SCIPgetConcurrentNTightenedBnds( 168 SCIP* scip /**< SCIP data structure */ 169 ); 170 171 /** gives the total number of tightened bounds for integer variables received from 172 * other concurrent solvers */ 173 SCIP_Longint SCIPgetConcurrentNTightenedIntBnds( 174 SCIP* scip /**< SCIP data structure */ 175 ); 176 177 #ifdef __cplusplus 178 } 179 #endif 180 181 #endif 182