Scippy

UG

Ubiquity Generator framework

bbParaCommPth.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-2024 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 bbParaCommPth.h
27 * @brief ParaComm extension for Pthreads 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 __BB_PARA_COMM_PTH_H__
38#define __BB_PARA_COMM_PTH_H__
39
40#include <stdexcept>
41#include <iostream>
42#include <ostream>
43#include <fstream>
44#include <sstream>
45#include <string>
46#include <iomanip>
47#include <cassert>
48#include "bbParaNodeTh.h"
50#include "bbParaSolverStateTh.h"
52#include "ug/paraCommPth.h"
53
54namespace UG
55{
56
57///
58/// bb user defined transfer data types
59///
63
65class BbParaParamSet;
68class BbParaInstance;
70class BbParaSolution;
71class BbParaInitialStat;
73class BbParaNode;
74
75///
76/// Communicator object for pthreads thread communications
77///
79{
80
81protected:
82
83 static const char *tagStringTable[]; ///< tag name string table
84
85 ///
86 /// check if tag string table (for debugging) set up correctly
87 /// @return true if tag string table is set up correctly, false otherwise
88 ///
90 );
91
92 ///
93 /// get Tag string for debugging
94 /// @return string which shows Tag
95 ///
96 virtual const char *getTagString(
97 int tag /// tag to be converted to string
98 );
99
100public:
101
102 ///
103 /// constructor of BbParaCommPth
104 ///
106 )
107 : ParaCommPth()
108 {
109 }
110
111 ///
112 /// destructor of this communicator
113 ///
115 )
116 {
117 }
118
119 ///
120 /// create ParaCalculationState object by default constructor
121 /// @return pointer to ParaCalculationState object
122 ///
124 );
125
126 ///
127 /// create ParaCalculationState object
128 /// @return pointer to ParaCalculationState object
129 ///
131 double compTime, ///< computation time of this ParaNode */
132 double rootTime, ///< computation time of the root node */
133 int nSolved, ///< the number of nodes solved */
134 int nSent, ///< the number of ParaNodes sent */
135 int nImprovedIncumbent, ///< the number of improved solution generated in this ParaSolver */
136 int terminationState, ///< indicate whether if this computation is terminationState or not. 0: no, 1: terminationState */
137 int nSolvedWithNoPreprocesses, ///< number of nodes solved when it is solved with no preprocesses */
138 int nSimplexIterRoot, ///< number of simplex iteration at root node */
139 double averageSimplexIter, ///< average number of simplex iteration except root node */
140 int nTransferredLocalCuts, ///< number of local cuts transferred from a ParaNode */
141 int minTransferredLocalCuts, ///< minimum number of local cuts transferred from a ParaNode */
142 int maxTransferredLocalCuts, ///< maximum number of local cuts transferred from a ParaNode */
143 int nTransferredBendersCuts, ///< number of benders cuts transferred from a ParaNode */
144 int minTransferredBendersCuts, ///< minimum number of benders cuts transferred from a ParaNode */
145 int maxTransferredBendersCuts, ///< maximum number of benders cuts transferred from a ParaNode */
146 int nRestarts, ///< number of restarts */
147 double minIisum, ///< minimum sum of integer infeasibility */
148 double maxIisum, ///< maximum sum of integer infeasibility */
149 int minNii, ///< minimum number of integer infeasibility */
150 int maxNii, ///< maximum number of integer infeasibility */
151 double dualBound, ///< final dual bound value
152 int nSelfSplitNodesLeft ///< number of self-split nodes left
153 );
154
155 ///
156 /// create ParaNode object by default constructor
157 /// @return pointer to ParaNode object
158 ///
159 virtual ParaTask *createParaTask(
160 );
161
162 ///
163 /// create ParaNode object
164 /// @return pointer to ParaNode object
165 ///
166 virtual ParaTask *createParaNode(
167 TaskId inNodeId, ///< node id
168 TaskId inGeneratorNodeId, ///< generator node id
169 int inDepth, ///< node depth in global search tree
170 double inDualBoundValue, ///< dual bound value
171 double inOriginalDualBoundValue, ///< original dual bound value
172 double inEstimatedValue, ///< estimated value
173 ParaDiffSubproblem *inDiffSubproblem ///< diff subproblem info. from the original problem
174 );
175
176 ///
177 /// create ParaSolverState object by default constructor
178 /// @return pointer to ParaSolverState object
179 ///
181 );
182
183 ///
184 /// create ParaSolverState object
185 /// @return pointer to ParaSolverState object
186 ///
188 int racingStage, ///< if this value is 1, solver is in racing stage
189 unsigned int notificationId, ///< id for this notification
190 int lcId, ///< lc id of current ParaNode
191 int globalSubtreeId, ///< global subtree id of current ParaNode
192 long long nodesSolved, ///< number of nodes solved
193 int nodesLeft, ///< number of remaining nodes
194 double bestDualBoundValue, ///< best dual bound value in that of remaining nodes
195 double globalBestPrimalBoundValue, ///< global best primal bound value
196 double detTime, ///< deterministic time, -1: should be non-deterministic
197 double averageDualBoundGain ///< average dual bound gain received
198 );
199
200 ///
201 /// create ParaSolverTerminationState object by default constructor
202 /// @return pointer to ParaSolverTerminationState object
203 ///
205 );
206
207 ///
208 /// create ParaSolverTerminationState object
209 /// @return pointer to ParaSolverTerminationState object
210 ///
212 int interrupted, ///< indicate that this solver is interrupted or not. 0: not interrupted, 1: interrupted
213 ///< 2: checkpoint, 3: racing-ramp up
214 int rank, ///< rank of this solver
215 int totalNSolved, ///< accumulated number of nodes solved in this ParaSolver
216 int minNSolved, ///< minimum number of subtree nodes rooted from ParaNode
217 int maxNSolved, ///< maximum number of subtree nodes rooted from ParaNode
218 int totalNSent, ///< accumulated number of nodes sent from this ParaSolver
219 int totalNImprovedIncumbent, ///< accumulated number of improvements of incumbent value in this ParaSolver
220 int nParaNodesReceived, ///< number of ParaNodes received in this ParaSolver
221 int nParaNodesSolved, ///< number of ParaNodes solved ( received ) in this ParaSolver
222 int nParaNodesSolvedAtRoot, ///< number of ParaNodes solved at root node before sending
223 int nParaNodesSolvedAtPreCheck, ///< number of ParaNodes solved at pre-checking of root node solvability
224 int nTransferredLocalCutsFromSolver, ///< number of local cuts transferred from this Solver
225 int minTransferredLocalCutsFromSolver, ///< minimum number of local cuts transferred from this Solver
226 int maxTransferredLocalCutsFromSolver, ///< maximum number of local cuts transferred from this Solver
227 int nTransferredBendersCutsFromSolver, ///< number of benders cuts transferred from this Solver
228 int minTransferredBendersCutsFromSolver, ///< minimum number of benders cuts transferred from this Solver
229 int maxTransferredBendersCutsFromSolver, ///< maximum number of benders cuts transferred from this Solver
230 int nTotalRestarts, ///< number of total restarts
231 int minRestarts, ///< minimum number of restarts
232 int maxRestarts, ///< maximum number of restarts
233 int nTightened, ///< number of tightened variable bounds during racing stage
234 int nTightenedInt, ///< number of tightened integral variable bounds during racing stage
235 int calcTerminationState, ///< termination sate of a calculation in a Solver
236 double runningTime, ///< this solver running time
237 double idleTimeToFirstParaNode, ///< idle time to start solving the first ParaNode
238 double idleTimeBetweenParaNodes, ///< idle time between ParaNodes processing
239 double iddleTimeAfterLastParaNode, ///< idle time after the last ParaNode was solved
240 double idleTimeToWaitNotificationId, ///< idle time to wait notification Id messages
241 double idleTimeToWaitAckCompletion, ///< idle time to wait ack completion message
242 double idleTimeToWaitToken, ///< idle time to wait token
243 double totalRootNodeTime, ///< total time consumed by root node processes
244 double minRootNodeTime, ///< minimum time consumed by root node processes
245 double maxRootNodeTime, ///< maximum time consumed by root node processes
246 double detTime ///< deterministic time, -1: should be non-deterministic
247 );
248
249 ///
250 /// create ParaRacingRampUpParamSet object by default constructor
251 /// @return pointer to ParaRacingRampUpParamSet object
252 ///
254 )
255 {
256 THROW_LOGICAL_ERROR1("*** createParaRacingRampUpParamSet() is called in BbParaComm class ***");
257 }
258
259};
260
261#define DEF_BB_PARA_COMM( para_comm, comm ) UG::BbParaCommPth *para_comm = dynamic_cast< UG::BbParaCommPth* >(comm)
262
263}
264
265#endif // __BB_PARA_COMM_PTH_H__
CalcutationStte object extension for threads communication.
BbParaNode extension for threads communication.
BbParaSolverState extension for threads communication.
BbParaSolverTerminationState extension for threads communication.
Base class of Calculation state in a ParaSolver.
Communicator object for pthreads thread communications.
Definition: bbParaCommPth.h:79
virtual ParaCalculationState * createParaCalculationState()
create ParaCalculationState object by default constructor
virtual ParaSolverState * createParaSolverState()
create ParaSolverState object by default constructor
virtual ~BbParaCommPth()
destructor of this communicator
virtual ParaTask * createParaTask()
create ParaNode object by default constructor
virtual bool tagStringTableIsSetUpCoorectly()
check if tag string table (for debugging) set up correctly
virtual ParaSolverTerminationState * createParaSolverTerminationState()
create ParaSolverTerminationState object by default constructor
virtual ParaRacingRampUpParamSet * createParaRacingRampUpParamSet()
create ParaRacingRampUpParamSet object by default constructor
virtual ParaTask * createParaNode(TaskId inNodeId, TaskId inGeneratorNodeId, int inDepth, double inDualBoundValue, double inOriginalDualBoundValue, double inEstimatedValue, ParaDiffSubproblem *inDiffSubproblem)
create ParaNode object
virtual const char * getTagString(int tag)
get Tag string for debugging
static const char * tagStringTable[]
tag name string table
Definition: bbParaCommPth.h:83
BbParaCommPth()
constructor of BbParaCommPth
Class for the difference between instance and subproblem.
class for instance data
class BbParaNode
Definition: bbParaNode.h:62
class BbParaParamSet
class BbParaRacingRampUpParamSet (parameter set for racing ramp-up)
class for solution
class BbParaSolverState (ParaSolver state object for notification message)
class BbParaSolverTerminationState (Solver termination state in a ParaSolver)
Base class of Calculation state in a ParaSolver.
Communicator object for pthreads thread communications.
Definition: paraCommPth.h:706
Class for the difference between instance and subproblem.
class ParaRacingRampUpParamSet (parameter set for racing ramp-up)
class ParaSolverState (ParaSolver state object for notification message)
class ParaSolverTerminationState (Solver termination state in a ParaSolver)
class ParaTask
Definition: paraTask.h:542
TaskId class.
Definition: paraTask.h:223
static bool interrupted
Definition: fscip.cpp:78
static const int UG_USER_TYPE_LAST
static const int BB_USER_TYPE_LAST
static const int ParaSolverDiffParamType
static const int BB_USER_TYPE_FIRST
bb user defined transfer data types
ParaComm extension for Pthreads communication.
#define THROW_LOGICAL_ERROR1(msg1)
Definition: paraDef.h:52