Scippy

SCIP

Solving Constraint Integer Programs

struct_syncstore.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-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_syncstore.h
26  * @ingroup PARALLEL
27  * @brief the struct definitions for the synchronization store
28  * @author Stephen J. Maher
29  * @author Leona Gottwald
30  */
31 
32 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
33 
34 #ifndef __STRUCT_SYNCSTORE_H__
35 #define __STRUCT_SYNCSTORE_H__
36 
37 #include "scip/type_syncstore.h"
38 #include "tpi/type_tpi.h"
39 #include "scip/def.h"
40 #include "scip/type_scip.h"
41 #include "scip/type_stat.h"
42 #include "scip/type_lp.h"
43 
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47 
49 {
50  int nuses; /**< number of uses of the synchronization store */
51  SCIP_PARALLELMODE mode; /**< the mode for the parallel solving */
52  SCIP_Bool initialized; /**< flag to indicate whether the syncstore has been initialized */
53  int ninitvars; /**< number of variables it has been initialized for */
54  SCIP_SYNCDATA* syncdata; /**< array of size nsyncdata, containing the synchronization data
55  * for each active synchroization */
56  SCIP_SYNCDATA* lastsync; /**< pointer to the last synchronization data that has been synchronized
57  * by all threads */
58 
59  SCIP* mainscip; /**< the SCIP instance that was used for initializing the syncstore */
60  SCIP_Bool stopped; /**< flag to indicate if the solving is stopped */
61  SCIP_LOCK lock; /**< lock to protect the syncstore data structure from data races */
62 
63  /* SPI settings */
64  int nsyncdata; /**< the size of the synchronization data array */
65  SCIP_Real minsyncdelay; /**< the minimum delay before a synchronization data may be read */
66  int maxnsyncdelay; /**< maximum number of synchronizations before the reading of the next
67  * synchronization data is enforced regardless of the minimal synchroization
68  * delay */
69  SCIP_Real syncfreqinit; /**< the initial synchronization frequency which is read from the settings
70  * of the main SCIP when the syncstore is initialized */
71  SCIP_Real syncfreqmax; /**< the maximum synchronization frequency */
72  int maxnsols; /**< maximum number of solutions that can be shared in one synchronization */
73  int nsolvers; /**< number of solvers synchronizing with this syncstore */
74 };
75 
76 
77 struct SCIP_SyncData
78 {
79  SCIP_Real* solobj; /**< array with the objective value of all stored solutions */
80  SCIP_Real** sols; /**< array with the solution values of each variable for all stored solutions */
81  int* solsource; /**< the solverid of the solution came from */
82  int nsols; /**< number of solutions currently stored in the synchronization data */
83  SCIP_Real bestlowerbound; /**< largest lower bound on the objective value that was stored in this
84  * synchroization data */
85  SCIP_Real bestupperbound; /**< smalles upper bound on the objective value that was stored in this
86  * synchroization data */
87  SCIP_Longint syncnum; /**< the synchronization number of this synchronization data */
88  int winner; /**< the solverid of the solver with the best status */
89  SCIP_STATUS status; /**< the best status that was stored in this synchronization data */
90  SCIP_LOCK lock; /**< a lock to protect this synchronization data */
91  int syncedcount; /**< a counter of how many solvers have finished writing to this synchronization data */
92  SCIP_CONDITION allsynced; /**< a condition variable to signal when the last solver has finished writing to this
93  * synchronization data */
94  SCIP_BOUNDSTORE* boundstore; /**< a boundstore for storing all the bound changes that were added to this
95  * synchronization data */
96  SCIP_Real syncfreq; /**< the synchroization frequency that was set in this synchronization data */
97  SCIP_Longint memtotal; /**< the total amount of memory used by all solvers including the main SCIP */
98 };
99 
100 /** struct for storing the position of avariables lower and upper bound in the boundstore */
101 typedef struct
102 {
103  int pos[2]; /**< stores at pos[SCIP_BOUNDTYPE_LOWER] the position of the lowerbound and
104  * at pos[SCIP_BOUNDTYPE_UPPER] the position of the upperbound */
105 } BoundPos;
106 
107 /** struct for storing a single boundchange in the boundstore */
108 typedef struct
109 {
110  int varidx; /**< the variables position in the variable array of the main scip */
111  SCIP_Real newbound; /**< the variables new bound */
112  SCIP_BOUNDTYPE boundtype; /**< the type of the variables new bound */
113 } BoundChg;
114 
116 {
117  int nvars; /**< the number of variables to store bounds for */
118  BoundPos* bndpos; /**< array of size nvars to store the positions for all the bound changes
119  * stored in this boundstore */
120  BoundChg* bndchg; /**< array of boundchanges */
121  int nbndchg; /**< the number of boundchanges stored in this bound store */
122  int bndchgsize; /**< the size of the bound change array */
123 };
124 
125 #ifdef __cplusplus
126 }
127 #endif
128 
129 #endif
enum SCIP_BoundType SCIP_BOUNDTYPE
Definition: type_lp.h:59
SCIP_PARALLELMODE mode
SCIP_Real newbound
SCIP_SYNCDATA * lastsync
the type definitions for the task processing interface
type definitions for problem statistics
type definitions for LP management
SCIP_Real minsyncdelay
type definitions for SCIP&#39;s main datastructure
struct SCIP_SyncData SCIP_SYNCDATA
SCIP_BOUNDTYPE boundtype
SCIP_Bool initialized
SCIP_SYNCDATA * syncdata
#define SCIP_Bool
Definition: def.h:93
enum SCIP_Status SCIP_STATUS
Definition: type_stat.h:67
enum SCIP_Parallelmode SCIP_PARALLELMODE
the type definitions for the synchronization store
SCIP_Real syncfreqmax
#define SCIP_Real
Definition: def.h:186
SCIP_Real syncfreqinit
#define SCIP_Longint
Definition: def.h:171
common defines and data types used in all packages of SCIP