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