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 (C) 2002-2019 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SCIP is distributed under the terms of the ZIB Academic License. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SCIP; see the file COPYING. If not visit scip.zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file syncstore.h
17  * @ingroup PARALLEL
18  * @brief the function declarations for the synchronization store
19  * @author Robert Lion Gottwald
20  * @author Stephen J. Maher
21  */
22 
23 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
24 
25 #ifndef __SYNCSTORE_H__
26 #define __SYNCSTORE_H__
27 
28 #include "scip/def.h"
29 #include "scip/type_syncstore.h"
30 #include "scip/type_scip.h"
31 #include "scip/type_retcode.h"
32 
33 /** creates and captures a new synchronization store */
36  SCIP_SYNCSTORE** syncstore /**< pointer to return the created synchronization store */
37  );
38 
39 /** releases a synchronization store */
42  SCIP_SYNCSTORE** syncstore /**< pointer to the synchronization store */
43  );
44 
45 /** captures a synchronization store */
48  SCIP_SYNCSTORE* syncstore /**< the synchronization store */
49  );
50 
51 /** initialize the syncstore for the given SCIP instance */
54  SCIP* scip /**< SCIP main datastructure */
55  );
56 
57 /** deinitializes the synchronization store */
60  SCIP_SYNCSTORE* syncstore /**< the synchronization store */
61  );
62 
63 /** checks whether the solve-is-stopped flag in the syncstore has been set by any thread */
66  SCIP_SYNCSTORE* syncstore /**< the synchronization store */
67  );
68 
69 /** sets the solve-is-stopped flag in the syncstore so that subsequent calls to
70  * SCIPsyncstoreSolveIsStopped will return the given value in any thread
71  */
74  SCIP_SYNCSTORE* syncstore, /**< the synchronization store */
75  SCIP_Bool stopped /**< flag if the solve is stopped */
76  );
77 
78 /** gets the upperbound from the last synchronization */
81  SCIP_SYNCSTORE* syncstore /**< the synchronization store */
82  );
83 
84 /** gets the lowerbound from the last synchronization */
87  SCIP_SYNCSTORE* syncstore /**< the synchronization store */
88  );
89 
90 /** gets the number of solutions from the last synchronization */
93  SCIP_SYNCSTORE* syncstore /**< the synchronization store */
94  );
95 
96 /** gets the number of boundchanges from the last synchronization */
99  SCIP_SYNCSTORE* syncstore /**< the synchronization store */
100  );
101 
102 /** gets total memory used by all solvers from the last synchronization */
105  SCIP_SYNCSTORE* syncstore /**< the synchronization store */
106  );
107 
108 /** gets the synchronization frequency from the last synchronization */
111  SCIP_SYNCSTORE* syncstore /**< the synchronization store */
112  );
113 
114 /** get synchronization data with given number. It is the responsibility of the caller
115  * to only ask for a synchronization number that still exists. */
118  SCIP_SYNCSTORE* syncstore, /**< the synchronization store */
119  SCIP_Longint syncnum /**< the number of the synchronization to start, which
120  * must be increasing between calls of the same thread */
121  );
122 
123 /** get the next synchronization data that should be read and
124  * adjust the delay. Returns NULL if no more data should be read due to minimum delay */
127  SCIP_SYNCSTORE* syncstore, /**< the synchronization store */
128  SCIP_SYNCDATA* syncdata, /**< the synchronization data */
129  SCIP_Real syncfreq, /**< the current synchronization frequency */
130  SCIP_Longint writenum, /**< number of synchronizations the solver has written to */
131  SCIP_Real* delay /**< pointer holding the current synchronization delay */
132  );
133 
134 /** ensures that the given synchronization data has been written by
135  * all solvers upon return of this function and blocks the caller if necessary. */
138  SCIP_SYNCSTORE* syncstore, /**< the synchronization store */
139  SCIP_SYNCDATA* syncdata /**< the synchronization data */
140  );
141 
142 /** Start synchronization for the given concurrent solver.
143  * Needs to be followed by a call to SCIPsyncstoreFinishSync if
144  * the syncdata that is returned is not NULL
145  */
148  SCIP_SYNCSTORE* syncstore, /**< the synchronization store */
149  SCIP_Longint syncnum, /**< the number of the synchronization to start, which
150  * must be increasing between calls of the same thread */
151  SCIP_SYNCDATA** syncdata /**< pointer to return the synchronization data */
152  );
153 
154 /** finishes synchronization for the synchronization data */
157  SCIP_SYNCSTORE* syncstore, /**< the synchronization store */
158  SCIP_SYNCDATA** syncdata /**< the synchronization data */
159  );
160 
161 /** gets status in synchronization data */
164  SCIP_SYNCDATA* syncdata /**< the synchronization data */
165  );
166 
167 /** gets the solver that had the best status, or -1 if solve is not stopped yet */
170  SCIP_SYNCSTORE* syncstore /**< the synchronization store */
171  );
172 
173 /** how many solvers have already finished synchronizing on this sychronization data */
176  SCIP_SYNCDATA* syncdata /**< the synchronization data */
177  );
178 
179 /** how many solvers have are running concurrently */
182  SCIP_SYNCSTORE* syncstore /**< the synchronization store */
183  );
184 
185 /** read amount of memory used from synchronization data */
188  SCIP_SYNCDATA* syncdata /**< the synchronization data */
189  );
190 
191 /** read the synchronization frequency from a synchronization data */
194  SCIP_SYNCDATA* syncdata /**< the synchronization data */
195  );
196 
197 /** read the upperbound stored in a synchronization data */
200  SCIP_SYNCDATA* syncdata /**< the synchronization data */
201  );
202 
203 /** read the lowerbound stored in a synchronization data */
206  SCIP_SYNCDATA* syncdata /**< the synchronization data */
207  );
208 
209 /** read the solutions stored in a synchronization data */
212  SCIP_SYNCDATA* syncdata, /**< the synchronization data */
213  SCIP_Real*** solvalues, /**< pointer to return array of buffers containing the solution values */
214  int** solowner, /**< pointer to return array of ownerids of solutions */
215  int* nsols /**< pointer to return number of solutions */
216  );
217 
218 /** read bound changes stored in the synchronization data */
221  SCIP_SYNCDATA* syncdata /**< the synchronization data */
222  );
223 
224 /** write the synchronization frequency to a synchronization data */
227  SCIP_SYNCSTORE* syncstore, /**< the synchronization store */
228  SCIP_SYNCDATA* syncdata, /**< the synchronization data */
229  SCIP_Real syncfreq /**< the synchronization frequency */
230  );
231 
232 /** set status in the synchronization data */
235  SCIP_SYNCDATA* syncdata, /**< the synchronization data the upperbound should be added to */
236  SCIP_STATUS status, /**< the status */
237  int solverid /**< identifier of te solver that has this status */
238  );
239 
240 /** adds memory used to the synchronization data */
243  SCIP_SYNCDATA* syncdata, /**< the synchronization data the solution should be added to */
244  SCIP_Longint memtotal /**< the number of bytes used */
245  );
246 
247 /** set upperbound to the synchronization data */
250  SCIP_SYNCDATA* syncdata, /**< the synchronization data the upperbound should be added to */
251  SCIP_Real upperbound /**< the upperbound */
252  );
253 
254 /** set lowerbound to the synchronization data */
257  SCIP_SYNCDATA* syncdata, /**< the synchronization data the lowerbound should be added to */
258  SCIP_Real lowerbound /**< the lowerbound */
259  );
260 
261 /** gives a buffer to store the solution values, or NULL if solution should not be stored
262  * because there are already better solutions stored.
263  */
266  SCIP_SYNCSTORE* syncstore, /**< the synchronization store */
267  SCIP_SYNCDATA* syncdata, /**< the synchronization data the solution should be added to */
268  SCIP_Real solobj, /**< the objective value of the solution */
269  int ownerid, /**< an identifier for the owner of the solution, e.g. the thread number */
270  SCIP_Real** buffer /**< pointer to return a buffer for the solution values, which must be set
271  * if the buffer is not NULL */
272  );
273 
274 /** adds bound changes to the synchronization data */
277  SCIP_SYNCSTORE* syncstore, /**< the synchronization store */
278  SCIP_SYNCDATA* syncdata, /**< the synchronization data */
279  SCIP_BOUNDSTORE* boundstore /**< bound store containing the bounds to add */
280  );
281 
282 /** is synchronization store initialized */
285  SCIP_SYNCSTORE* syncstore /**< the synchronization store */
286  );
287 
288 /** returns the mode of the synchronization store */
291  SCIP_SYNCSTORE* syncstore /**< the synchronization store */
292  );
293 
294 /**@} */
295 #endif
SCIP_EXPORT SCIP_Bool SCIPsyncstoreSolveIsStopped(SCIP_SYNCSTORE *syncstore)
Definition: syncstore.c:228
SCIP_EXPORT SCIP_SYNCDATA * SCIPsyncstoreGetSyncdata(SCIP_SYNCSTORE *syncstore, SCIP_Longint syncnum)
Definition: syncstore.c:327
SCIP_EXPORT SCIP_STATUS SCIPsyncdataGetStatus(SCIP_SYNCDATA *syncdata)
Definition: syncstore.c:506
SCIP_EXPORT SCIP_RETCODE SCIPsyncstoreRelease(SCIP_SYNCSTORE **syncstore)
Definition: syncstore.c:78
SCIP_EXPORT SCIP_RETCODE SCIPsyncstoreInit(SCIP *scip)
Definition: syncstore.c:127
#define SCIP_EXPORT
Definition: def.h:98
SCIP_EXPORT SCIP_BOUNDSTORE * SCIPsyncdataGetBoundChgs(SCIP_SYNCDATA *syncdata)
Definition: syncstore.c:609
SCIP_EXPORT SCIP_Real SCIPsyncstoreGetLastUpperbound(SCIP_SYNCSTORE *syncstore)
Definition: syncstore.c:259
SCIP_EXPORT int SCIPsyncstoreGetLastNBounds(SCIP_SYNCSTORE *syncstore)
Definition: syncstore.c:292
SCIP_EXPORT void SCIPsyncstoreSetSolveIsStopped(SCIP_SYNCSTORE *syncstore, SCIP_Bool stopped)
Definition: syncstore.c:246
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
SCIP_EXPORT void SCIPsyncdataSetSyncFreq(SCIP_SYNCSTORE *syncstore, SCIP_SYNCDATA *syncdata, SCIP_Real syncfreq)
Definition: syncstore.c:619
SCIP_EXPORT SCIP_Real SCIPsyncdataGetLowerbound(SCIP_SYNCDATA *syncdata)
Definition: syncstore.c:581
SCIP_EXPORT void SCIPsyncdataSetLowerbound(SCIP_SYNCDATA *syncdata, SCIP_Real lowerbound)
Definition: syncstore.c:686
SCIP_EXPORT void SCIPsyncdataAddMemTotal(SCIP_SYNCDATA *syncdata, SCIP_Longint memtotal)
Definition: syncstore.c:664
type definitions for return codes for SCIP methods
SCIP_EXPORT void SCIPsyncdataSetStatus(SCIP_SYNCDATA *syncdata, SCIP_STATUS status, int solverid)
Definition: syncstore.c:633
SCIP_EXPORT SCIP_RETCODE SCIPsyncstoreStartSync(SCIP_SYNCSTORE *syncstore, SCIP_Longint syncnum, SCIP_SYNCDATA **syncdata)
Definition: syncstore.c:425
SCIP_EXPORT SCIP_PARALLELMODE SCIPsyncstoreGetMode(SCIP_SYNCSTORE *syncstore)
Definition: syncstore.c:785
SCIP_EXPORT SCIP_Bool SCIPsyncstoreIsInitialized(SCIP_SYNCSTORE *syncstore)
Definition: syncstore.c:775
SCIP_EXPORT SCIP_RETCODE SCIPsyncstoreExit(SCIP_SYNCSTORE *syncstore)
Definition: syncstore.c:191
SCIP_EXPORT SCIP_RETCODE SCIPsyncstoreCapture(SCIP_SYNCSTORE *syncstore)
Definition: syncstore.c:113
SCIP_EXPORT void SCIPsyncdataGetSolutionBuffer(SCIP_SYNCSTORE *syncstore, SCIP_SYNCDATA *syncdata, SCIP_Real solobj, int ownerid, SCIP_Real **buffer)
Definition: syncstore.c:699
SCIP_EXPORT SCIP_Real SCIPsyncdataGetSyncFreq(SCIP_SYNCDATA *syncdata)
Definition: syncstore.c:561
SCIP_EXPORT int SCIPsyncstoreGetWinner(SCIP_SYNCSTORE *syncstore)
Definition: syncstore.c:516
SCIP_EXPORT SCIP_Real SCIPsyncstoreGetLastLowerbound(SCIP_SYNCSTORE *syncstore)
Definition: syncstore.c:270
SCIP_EXPORT SCIP_RETCODE SCIPsyncstoreFinishSync(SCIP_SYNCSTORE *syncstore, SCIP_SYNCDATA **syncdata)
Definition: syncstore.c:468
type definitions for SCIP&#39;s main datastructure
struct SCIP_SyncData SCIP_SYNCDATA
SCIP_EXPORT SCIP_Longint SCIPsyncstoreGetLastMemTotal(SCIP_SYNCSTORE *syncstore)
Definition: syncstore.c:303
SCIP_EXPORT void SCIPsyncdataSetUpperbound(SCIP_SYNCDATA *syncdata, SCIP_Real upperbound)
Definition: syncstore.c:675
#define SCIP_Bool
Definition: def.h:70
enum SCIP_Status SCIP_STATUS
Definition: type_stat.h:58
enum SCIP_Parallelmode SCIP_PARALLELMODE
SCIP_EXPORT SCIP_Longint SCIPsyncdataGetMemTotal(SCIP_SYNCDATA *syncdata)
Definition: syncstore.c:551
SCIP_EXPORT SCIP_RETCODE SCIPsyncdataAddBoundChanges(SCIP_SYNCSTORE *syncstore, SCIP_SYNCDATA *syncdata, SCIP_BOUNDSTORE *boundstore)
Definition: syncstore.c:758
SCIP_EXPORT SCIP_Real SCIPsyncdataGetUpperbound(SCIP_SYNCDATA *syncdata)
Definition: syncstore.c:571
SCIP_EXPORT SCIP_SYNCDATA * SCIPsyncstoreGetNextSyncdata(SCIP_SYNCSTORE *syncstore, SCIP_SYNCDATA *syncdata, SCIP_Real syncfreq, SCIP_Longint writenum, SCIP_Real *delay)
Definition: syncstore.c:348
the type definitions for the synchronization store
SCIP_EXPORT SCIP_Real SCIPsyncstoreGetLastSyncfreq(SCIP_SYNCSTORE *syncstore)
Definition: syncstore.c:314
SCIP_EXPORT int SCIPsyncstoreGetNSolvers(SCIP_SYNCSTORE *syncstore)
Definition: syncstore.c:540
SCIP_EXPORT SCIP_RETCODE SCIPsyncstoreEnsureAllSynced(SCIP_SYNCSTORE *syncstore, SCIP_SYNCDATA *syncdata)
Definition: syncstore.c:396
SCIP_EXPORT SCIP_RETCODE SCIPsyncstoreCreate(SCIP_SYNCSTORE **syncstore)
Definition: syncstore.c:57
#define SCIP_Real
Definition: def.h:164
#define SCIP_Longint
Definition: def.h:149
SCIP_EXPORT void SCIPsyncdataGetSolutions(SCIP_SYNCDATA *syncdata, SCIP_Real ***solvalues, int **solowner, int *nsols)
Definition: syncstore.c:591
common defines and data types used in all packages of SCIP
SCIP_EXPORT int SCIPsyncstoreGetLastNSols(SCIP_SYNCSTORE *syncstore)
Definition: syncstore.c:281
SCIP_EXPORT int SCIPsyncdataGetNSynced(SCIP_SYNCDATA *syncdata)
Definition: syncstore.c:530