Scippy

SCIP

Solving Constraint Integer Programs

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 2002-2022 Zuse Institute Berlin */
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 syncstore.h
26  * @ingroup PARALLEL
27  * @brief the function declarations for the synchronization store
28  * @author Leona Gottwald
29  * @author Stephen J. Maher
30  */
31 
32 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
33 
34 #ifndef __SYNCSTORE_H__
35 #define __SYNCSTORE_H__
36 
37 #include "scip/def.h"
38 #include "scip/type_syncstore.h"
39 #include "scip/type_scip.h"
40 #include "scip/type_retcode.h"
41 
42 /** creates and captures a new synchronization store */
43 SCIP_EXPORT
45  SCIP_SYNCSTORE** syncstore /**< pointer to return the created synchronization store */
46  );
47 
48 /** releases a synchronization store */
49 SCIP_EXPORT
51  SCIP_SYNCSTORE** syncstore /**< pointer to the synchronization store */
52  );
53 
54 /** captures a synchronization store */
55 SCIP_EXPORT
57  SCIP_SYNCSTORE* syncstore /**< the synchronization store */
58  );
59 
60 /** initialize the syncstore for the given SCIP instance */
61 SCIP_EXPORT
63  SCIP* scip /**< SCIP main datastructure */
64  );
65 
66 /** deinitializes the synchronization store */
67 SCIP_EXPORT
69  SCIP_SYNCSTORE* syncstore /**< the synchronization store */
70  );
71 
72 /** checks whether the solve-is-stopped flag in the syncstore has been set by any thread */
73 SCIP_EXPORT
75  SCIP_SYNCSTORE* syncstore /**< the synchronization store */
76  );
77 
78 /** sets the solve-is-stopped flag in the syncstore so that subsequent calls to
79  * SCIPsyncstoreSolveIsStopped will return the given value in any thread
80  */
81 SCIP_EXPORT
83  SCIP_SYNCSTORE* syncstore, /**< the synchronization store */
84  SCIP_Bool stopped /**< flag if the solve is stopped */
85  );
86 
87 /** gets the upperbound from the last synchronization */
88 SCIP_EXPORT
90  SCIP_SYNCSTORE* syncstore /**< the synchronization store */
91  );
92 
93 /** gets the lowerbound from the last synchronization */
94 SCIP_EXPORT
96  SCIP_SYNCSTORE* syncstore /**< the synchronization store */
97  );
98 
99 /** gets the number of solutions from the last synchronization */
100 SCIP_EXPORT
102  SCIP_SYNCSTORE* syncstore /**< the synchronization store */
103  );
104 
105 /** gets the number of boundchanges from the last synchronization */
106 SCIP_EXPORT
108  SCIP_SYNCSTORE* syncstore /**< the synchronization store */
109  );
110 
111 /** gets total memory used by all solvers from the last synchronization */
112 SCIP_EXPORT
114  SCIP_SYNCSTORE* syncstore /**< the synchronization store */
115  );
116 
117 /** gets the synchronization frequency from the last synchronization */
118 SCIP_EXPORT
120  SCIP_SYNCSTORE* syncstore /**< the synchronization store */
121  );
122 
123 /** get synchronization data with given number. It is the responsibility of the caller
124  * to only ask for a synchronization number that still exists. */
125 SCIP_EXPORT
127  SCIP_SYNCSTORE* syncstore, /**< the synchronization store */
128  SCIP_Longint syncnum /**< the number of the synchronization to start, which
129  * must be increasing between calls of the same thread */
130  );
131 
132 /** get the next synchronization data that should be read and
133  * adjust the delay. Returns NULL if no more data should be read due to minimum delay */
134 SCIP_EXPORT
136  SCIP_SYNCSTORE* syncstore, /**< the synchronization store */
137  SCIP_SYNCDATA* syncdata, /**< the synchronization data */
138  SCIP_Real syncfreq, /**< the current synchronization frequency */
139  SCIP_Longint writenum, /**< number of synchronizations the solver has written to */
140  SCIP_Real* delay /**< pointer holding the current synchronization delay */
141  );
142 
143 /** ensures that the given synchronization data has been written by
144  * all solvers upon return of this function and blocks the caller if necessary. */
145 SCIP_EXPORT
147  SCIP_SYNCSTORE* syncstore, /**< the synchronization store */
148  SCIP_SYNCDATA* syncdata /**< the synchronization data */
149  );
150 
151 /** Start synchronization for the given concurrent solver.
152  * Needs to be followed by a call to SCIPsyncstoreFinishSync if
153  * the syncdata that is returned is not NULL
154  */
155 SCIP_EXPORT
157  SCIP_SYNCSTORE* syncstore, /**< the synchronization store */
158  SCIP_Longint syncnum, /**< the number of the synchronization to start, which
159  * must be increasing between calls of the same thread */
160  SCIP_SYNCDATA** syncdata /**< pointer to return the synchronization data */
161  );
162 
163 /** finishes synchronization for the synchronization data */
164 SCIP_EXPORT
166  SCIP_SYNCSTORE* syncstore, /**< the synchronization store */
167  SCIP_SYNCDATA** syncdata /**< the synchronization data */
168  );
169 
170 /** gets status in synchronization data */
171 SCIP_EXPORT
173  SCIP_SYNCDATA* syncdata /**< the synchronization data */
174  );
175 
176 /** gets the solver that had the best status, or -1 if solve is not stopped yet */
177 SCIP_EXPORT
179  SCIP_SYNCSTORE* syncstore /**< the synchronization store */
180  );
181 
182 /** how many solvers have already finished synchronizing on this sychronization data */
183 SCIP_EXPORT
185  SCIP_SYNCDATA* syncdata /**< the synchronization data */
186  );
187 
188 /** how many solvers have are running concurrently */
189 SCIP_EXPORT
191  SCIP_SYNCSTORE* syncstore /**< the synchronization store */
192  );
193 
194 /** read amount of memory used from synchronization data */
195 SCIP_EXPORT
197  SCIP_SYNCDATA* syncdata /**< the synchronization data */
198  );
199 
200 /** read the synchronization frequency from a synchronization data */
201 SCIP_EXPORT
203  SCIP_SYNCDATA* syncdata /**< the synchronization data */
204  );
205 
206 /** read the upperbound stored in a synchronization data */
207 SCIP_EXPORT
209  SCIP_SYNCDATA* syncdata /**< the synchronization data */
210  );
211 
212 /** read the lowerbound stored in a synchronization data */
213 SCIP_EXPORT
215  SCIP_SYNCDATA* syncdata /**< the synchronization data */
216  );
217 
218 /** read the solutions stored in a synchronization data */
219 SCIP_EXPORT
221  SCIP_SYNCDATA* syncdata, /**< the synchronization data */
222  SCIP_Real*** solvalues, /**< pointer to return array of buffers containing the solution values */
223  int** solowner, /**< pointer to return array of ownerids of solutions */
224  int* nsols /**< pointer to return number of solutions */
225  );
226 
227 /** read bound changes stored in the synchronization data */
228 SCIP_EXPORT
230  SCIP_SYNCDATA* syncdata /**< the synchronization data */
231  );
232 
233 /** write the synchronization frequency to a synchronization data */
234 SCIP_EXPORT
236  SCIP_SYNCSTORE* syncstore, /**< the synchronization store */
237  SCIP_SYNCDATA* syncdata, /**< the synchronization data */
238  SCIP_Real syncfreq /**< the synchronization frequency */
239  );
240 
241 /** set status in the synchronization data */
242 SCIP_EXPORT
244  SCIP_SYNCDATA* syncdata, /**< the synchronization data the upperbound should be added to */
245  SCIP_STATUS status, /**< the status */
246  int solverid /**< identifier of te solver that has this status */
247  );
248 
249 /** adds memory used to the synchronization data */
250 SCIP_EXPORT
252  SCIP_SYNCDATA* syncdata, /**< the synchronization data the solution should be added to */
253  SCIP_Longint memtotal /**< the number of bytes used */
254  );
255 
256 /** set upperbound to the synchronization data */
257 SCIP_EXPORT
259  SCIP_SYNCDATA* syncdata, /**< the synchronization data the upperbound should be added to */
260  SCIP_Real upperbound /**< the upperbound */
261  );
262 
263 /** set lowerbound to the synchronization data */
264 SCIP_EXPORT
266  SCIP_SYNCDATA* syncdata, /**< the synchronization data the lowerbound should be added to */
267  SCIP_Real lowerbound /**< the lowerbound */
268  );
269 
270 /** gives a buffer to store the solution values, or NULL if solution should not be stored
271  * because there are already better solutions stored.
272  */
273 SCIP_EXPORT
275  SCIP_SYNCSTORE* syncstore, /**< the synchronization store */
276  SCIP_SYNCDATA* syncdata, /**< the synchronization data the solution should be added to */
277  SCIP_Real solobj, /**< the objective value of the solution */
278  int ownerid, /**< an identifier for the owner of the solution, e.g. the thread number */
279  SCIP_Real** buffer /**< pointer to return a buffer for the solution values, which must be set
280  * if the buffer is not NULL */
281  );
282 
283 /** adds bound changes to the synchronization data */
284 SCIP_EXPORT
286  SCIP_SYNCSTORE* syncstore, /**< the synchronization store */
287  SCIP_SYNCDATA* syncdata, /**< the synchronization data */
288  SCIP_BOUNDSTORE* boundstore /**< bound store containing the bounds to add */
289  );
290 
291 /** is synchronization store initialized */
292 SCIP_EXPORT
294  SCIP_SYNCSTORE* syncstore /**< the synchronization store */
295  );
296 
297 /** returns the mode of the synchronization store */
298 SCIP_EXPORT
300  SCIP_SYNCSTORE* syncstore /**< the synchronization store */
301  );
302 
303 #endif
int SCIPsyncstoreGetNSolvers(SCIP_SYNCSTORE *syncstore)
Definition: syncstore.c:549
SCIP_RETCODE SCIPsyncstoreEnsureAllSynced(SCIP_SYNCSTORE *syncstore, SCIP_SYNCDATA *syncdata)
Definition: syncstore.c:405
SCIP_RETCODE SCIPsyncstoreRelease(SCIP_SYNCSTORE **syncstore)
Definition: syncstore.c:87
void SCIPsyncdataSetLowerbound(SCIP_SYNCDATA *syncdata, SCIP_Real lowerbound)
Definition: syncstore.c:695
SCIP_STATUS SCIPsyncdataGetStatus(SCIP_SYNCDATA *syncdata)
Definition: syncstore.c:515
void SCIPsyncdataSetUpperbound(SCIP_SYNCDATA *syncdata, SCIP_Real upperbound)
Definition: syncstore.c:684
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:63
SCIP_SYNCDATA * SCIPsyncstoreGetSyncdata(SCIP_SYNCSTORE *syncstore, SCIP_Longint syncnum)
Definition: syncstore.c:336
type definitions for return codes for SCIP methods
SCIP_SYNCDATA * SCIPsyncstoreGetNextSyncdata(SCIP_SYNCSTORE *syncstore, SCIP_SYNCDATA *syncdata, SCIP_Real syncfreq, SCIP_Longint writenum, SCIP_Real *delay)
Definition: syncstore.c:357
SCIP_PARALLELMODE SCIPsyncstoreGetMode(SCIP_SYNCSTORE *syncstore)
Definition: syncstore.c:794
SCIP_Real SCIPsyncstoreGetLastLowerbound(SCIP_SYNCSTORE *syncstore)
Definition: syncstore.c:279
void SCIPsyncdataGetSolutionBuffer(SCIP_SYNCSTORE *syncstore, SCIP_SYNCDATA *syncdata, SCIP_Real solobj, int ownerid, SCIP_Real **buffer)
Definition: syncstore.c:708
SCIP_Real SCIPsyncstoreGetLastUpperbound(SCIP_SYNCSTORE *syncstore)
Definition: syncstore.c:268
void SCIPsyncdataSetStatus(SCIP_SYNCDATA *syncdata, SCIP_STATUS status, int solverid)
Definition: syncstore.c:642
void SCIPsyncdataSetSyncFreq(SCIP_SYNCSTORE *syncstore, SCIP_SYNCDATA *syncdata, SCIP_Real syncfreq)
Definition: syncstore.c:628
SCIP_Bool SCIPsyncstoreIsInitialized(SCIP_SYNCSTORE *syncstore)
Definition: syncstore.c:784
type definitions for SCIP&#39;s main datastructure
struct SCIP_SyncData SCIP_SYNCDATA
SCIP_Real SCIPsyncstoreGetLastSyncfreq(SCIP_SYNCSTORE *syncstore)
Definition: syncstore.c:323
void SCIPsyncdataAddMemTotal(SCIP_SYNCDATA *syncdata, SCIP_Longint memtotal)
Definition: syncstore.c:673
SCIP_Longint SCIPsyncstoreGetLastMemTotal(SCIP_SYNCSTORE *syncstore)
Definition: syncstore.c:312
int SCIPsyncstoreGetWinner(SCIP_SYNCSTORE *syncstore)
Definition: syncstore.c:525
#define SCIP_Bool
Definition: def.h:93
enum SCIP_Status SCIP_STATUS
Definition: type_stat.h:67
enum SCIP_Parallelmode SCIP_PARALLELMODE
SCIP_RETCODE SCIPsyncstoreCreate(SCIP_SYNCSTORE **syncstore)
Definition: syncstore.c:66
SCIP_RETCODE SCIPsyncstoreInit(SCIP *scip)
Definition: syncstore.c:136
SCIP_RETCODE SCIPsyncstoreStartSync(SCIP_SYNCSTORE *syncstore, SCIP_Longint syncnum, SCIP_SYNCDATA **syncdata)
Definition: syncstore.c:434
SCIP_Longint SCIPsyncdataGetMemTotal(SCIP_SYNCDATA *syncdata)
Definition: syncstore.c:560
SCIP_RETCODE SCIPsyncstoreExit(SCIP_SYNCSTORE *syncstore)
Definition: syncstore.c:200
int SCIPsyncdataGetNSynced(SCIP_SYNCDATA *syncdata)
Definition: syncstore.c:539
SCIP_Real SCIPsyncdataGetLowerbound(SCIP_SYNCDATA *syncdata)
Definition: syncstore.c:590
the type definitions for the synchronization store
int SCIPsyncstoreGetLastNSols(SCIP_SYNCSTORE *syncstore)
Definition: syncstore.c:290
void SCIPsyncstoreSetSolveIsStopped(SCIP_SYNCSTORE *syncstore, SCIP_Bool stopped)
Definition: syncstore.c:255
SCIP_BOUNDSTORE * SCIPsyncdataGetBoundChgs(SCIP_SYNCDATA *syncdata)
Definition: syncstore.c:618
#define SCIP_Real
Definition: def.h:186
SCIP_Real SCIPsyncdataGetSyncFreq(SCIP_SYNCDATA *syncdata)
Definition: syncstore.c:570
SCIP_Real SCIPsyncdataGetUpperbound(SCIP_SYNCDATA *syncdata)
Definition: syncstore.c:580
SCIP_RETCODE SCIPsyncstoreFinishSync(SCIP_SYNCSTORE *syncstore, SCIP_SYNCDATA **syncdata)
Definition: syncstore.c:477
#define SCIP_Longint
Definition: def.h:171
common defines and data types used in all packages of SCIP
int SCIPsyncstoreGetLastNBounds(SCIP_SYNCSTORE *syncstore)
Definition: syncstore.c:301
SCIP_Bool SCIPsyncstoreSolveIsStopped(SCIP_SYNCSTORE *syncstore)
Definition: syncstore.c:237
void SCIPsyncdataGetSolutions(SCIP_SYNCDATA *syncdata, SCIP_Real ***solvalues, int **solowner, int *nsols)
Definition: syncstore.c:600
SCIP_RETCODE SCIPsyncstoreCapture(SCIP_SYNCSTORE *syncstore)
Definition: syncstore.c:122
SCIP_RETCODE SCIPsyncdataAddBoundChanges(SCIP_SYNCSTORE *syncstore, SCIP_SYNCDATA *syncdata, SCIP_BOUNDSTORE *boundstore)
Definition: syncstore.c:767