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-2025 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 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 */
    43SCIP_EXPORT
    45 SCIP_SYNCSTORE** syncstore /**< pointer to return the created synchronization store */
    46 );
    47
    48/** releases a synchronization store */
    49SCIP_EXPORT
    51 SCIP_SYNCSTORE** syncstore /**< pointer to the synchronization store */
    52 );
    53
    54/** captures a synchronization store */
    55SCIP_EXPORT
    57 SCIP_SYNCSTORE* syncstore /**< the synchronization store */
    58 );
    59
    60/** initialize the syncstore for the given SCIP instance */
    61SCIP_EXPORT
    63 SCIP* scip /**< SCIP main datastructure */
    64 );
    65
    66/** deinitializes the synchronization store */
    67SCIP_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 */
    73SCIP_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 */
    81SCIP_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 */
    88SCIP_EXPORT
    90 SCIP_SYNCSTORE* syncstore /**< the synchronization store */
    91 );
    92
    93/** gets the lowerbound from the last synchronization */
    94SCIP_EXPORT
    96 SCIP_SYNCSTORE* syncstore /**< the synchronization store */
    97 );
    98
    99/** gets the number of solutions from the last synchronization */
    100SCIP_EXPORT
    102 SCIP_SYNCSTORE* syncstore /**< the synchronization store */
    103 );
    104
    105/** gets the number of boundchanges from the last synchronization */
    106SCIP_EXPORT
    108 SCIP_SYNCSTORE* syncstore /**< the synchronization store */
    109 );
    110
    111/** gets total memory used by all solvers from the last synchronization */
    112SCIP_EXPORT
    114 SCIP_SYNCSTORE* syncstore /**< the synchronization store */
    115 );
    116
    117/** gets the synchronization frequency from the last synchronization */
    118SCIP_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. */
    125SCIP_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 */
    134SCIP_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. */
    145SCIP_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 */
    155SCIP_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 */
    164SCIP_EXPORT
    166 SCIP_SYNCSTORE* syncstore, /**< the synchronization store */
    167 SCIP_SYNCDATA** syncdata /**< the synchronization data */
    168 );
    169
    170/** gets status in synchronization data */
    171SCIP_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 */
    177SCIP_EXPORT
    179 SCIP_SYNCSTORE* syncstore /**< the synchronization store */
    180 );
    181
    182/** how many solvers have already finished synchronizing on this sychronization data */
    183SCIP_EXPORT
    185 SCIP_SYNCDATA* syncdata /**< the synchronization data */
    186 );
    187
    188/** how many solvers have are running concurrently */
    189SCIP_EXPORT
    191 SCIP_SYNCSTORE* syncstore /**< the synchronization store */
    192 );
    193
    194/** read amount of memory used from synchronization data */
    195SCIP_EXPORT
    197 SCIP_SYNCDATA* syncdata /**< the synchronization data */
    198 );
    199
    200/** read the synchronization frequency from a synchronization data */
    201SCIP_EXPORT
    203 SCIP_SYNCDATA* syncdata /**< the synchronization data */
    204 );
    205
    206/** read the upperbound stored in a synchronization data */
    207SCIP_EXPORT
    209 SCIP_SYNCDATA* syncdata /**< the synchronization data */
    210 );
    211
    212/** read the lowerbound stored in a synchronization data */
    213SCIP_EXPORT
    215 SCIP_SYNCDATA* syncdata /**< the synchronization data */
    216 );
    217
    218/** read the solutions stored in a synchronization data */
    219SCIP_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 */
    228SCIP_EXPORT
    230 SCIP_SYNCDATA* syncdata /**< the synchronization data */
    231 );
    232
    233/** write the synchronization frequency to a synchronization data */
    234SCIP_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 */
    242SCIP_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 the solver that has this status */
    247 );
    248
    249/** adds memory used to the synchronization data */
    250SCIP_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 */
    257SCIP_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 */
    264SCIP_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 */
    273SCIP_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 */
    284SCIP_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 */
    292SCIP_EXPORT
    294 SCIP_SYNCSTORE* syncstore /**< the synchronization store */
    295 );
    296
    297/** returns the mode of the synchronization store */
    298SCIP_EXPORT
    300 SCIP_SYNCSTORE* syncstore /**< the synchronization store */
    301 );
    302
    303#endif
    common defines and data types used in all packages of SCIP
    #define SCIP_Longint
    Definition: def.h:141
    #define SCIP_Bool
    Definition: def.h:91
    #define SCIP_Real
    Definition: def.h:156
    SCIP_Bool SCIPsyncstoreSolveIsStopped(SCIP_SYNCSTORE *syncstore)
    Definition: syncstore.c:241
    SCIP_Real SCIPsyncdataGetSyncFreq(SCIP_SYNCDATA *syncdata)
    Definition: syncstore.c:576
    SCIP_Longint SCIPsyncdataGetMemTotal(SCIP_SYNCDATA *syncdata)
    Definition: syncstore.c:566
    SCIP_BOUNDSTORE * SCIPsyncdataGetBoundChgs(SCIP_SYNCDATA *syncdata)
    Definition: syncstore.c:624
    SCIP_Real SCIPsyncstoreGetLastUpperbound(SCIP_SYNCSTORE *syncstore)
    Definition: syncstore.c:272
    SCIP_RETCODE SCIPsyncstoreFinishSync(SCIP_SYNCSTORE *syncstore, SCIP_SYNCDATA **syncdata)
    Definition: syncstore.c:481
    SCIP_Real SCIPsyncstoreGetLastLowerbound(SCIP_SYNCSTORE *syncstore)
    Definition: syncstore.c:283
    SCIP_Real SCIPsyncdataGetUpperbound(SCIP_SYNCDATA *syncdata)
    Definition: syncstore.c:586
    void SCIPsyncdataSetUpperbound(SCIP_SYNCDATA *syncdata, SCIP_Real upperbound)
    Definition: syncstore.c:695
    SCIP_RETCODE SCIPsyncdataAddBoundChanges(SCIP_SYNCSTORE *syncstore, SCIP_SYNCDATA *syncdata, SCIP_BOUNDSTORE *boundstore)
    Definition: syncstore.c:778
    int SCIPsyncstoreGetWinner(SCIP_SYNCSTORE *syncstore)
    Definition: syncstore.c:531
    SCIP_RETCODE SCIPsyncstoreEnsureAllSynced(SCIP_SYNCSTORE *syncstore, SCIP_SYNCDATA *syncdata)
    Definition: syncstore.c:409
    void SCIPsyncdataSetSyncFreq(SCIP_SYNCSTORE *syncstore, SCIP_SYNCDATA *syncdata, SCIP_Real syncfreq)
    Definition: syncstore.c:634
    SCIP_Real SCIPsyncstoreGetLastSyncfreq(SCIP_SYNCSTORE *syncstore)
    Definition: syncstore.c:327
    void SCIPsyncdataGetSolutions(SCIP_SYNCDATA *syncdata, SCIP_Real ***solvalues, int **solowner, int *nsols)
    Definition: syncstore.c:606
    void SCIPsyncdataSetStatus(SCIP_SYNCDATA *syncdata, SCIP_STATUS status, int solverid)
    Definition: syncstore.c:648
    void SCIPsyncstoreSetSolveIsStopped(SCIP_SYNCSTORE *syncstore, SCIP_Bool stopped)
    Definition: syncstore.c:259
    SCIP_RETCODE SCIPsyncstoreRelease(SCIP_SYNCSTORE **syncstore)
    Definition: syncstore.c:89
    SCIP_Longint SCIPsyncstoreGetLastMemTotal(SCIP_SYNCSTORE *syncstore)
    Definition: syncstore.c:316
    SCIP_RETCODE SCIPsyncstoreExit(SCIP_SYNCSTORE *syncstore)
    Definition: syncstore.c:204
    void SCIPsyncdataSetLowerbound(SCIP_SYNCDATA *syncdata, SCIP_Real lowerbound)
    Definition: syncstore.c:706
    SCIP_RETCODE SCIPsyncstoreCapture(SCIP_SYNCSTORE *syncstore)
    Definition: syncstore.c:124
    int SCIPsyncstoreGetLastNBounds(SCIP_SYNCSTORE *syncstore)
    Definition: syncstore.c:305
    int SCIPsyncstoreGetLastNSols(SCIP_SYNCSTORE *syncstore)
    Definition: syncstore.c:294
    SCIP_RETCODE SCIPsyncstoreStartSync(SCIP_SYNCSTORE *syncstore, SCIP_Longint syncnum, SCIP_SYNCDATA **syncdata)
    Definition: syncstore.c:438
    void SCIPsyncdataGetSolutionBuffer(SCIP_SYNCSTORE *syncstore, SCIP_SYNCDATA *syncdata, SCIP_Real solobj, int ownerid, SCIP_Real **buffer)
    Definition: syncstore.c:719
    SCIP_Real SCIPsyncdataGetLowerbound(SCIP_SYNCDATA *syncdata)
    Definition: syncstore.c:596
    SCIP_PARALLELMODE SCIPsyncstoreGetMode(SCIP_SYNCSTORE *syncstore)
    Definition: syncstore.c:805
    SCIP_RETCODE SCIPsyncstoreCreate(SCIP_SYNCSTORE **syncstore)
    Definition: syncstore.c:67
    int SCIPsyncdataGetNSynced(SCIP_SYNCDATA *syncdata)
    Definition: syncstore.c:545
    SCIP_SYNCDATA * SCIPsyncstoreGetSyncdata(SCIP_SYNCSTORE *syncstore, SCIP_Longint syncnum)
    Definition: syncstore.c:340
    SCIP_Bool SCIPsyncstoreIsInitialized(SCIP_SYNCSTORE *syncstore)
    Definition: syncstore.c:795
    SCIP_SYNCDATA * SCIPsyncstoreGetNextSyncdata(SCIP_SYNCSTORE *syncstore, SCIP_SYNCDATA *syncdata, SCIP_Real syncfreq, SCIP_Longint writenum, SCIP_Real *delay)
    Definition: syncstore.c:361
    void SCIPsyncdataAddMemTotal(SCIP_SYNCDATA *syncdata, SCIP_Longint memtotal)
    Definition: syncstore.c:684
    int SCIPsyncstoreGetNSolvers(SCIP_SYNCSTORE *syncstore)
    Definition: syncstore.c:555
    SCIP_STATUS SCIPsyncdataGetStatus(SCIP_SYNCDATA *syncdata)
    Definition: syncstore.c:521
    SCIP_RETCODE SCIPsyncstoreInit(SCIP *scip)
    Definition: syncstore.c:138
    type definitions for return codes for SCIP methods
    enum SCIP_Retcode SCIP_RETCODE
    Definition: type_retcode.h:63
    type definitions for SCIP's main datastructure
    enum SCIP_Status SCIP_STATUS
    Definition: type_stat.h:64
    the type definitions for the synchronization store
    enum SCIP_Parallelmode SCIP_PARALLELMODE
    struct SCIP_SyncData SCIP_SYNCDATA