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-2024 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
45extern "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_Real limit_gap; /**< relative gap limit in main SCIP */
61 SCIP_Real limit_absgap; /**< absolute gap limit in main SCIP */
62 SCIP_Bool stopped; /**< flag to indicate if the solving is stopped */
63 SCIP_LOCK* lock; /**< lock to protect the syncstore data structure from data races */
64
65 /* SPI settings */
66 int nsyncdata; /**< the size of the synchronization data array */
67 SCIP_Real minsyncdelay; /**< the minimum delay before a synchronization data may be read */
68 int maxnsyncdelay; /**< maximum number of synchronizations before the reading of the next
69 * synchronization data is enforced regardless of the minimal synchroization
70 * delay */
71 SCIP_Real syncfreqinit; /**< the initial synchronization frequency which is read from the settings
72 * of the main SCIP when the syncstore is initialized */
73 SCIP_Real syncfreqmax; /**< the maximum synchronization frequency */
74 int maxnsols; /**< maximum number of solutions that can be shared in one synchronization */
75 int nsolvers; /**< number of solvers synchronizing with this syncstore */
76};
77
78
79struct SCIP_SyncData
80{
81 SCIP_Real* solobj; /**< array with the objective value of all stored solutions */
82 SCIP_Real** sols; /**< array with the solution values of each variable for all stored solutions */
83 int* solsource; /**< the solverid of the solution came from */
84 int nsols; /**< number of solutions currently stored in the synchronization data */
85 SCIP_Real bestlowerbound; /**< largest lower bound on the objective value that was stored in this
86 * synchroization data */
87 SCIP_Real bestupperbound; /**< smalles upper bound on the objective value that was stored in this
88 * synchroization data */
89 SCIP_Longint syncnum; /**< the synchronization number of this synchronization data */
90 int winner; /**< the solverid of the solver with the best status */
91 SCIP_STATUS status; /**< the best status that was stored in this synchronization data */
92 SCIP_LOCK* lock; /**< a lock to protect this synchronization data */
93 int syncedcount; /**< a counter of how many solvers have finished writing to this synchronization data */
94 SCIP_CONDITION* allsynced; /**< a condition variable to signal when the last solver has finished writing to this
95 * synchronization data */
96 SCIP_BOUNDSTORE* boundstore; /**< a boundstore for storing all the bound changes that were added to this
97 * synchronization data */
98 SCIP_Real syncfreq; /**< the synchroization frequency that was set in this synchronization data */
99 SCIP_Longint memtotal; /**< the total amount of memory used by all solvers including the main SCIP */
100};
101
102/** struct for storing the position of avariables lower and upper bound in the boundstore */
103typedef struct
104{
105 int pos[2]; /**< stores at pos[SCIP_BOUNDTYPE_LOWER] the position of the lowerbound and
106 * at pos[SCIP_BOUNDTYPE_UPPER] the position of the upperbound */
107} BoundPos;
108
109/** struct for storing a single boundchange in the boundstore */
110typedef struct
111{
112 int varidx; /**< the variables position in the variable array of the main scip */
113 SCIP_Real newbound; /**< the variables new bound */
114 SCIP_BOUNDTYPE boundtype; /**< the type of the variables new bound */
115} BoundChg;
116
118{
119 int nvars; /**< the number of variables to store bounds for */
120 BoundPos* bndpos; /**< array of size nvars to store the positions for all the bound changes
121 * stored in this boundstore */
122 BoundChg* bndchg; /**< array of boundchanges */
123 int nbndchg; /**< the number of boundchanges stored in this bound store */
124 int bndchgsize; /**< the size of the bound change array */
125};
126
127#ifdef __cplusplus
128}
129#endif
130
131#endif
common defines and data types used in all packages of SCIP
#define SCIP_Longint
Definition: def.h:157
#define SCIP_Bool
Definition: def.h:91
#define SCIP_Real
Definition: def.h:172
SCIP_Real newbound
SCIP_BOUNDTYPE boundtype
SCIP_Real limit_gap
SCIP_Bool initialized
SCIP_SYNCDATA * syncdata
SCIP_Real limit_absgap
SCIP_Real syncfreqmax
SCIP_Real syncfreqinit
SCIP_PARALLELMODE mode
SCIP_LOCK * lock
SCIP_SYNCDATA * lastsync
SCIP_Real minsyncdelay
type definitions for LP management
enum SCIP_BoundType SCIP_BOUNDTYPE
Definition: type_lp.h:59
type definitions for SCIP's main datastructure
type definitions for problem statistics
enum SCIP_Status SCIP_STATUS
Definition: type_stat.h:67
the type definitions for the synchronization store
enum SCIP_Parallelmode SCIP_PARALLELMODE
struct SCIP_SyncData SCIP_SYNCDATA
the type definitions for the task processing interface