Scippy

UG

Ubiquity Generator framework

bbParaNodeMpi.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 paraNodeMpi.h
27  * @brief BbParaNode extension for MIP 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_NODE_MPI_H__
38 #define __BB_PARA_NODE_MPI_H__
39 
40 #include <mpi.h>
41 #include <iostream>
42 #include <fstream>
43 #include "bbParaCommMpi.h"
44 #include "bbParaNode.h"
45 
46 namespace UG
47 {
48 
49 ///
50 /// class BbParaNodeMpi
51 ///
52 class BbParaNodeMpi : public BbParaNode
53 {
54  ///
55  /// create BbParaNode datatype
56  ///
57  MPI_Datatype createDatatype(
58  );
59 
60  ///
61  /// create BbParaNode datatype
62  ///
63  MPI_Datatype createDatatypeForNodeId(
64  );
65 
66 public :
67 
68  ///
69  /// default constructor
70  ///
72  )
73  {
74  }
75 
76  ///
77  /// constructor
78  ///
80  TaskId inNodeId, ///< node id
81  TaskId inGeneratorNodeId, ///< generator node id
82  int inDepth, ///< depth in global search tree
83  double inDualBoundValue, ///< dual bound value
84  double inOriginalDualBoundValue, ///< original dual bound value when the node is generated
85  double inEstimatedValue, ///< estimated value
86  ParaDiffSubproblem *inDiffSubproblem ///< pointer to ParaDiffSubproblem object
87  )
88  : BbParaNode(inNodeId, inGeneratorNodeId, inDepth, inDualBoundValue, inOriginalDualBoundValue, inEstimatedValue, inDiffSubproblem)
89  {
90  }
91 
92  ///
93  /// destructor
94  ///
96  )
97  {
98  }
99 
100  ///
101  /// clone this BbParaNodeMpi
102  /// @return pointer to cloned BbParaNodeMpi object
103  ///
105  ParaComm *comm ///< communicator used
106  )
107  {
108  if( diffSubproblem )
109  {
110  return ( new
113  }
114  else
115  {
116  return ( new
118  initialDualBoundValue, 0 ) );
119  }
120  }
121 
122  ///
123  /// broadcast this object
124  /// @return always 0 (for future extensions)
125  ///
126  int bcast(
127  ParaComm *comm, ///< communicator used
128  int root ///< root rank of broadcast
129  );
130 
131  ///
132  /// send this object
133  /// @return always 0 (for future extensions)
134  ///
135  int send(
136  ParaComm *comm, ///< communicator used
137  int destination ///< destination rank
138  );
139 
140  ///
141  /// receive this object
142  /// @return always 0 (for future extensions)
143  ///
144  int receive(
145  ParaComm *comm, ///< communicator used
146  int source ///< source rank
147  );
148 
149  ///
150  /// send new subtree root node
151  /// @return always 0 (for future extensions)
152  ///
153  int sendNewSubtreeRoot(
154  ParaComm *comm, ///< communicator used
155  int destination ///< destination rank
156  );
157 
158  ///
159  /// send subtree root to be removed
160  /// @return always 0 (for future extensions)
161  ///
163  ParaComm *comm, ///< communicator used
164  int destination, ///< destination rank
165  int tag ///< tag of message
166  );
167 
168  ///
169  /// send subtree root to be reassigned
170  /// @return always 0 (for future extensions)
171  ///
173  ParaComm *comm, ///< communicator used
174  int destination ///< destination rank
175  );
176 
177  ///
178  /// receive this object
179  /// @return always 0 (for future extensions)
180  ///
182  ParaComm *comm, ///< communicator used
183  int source ///< source rank
184  );
185 
186  ///
187  /// receive this object
188  /// @return always 0 (for future extensions)
189  ///
191  ParaComm *comm, ///< communicator used
192  int source, ///< source rank
193  int tag ///< tag of message
194  );
195 
196  ///
197  /// receive this object node Id
198  /// @return always 0 (for future extensions)
199  ///
201  ParaComm *comm, ///< communicator used
202  int source ///< source rank
203  );
204 
205 };
206 
207 }
208 
209 #endif // __BB_PARA_NODE_MPI_H__
double dualBoundValue
dual bound value
Definition: bbParaNode.h:67
int bcast(ParaComm *comm, int root)
broadcast this object
static ScipParaCommTh * comm
Definition: fscip.cpp:73
int send(ParaComm *comm, int destination)
send this object
int sendReassignSelfSplitSubtreeRoot(ParaComm *comm, int destination)
send subtree root to be reassigned
BbParaNodeMpi()
default constructor
Definition: bbParaNodeMpi.h:71
int receiveSubtreeRootNodeId(ParaComm *comm, int source, int tag)
receive this object
double initialDualBoundValue
dual bound value when this node is created This value is updated to precise one when there is guarant...
Definition: bbParaNode.h:68
TaskId class.
Definition: paraTask.h:222
int sendNewSubtreeRoot(ParaComm *comm, int destination)
send new subtree root node
TaskId generatorTaskId
subtree root task id of generator
Definition: paraTask.h:550
int receiveReassignSelfSplitSubtreeRoot(ParaComm *comm, int source)
receive this object node Id
ParaDiffSubproblem * diffSubproblem
difference between solving instance data and subproblem data
Definition: paraTask.h:558
class BbParaNodeMpi
Definition: bbParaNodeMpi.h:52
virtual ParaDiffSubproblem * clone(ParaComm *comm)=0
create clone of this object
BbParaNodeMpi(TaskId inNodeId, TaskId inGeneratorNodeId, int inDepth, double inDualBoundValue, double inOriginalDualBoundValue, double inEstimatedValue, ParaDiffSubproblem *inDiffSubproblem)
constructor
Definition: bbParaNodeMpi.h:79
~BbParaNodeMpi()
destructor
Definition: bbParaNodeMpi.h:95
BbParaNodeMpi * clone(ParaComm *comm)
clone this BbParaNodeMpi
int receiveNewSubtreeRoot(ParaComm *comm, int source)
receive this object
MPI_Datatype createDatatypeForNodeId()
create BbParaNode datatype
Class for the difference between instance and subproblem.
class BbParaNode
Definition: bbParaNode.h:61
int sendSubtreeRootNodeId(ParaComm *comm, int destination, int tag)
send subtree root to be removed
MPI_Datatype createDatatype()
create BbParaNode datatype
int receive(ParaComm *comm, int source)
receive this object
int depth
depth from the root node of original tree
Definition: bbParaNode.h:66
TaskId taskId
solving task information
Definition: paraTask.h:549
Base class of communicator object.
Definition: paraComm.h:101