Scippy

UG

Ubiquity Generator framework

bbParaSolverTerminationState.cpp
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 bbParaSolverTerminationState.cpp
27 * @brief This class contains solver termination state which is transferred form Solver to LC.
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#include "ug/paraDef.h"
38#include "ug/paraComm.h"
40
41using namespace UG;
42
43/** stringfy BbParaSolverTerminationState */
44std::string
45BbParaSolverTerminationState::toString(
46 ParaInitiator *initiator
47 )
48{
49 std::ostringstream os;
50 switch( interrupted )
51 {
52 case 0:
53 {
54 os << "######### Solver Rank = " << rank << " is terminated. #########" << std::endl;
55 break;
56 }
57 case 1:
58 {
59 os << "######### Solver Rank = " << rank << " is interrupted. #########" << std::endl;
60 break;
61 }
62 case 2:
63 {
64 os << "######### Solver Rank = " << rank << " is at checkpoint. #########" << std::endl;
65 break;
66 }
67 case 3:
68 {
69 os << "######### Solver Rank = " << rank << " is at the end of racing process. #########" << std::endl;
70 break;
71 }
72 default:
73 {
74 THROW_LOGICAL_ERROR1("invalid interrupted flag in BbParaSolverTerminationState!");
75 }
76 }
77
78 os << "#=== Elapsed time to terminate this Solver = " << runningTime << std::endl;
81 os << "#=== ( Idle time to start first ParaNode = " << idleTimeToFirstParaTask
82 << ", Idle time between ParaNods = " << idleTimeBetweenParaTasks
83 << ", Idle Time after last ParaNode = " << idleTimeAfterLastParaTask
84 << " )" << std::endl;
85 os << "#=== ( Idle time to wait notification Id messages = " << idleTimeToWaitNotificationId << " )" << std::endl;
86 os << "#=== ( Idle time to wait acknowledgment of completion = " << idleTimeToWaitAckCompletion << " )" << std::endl;
87 os << "#=== ( Idle time to wait token = " << idleTimeToWaitToken << " )" << std::endl;
88 if( nParaTasksSolved > 0 )
89 {
90 os << "#=== Total root node process time = " << totalRootNodeTime << " ( Mean = " << (totalRootNodeTime/nParaTasksSolved)
91 << ", Min = " << minRootNodeTime << ", Max = " << maxRootNodeTime << " )" << std::endl;
92 }
93 else
94 {
95 os << "#=== Total root node process time = 0.0 ( Mean = 0.0, Min = 0.0, Max = 0.0 )" << std::endl;
96 }
97 os << "#=== The number of ParaNodes received in this solver = " << nParaTasksReceived << std::endl;
98 os << "#=== The number of ParaNodes sent from this solver = " << totalNSent << std::endl;
99 if( nParaTasksSolved > 0 )
100 {
101 os << "#=== The number of nodes solved in this solver = " << totalNSolved
102 << " ( / Subtree : Mean = " << totalNSolved/nParaTasksSolved << ", Min = " << minNSolved << ", Max = " << maxNSolved << " )"<< std::endl;
103 os << "#=== Total number of restarts in this solver = " << nTotalRestarts
104 << "( / Subtree : Mean = " << nTotalRestarts/nParaTasksSolved
105 << ", Min = " << minRestarts << ", Max = " << maxRestarts << " )"<< std::endl;
106 os << "#=== Total number of cuts sent from this solver = " << nTransferredLocalCutsFromSolver
107 << "( / Subtree : Mean = " << nTransferredLocalCutsFromSolver/nParaTasksSolved;
109 {
110 os << ", Min = " << minTransferredLocalCutsFromSolver << ", Max = " << maxTransferredLocalCutsFromSolver << " )"<< std::endl;
111 }
112 else
113 {
114 os << ", Min = 0, Max = 0 )" << std::endl;
115 }
116 os << "#=== Total number of benders cuts sent from this solver = " << nTransferredBendersCutsFromSolver
117 << "( / Subtree : Mean = " << nTransferredBendersCutsFromSolver/nParaTasksSolved;
119 {
120 os << ", Min = " << minTransferredBendersCutsFromSolver << ", Max = " << maxTransferredBendersCutsFromSolver << " )"<< std::endl;
121 }
122 else
123 {
124 os << ", Min = 0, Max = 0 )" << std::endl;
125 }
126 }
127 else
128 {
129 os << "#=== The number of nodes solved in this solver = 0 ( / Subtree : Mean = 0, Min = 0, Max = 0 )" << std::endl;
130 }
131 os << "#=== The number of ParaNodes solved in this solver = " << nParaTasksSolved << std::endl;
132 os << "#=== ( Solved at root node = " << nParaNodesSolvedAtRoot << ", Solved at pre-checking of root node solvability = "
133 << nParaNodesSolvedAtPreCheck << " )" << std::endl;
134 os << "#=== The number of improved solutions found in this solver = " << totalNImprovedIncumbent << std::endl;
135 os << "#=== The number of tightened variable bounds in this solver = " << nTightened << " ( Int: " << nTightenedInt << " )" << std::endl;
136 return os.str();
137}
138
139#ifdef UG_WITH_ZLIB
140void
142 gzstream::ogzstream &out
143 )
144{
145 out.write((char *)&interrupted, sizeof(int));
146 out.write((char *)&rank, sizeof(int));
147 out.write((char *)&totalNSolved, sizeof(int));
148 out.write((char *)&minNSolved, sizeof(int));
149 out.write((char *)&maxNSolved, sizeof(int));
150 out.write((char *)&totalNSent, sizeof(int));
151 out.write((char *)&totalNImprovedIncumbent, sizeof(int));
152 out.write((char *)&nParaTasksReceived, sizeof(int));
153 out.write((char *)&nParaTasksSolved, sizeof(int));
154 out.write((char *)&nParaNodesSolvedAtRoot, sizeof(int));
155 out.write((char *)&nParaNodesSolvedAtPreCheck, sizeof(int));
156 out.write((char *)&runningTime, sizeof(double));
157 out.write((char *)&idleTimeToFirstParaTask, sizeof(double));
158 out.write((char *)&idleTimeBetweenParaTasks, sizeof(double));
159 out.write((char *)&idleTimeAfterLastParaTask, sizeof(double));
160 out.write((char *)&idleTimeToWaitNotificationId, sizeof(double));
161 out.write((char *)&idleTimeToWaitToken, sizeof(double));
162 out.write((char *)&totalRootNodeTime, sizeof(double));
163 out.write((char *)&minRootNodeTime, sizeof(double));
164 out.write((char *)&maxRootNodeTime, sizeof(double));
165 // detTime and dualBound are not saved
166}
167
168bool
170 ParaComm *comm,
171 gzstream::igzstream &in
172 )
173{
174 in.read((char *)&interrupted, sizeof(int));
175 if( in.eof() ) return false;
176 in.read((char *)&rank, sizeof(int));
177 in.read((char *)&totalNSolved, sizeof(int));
178 in.read((char *)&minNSolved, sizeof(int));
179 in.read((char *)&maxNSolved, sizeof(int));
180 in.read((char *)&totalNSent, sizeof(int));
181 in.read((char *)&totalNImprovedIncumbent, sizeof(int));
182 in.read((char *)&nParaTasksReceived, sizeof(int));
183 in.read((char *)&nParaTasksSolved, sizeof(int));
184 in.read((char *)&nParaNodesSolvedAtRoot, sizeof(int));
185 in.read((char *)&nParaNodesSolvedAtPreCheck, sizeof(int));
186 in.read((char *)&runningTime, sizeof(double));
187 in.read((char *)&idleTimeToFirstParaTask, sizeof(double));
188 in.read((char *)&idleTimeBetweenParaTasks, sizeof(double));
189 in.read((char *)&idleTimeAfterLastParaTask, sizeof(double));
190 in.read((char *)&idleTimeToWaitNotificationId, sizeof(double));
191 in.read((char *)&idleTimeToWaitToken, sizeof(double));
192 in.read((char *)&totalRootNodeTime, sizeof(double));
193 in.read((char *)&minRootNodeTime, sizeof(double));
194 in.read((char *)&maxRootNodeTime, sizeof(double));
195 // detTime and dualBound are not saved
196 return true;
197}
198
199#endif
This class contains solver termination state which is transferred form Solver to LC.
bool read(ParaComm *comm, gzstream::igzstream &in)
read BbParaSolverTerminationState from checkpoint file
int minNSolved
minimum number of subtree nodes rooted from ParaNode
int maxNSolved
maximum number of subtree nodes rooted from ParaNode
int nTransferredLocalCutsFromSolver
number of local cuts transferred from this Solver
int nTightened
number of tightened variable bounds during racing stage
int maxRestarts
maximum number of restarts
int totalNSolved
accumulated number of nodes solved in this ParaSolver
int nParaNodesSolvedAtRoot
number of ParaNodes solved at root node before sending
double maxRootNodeTime
maximum time consumed by root node processes
int totalNSent
accumulated number of nodes sent from this ParaSolver
int minRestarts
minimum number of restarts
void write(gzstream::ogzstream &out)
write BbParaSolverTerminationState to checkpoint file
int nTightenedInt
number of tightened integral variable bounds during racing stage
int nTransferredBendersCutsFromSolver
number of benders cuts transferred from this Solver
double minRootNodeTime
minimum time consumed by root node processes
int minTransferredLocalCutsFromSolver
minimum number of local cuts transferred from this Solver
int minTransferredBendersCutsFromSolver
minimum number of benders cuts transferred from this Solver
int nParaNodesSolvedAtPreCheck
number of ParaNodes solved at pre-checking of root node solvability
int maxTransferredBendersCutsFromSolver
maximum number of benders cuts transferred from this Solver
int maxTransferredLocalCutsFromSolver
maximum number of local cuts transferred from this Solver
double totalRootNodeTime
total time consumed by root node processes
int totalNImprovedIncumbent
accumulated number of improvements of incumbent value in this ParaSolver
int nTotalRestarts
number of total restarts
Base class of communicator object.
Definition: paraComm.h:102
Class for initiator.
Definition: paraInitiator.h:63
double idleTimeToWaitNotificationId
idle time to wait notification Id messages
double runningTime
this solver running time
int nParaTasksReceived
number of ParaTasks received in this ParaSolver
double idleTimeBetweenParaTasks
idle time between ParaTasks processing
int interrupted
indicate that this solver is interrupted or not. 0: not interrupted, 1: interrupted,...
double idleTimeToWaitAckCompletion
idle time to wait ack completion message
double idleTimeAfterLastParaTask
idle time after the last ParaTask was solved
double idleTimeToFirstParaTask
idle time to start solving the first ParaTask
static ScipParaCommTh * comm
Definition: fscip.cpp:73
Base class of communicator for UG Framework.
Defines for UG Framework.
#define THROW_LOGICAL_ERROR1(msg1)
Definition: paraDef.h:52