Scippy

UG

Ubiquity Generator framework

scipParaCommTh.h
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the program and software framework */
4 /* UG --- Ubquity Generator Framework */
5 /* */
6 /* Copyright Written by Yuji Shinano <shinano@zib.de>, */
7 /* Copyright (C) 2021 by Zuse Institute Berlin, */
8 /* licensed under LGPL version 3 or later. */
9 /* Commercial licenses are available through <licenses@zib.de> */
10 /* */
11 /* This code is free software; you can redistribute it and/or */
12 /* modify it under the terms of the GNU Lesser General Public License */
13 /* as published by the Free Software Foundation; either version 3 */
14 /* of the License, or (at your option) any later version. */
15 /* */
16 /* This program is distributed in the hope that it will be useful, */
17 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
18 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
19 /* GNU Lesser General Public License for more details. */
20 /* */
21 /* You should have received a copy of the GNU Lesser General Public License */
22 /* along with this program. If not, see <http://www.gnu.org/licenses/>. */
23 /* */
24 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
25 
26 /**@file scipParaCommTh.h
27  * @brief SCIP ParaComm extension for threads communication.
28  * @author Yuji Shinano
29  *
30  *
31  *
32  */
33 
34 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
35 
36 
37 #ifndef __SCIP_PARA_COMM_TH_H__
38 #define __SCIP_PARA_COMM_TH_H__
39 #include "ug_bb/bbParaComm.h"
40 #include "scipParaTagDef.h"
41 #include "scipParaInstanceTh.h"
42 #include "scipParaSolutionTh.h"
44 #include "scipParaInitialStatTh.h"
46 #include "scip/scip.h"
47 
48 namespace ParaSCIP
49 {
50 
51 ///
52 /// scip defined transfer data types
53 ///
55 static const int ParaInitialStatType = SCIP_USER_TYPE_FIRST + 0;
56 
57 class ScipParaSolver;
58 class ScipDiffParamSet;
59 
60 #ifdef _COMM_PTH
61 class ScipParaCommTh : public UG::BbParaCommPth
62 #endif
63 #ifdef _COMM_CPP11
65 #endif
66 {
67 
68  std::mutex interruptMsgMonitorLockMutex; ///< mutex for interrupt message monitor
69 
70 protected:
71 
72  static const char *tagStringTable[]; ///< tag name string table
73 
74  ///
75  /// check if tag string table (for debugging) set up correctly
76  /// @return true if tag string table is set up correctly, false otherwise
77  ///
79  );
80 
81  ///
82  /// get Tag string for debugging
83  /// @return string which shows Tag
84  ///
85  const char *getTagString(
86  int tag /// tag to be converted to string
87  );
88 
89 public:
92 
93  ///
94  /// lock interrupt message monitor to synchronize with the monitor thread
95  ///
97  )
98  {
99  interruptMsgMonitorLockMutex.lock();
100  }
101 
102  ///
103  /// unlock interrupt message monitor to synchronize with the monitor thread
104  ///
106  )
107  {
108  interruptMsgMonitorLockMutex.unlock();
109  }
110 
111  /*******************************************************************************
112  * transfer object factory
113  *******************************************************************************/
120 
121  ScipParaInstance *createScipParaInstance(SCIP *scip, int method);
122  ScipParaSolution *createScipParaSolution(ScipParaSolver *solver, SCIP_Real objval, int inNvars, SCIP_VAR ** vars, SCIP_Real *vals);
123  ScipParaSolution *createScipParaSolution(SCIP_Real objval, int inNvars, int *inIndicesAmongSolvers, SCIP_Real *vals);
124 
126  SCIP *scip,
127  ScipParaSolver *scipParaSolver,
128  int nNewBranchVars,
129  SCIP_VAR **newBranchVars,
130  SCIP_Real *newBranchBounds,
131  SCIP_BOUNDTYPE *newBoundTypes,
132  int nAddedConss,
133  SCIP_CONS **addedConss
134  );
137  int inMaxDepth,
138  int inMaxTotalDepth,
139  int inNVarBranchStatsDown,
140  int inNVarBranchStatsUp,
141  int *inIdxLBranchStatsVarsDown,
142  int *inNVarBranchingDown,
143  int *inIdxLBranchStatsVarsUp,
144  int *inNVarBranchingUp,
145  SCIP_Real *inDownpscost,
146  SCIP_Real *inDownvsids,
147  SCIP_Real *inDownconflen,
148  SCIP_Real *inDowninfer,
149  SCIP_Real *inDowncutoff,
150  SCIP_Real *inUppscost,
151  SCIP_Real *inUpvsids,
152  SCIP_Real *inUpconflen,
153  SCIP_Real *inUpinfer,
154  SCIP_Real *inUpcutoff
155  );
157  int inTerminationCriteria,
158  int inNNodesLeft,
159  double inTimeLimit,
160  int inScipRacingParamSeed,
161  int inPermuteProbSeed,
162  int inGenerateBranchOrderSeed,
163  ScipDiffParamSet *inScipDiffParamSet
164  );
167 };
168 
169 #define DEF_SCIP_PARA_COMM( scip_para_comm, comm ) ScipParaCommTh *scip_para_comm = dynamic_cast< ScipParaCommTh* >(comm)
170 
171 }
172 #endif // __SCIP_PARA_COMM_TH_H__
static const char * tagStringTable[]
mutex for interrupt message monitor
UG::ParaParamSet * createParaParamSet()
Communicator object for C++11 thread communications.
Communicator object for pthreads thread communications.
Definition: bbParaCommPth.h:78
ScipParaDiffSubproblem * createScipParaDiffSubproblem(SCIP *scip, ScipParaSolver *scipParaSolver, int nNewBranchVars, SCIP_VAR **newBranchVars, SCIP_Real *newBranchBounds, SCIP_BOUNDTYPE *newBoundTypes, int nAddedConss, SCIP_CONS **addedConss)
ScipParaSolution extension for threads communication.
void unlockInterruptMsg()
unlock interrupt message monitor to synchronize with the monitor thread
ScipParaSolution * createScipParaSolution(ScipParaSolver *solver, SCIP_Real objval, int inNvars, SCIP_VAR **vars, SCIP_Real *vals)
const char * getTagString(int tag)
get Tag string for debugging
UG::ParaInstance * createParaInstance()
ScipParaDiffSubproblem extension for threads communication.
UG::ParaDiffSubproblem * createParaDiffSubproblem()
UG::ParaSolution * createParaSolution()
static const int BB_USER_TYPE_LAST
ScipParaInitialStat * createScipParaInitialStat(SCIP *scip)
UG::ParaRacingRampUpParamSet * createParaRacingRampUpParamSet()
ScipParaInitialStat extension for threads communication.
void lockInterruptMsg()
lock interrupt message monitor to synchronize with the monitor thread
class ParaParamSet
Definition: paraParamSet.h:850
class for instance data
Definition: paraInstance.h:50
UG::ParaInitialStat * createParaInitialStat()
Class for the difference between instance and subproblem.
ScipParaRacingRampUpParamSet extension for threads communication.
ScipParaInstance extension for threads communication.
class for initial statistics collecting after racing
bool tagStringTableIsSetUpCoorectly()
check if tag string table (for debugging) set up correctly
ScipParaRacingRampUpParamSet * createScipParaRacingRampUpParamSet(int inTerminationCriteria, int inNNodesLeft, double inTimeLimit, int inScipRacingParamSeed, int inPermuteProbSeed, int inGenerateBranchOrderSeed, ScipDiffParamSet *inScipDiffParamSet)
ScipParaInstance * createScipParaInstance(SCIP *scip, int method)
static const int SCIP_USER_TYPE_FIRST
scip defined transfer data types
ScipDiffParamSet * createScipDiffParamSet()
static const int ParaInitialStatType
class ParaRacingRampUpParamSet (parameter set for racing ramp-up)
class for solution
Definition: paraSolution.h:53