Scippy

UG

Ubiquity Generator framework

bbParaRacingRampUpParamSet.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 paraRacingRampUpParamSet.h
27  * @brief Base class for racing ramp-up parameter set.
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 __BB_PARA_RACING_RAMP_UP_PARAM_SET_H__
38 #define __BB_PARA_RACING_RAMP_UP_PARAM_SET_H__
39 
41 #include "bbParaComm.h"
42 #ifdef UG_WITH_ZLIB
43 #include "ug/gzstream.h"
44 #endif
45 
46 namespace UG
47 {
48 
49 static const int RacingTerminateWithNNodesLeft = 0;
50 static const int RacingTerminateWithTimeLimit = 1;
51 
52 ///
53 /// class BbParaRacingRampUpParamSet
54 /// (parameter set for racing ramp-up)
55 ///
56 ///
58 {
59 
60 protected:
61 
62  int nNodesLeft; ///< stop racing number of nodes left
63  double timeLimit; ///< stop racing time limit
64 
65 public:
66 
67  ///
68  /// default constructor
69  ///
71  )
73  nNodesLeft(-1),
74  timeLimit(-1.0)
75  {
76  }
77 
78  ///
79  /// constructor
80  ///
82  int inTerminationCriteria, ///< termination criteria of racing ramp-up
83  int inNNodesLeft, ///< stop racing number of nodes left
84  double inTimeLimit ///< stop racing time limit
85  )
86  : ParaRacingRampUpParamSet(inTerminationCriteria),
87  nNodesLeft(inNNodesLeft),
88  timeLimit(inTimeLimit)
89  {
90  }
91 
92  ///
93  /// destructor
94  ///
96  )
97  {
98  }
99 
100  ///
101  /// get termination criteria
102  /// @return an int value to show termination criteria
103  ///
105  )
106  {
107  return terminationCriteria;
108  }
109 
110  ///
111  /// get stop racing number of nodes left
112  /// @return the number of nodes left
113  ///
115  )
116  {
117  return nNodesLeft;
118  }
119 
120  ///
121  /// get stop racing time limimt
122  /// @return time to stop racing
123  ///
125  )
126  {
127  return timeLimit;
128  }
129 
130 
131  ///
132  /// set winner rank
133  /// TODO: this function and also getWinnerRank should be removed
134  ///
135  virtual void setWinnerRank(
136  int rank
137  )
138  {
139  }
140 
141 
142  ///
143  /// send BbParaRacingRampUpParamSet
144  /// @return always 0 (for future extensions)
145  ///
146  virtual int send(
147  ParaComm *comm, ///< communicator used
148  int destination ///< destination rank
149  ) = 0;
150 
151  ///
152  /// receive BbParaRacingRampUpParamSet
153  /// @return always 0 (for future extensions)
154  ///
155  virtual int receive(
156  ParaComm *comm, ///< communicator used
157  int source ///< source rank
158  ) = 0;
159 
160 #ifdef UG_WITH_ZLIB
161 
162  ///
163  /// write to checkpoint file
164  ///
165  virtual void write(
166  gzstream::ogzstream &out ///< gzstream for output
167  ) = 0;
168 
169  ///
170  /// read from checkpoint file
171  ///
172  virtual bool read(
173  ParaComm *comm, ///< communicator used
174  gzstream::igzstream &in ///< gzstream for input
175  ) = 0;
176 
177 #endif
178 
179  ///
180  /// stringfy BbParaRacingRampUpParamSet
181  /// @return string to show inside of this object
182  ///
183  virtual const std::string toString(
184  ) = 0;
185 
186  ///
187  /// get strategy
188  /// @return an int value which shows strategy
189  ///
190  virtual int getStrategy() = 0;
191 
192 };
193 
195 
196 }
197 
198 #endif // __BB_PARA_RACING_RAMP_UP_PARAM_SET_H__
199 
virtual int getStrategy()=0
get strategy
class BbParaRacingRampUpParamSet (parameter set for racing ramp-up)
double getStopRacingTimeLimit()
get stop racing time limimt
static ScipParaCommTh * comm
Definition: fscip.cpp:73
int getTerminationCriteria()
get termination criteria
int terminationCriteria
termination criteria of racing ramp-up : 0: number of nodes left, 1: time limit meaning must be defin...
virtual const std::string toString()=0
stringfy BbParaRacingRampUpParamSet
static const int RacingTerminateWithNNodesLeft
virtual ~BbParaRacingRampUpParamSet()
destructor
virtual int send(ParaComm *comm, int destination)=0
send BbParaRacingRampUpParamSet
Base class for racing ramp-up parameter set.
void read(ParaComm *comm, const char *filename)
read ParaParams from file
int nNodesLeft
stop racing number of nodes left
static const int RacingTerminateWithTimeLimit
double timeLimit
stop racing time limit
static const int RacingTerminationNotDefined
int getStopRacingNNodesLeft()
get stop racing number of nodes left
BbParaRacingRampUpParamSet()
default constructor
virtual void setWinnerRank(int rank)
set winner rank TODO: this function and also getWinnerRank should be removed
class ParaRacingRampUpParamSet (parameter set for racing ramp-up)
BbParaRacingRampUpParamSet * BbParaRacingRampUpParamSetPtr
BbParaRacingRampUpParamSet(int inTerminationCriteria, int inNNodesLeft, double inTimeLimit)
constructor
Base class of communicator object.
Definition: paraComm.h:101
virtual int receive(ParaComm *comm, int source)=0
receive BbParaRacingRampUpParamSet