Scippy

UG

Ubiquity Generator framework

bbParaNodesMerger.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 bbParaNodesMerger.h
27 * @brief Structs used for merging nodes.
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_NODES_MERGER_H__
38#define __BB_PARA_NODES_MERGER_H__
39
40#include<cassert>
41#include<ug/paraTimer.h>
42#include<ug/paraInitiator.h>
43#include<ug/paraParamSet.h>
44#include "bbParaInstance.h"
45
46namespace UG
47{
48
49class BbParaNode;
50class BbParaDiffSubproblem;
51class BbParaNodePool;
52
59
60///
61/// Fixed value struct
62///
64 double value; ///< value for a fixed variable
65 BbParaFixedVariable *head; ///< point the head of the ParaFixedVariable
66 BbParaFixedVariable *tail; ///< point the tail of the ParaFixedVarialbe
67 BbParaFixedValue *next; ///< point next ParaFixedValue struct
68};
69
70///
71/// Merge node information struct
72///
74 enum {
75 PARA_MERGING, ///< in merging process
76 PARA_MERGED_RPRESENTATIVE, ///< representative node for merging
77 PARA_MERGE_CHECKING_TO_OTHER_NODE, ///< checking possibility to merge with the other nodes
78 PARA_MERGED_TO_OTHER_NODE, ///< merged to the other node
79 PARA_CANNOT_MERGE, ///< cannot merge to the other node
80 PARA_DELETED ///< this node is deleted
81 } status; ///< status of this ParaMargeNodeInfo
82 int nSameValueVariables; ///< the number of fixed values which are the same as those of the merged node
83 ///< - This value < 0 means that this node is not merging target
84 int nMergedNodes; ///< the number of merged nodes with this node.
85 ///< - This value > 0 : head
86 ///< - This value = 0 : merging to the other node
87 ///< - This value < 0 : no merging node
88 int keyIndex; ///< The fixedVar of this index can reach all merging nodes
89 int nFixedVariables; ///< the number of fixed variables
90 BbParaFixedVariable *fixedVariables; ///< array of fixed variable info
91 BbParaMergeNodeInfo *mergedTo; ///< pointer to merge node info to which this node is merged */
92 BbParaNode *paraNode; ///< BbParaNode corresponding to this ParaMergeModeInfo */
93 BbParaDiffSubproblem *origDiffSubproblem; ///< original DiffSubproblem */
94 BbParaDiffSubproblem *mergedDiffSubproblem; ///< merged DiffSubproblem, in case this node is merged and this is the head */
95 BbParaMergeNodeInfo *next; ///< pointer to the next ParaMergeNodeInfo */
96};
97
98///
99/// Fixed variable struct
100///
102 int nSameValue; ///< the number of same value fixed variables in the following nodes
103 int index; ///< index of the variable among all solvers
104 double value; ///< fixed value
105 BbParaMergeNodeInfo *mnode; ///< pointer to merge node info struct to which this info is belonging
106 BbParaFixedVariable *next; ///< pointer to the next node which has the same fixed value
107 BbParaFixedVariable *prev; ///< pointer to the previous node which has the same fixed value
108};
109
110///
111/// Sorted variable struct
112///
114 int idxInFixedVariabes; ///< index in the fixedVariables array
115 BbParaFixedVariable *fixedVariable; ///< pointer to the fixedVariable
116};
117
118///
119/// merged node list element stract
121 BbParaNode *node; ///< pointer to BbParaNode object
122 BbParaMergedNodeListElement *next; ///< pointer to the next ParaMergedNodeListElement
123};
124
126{
127 int varIndexRange; ///< variable index range
128 int nBoundChangesOfBestNode; ///< bound changes of the best node
129 ParaTimer *paraTimer; ///< normal timer used
130 BbParaInstance *instance; ///< pointer to ParaInstance object
131 ParaParamSet *paraParamSet; ///< pointer to ParaParamSet object
132 BbParaFixedValue **varIndexTable; ///< variable indices table.
133 BbParaMergeNodeInfo *mergeInfoHead; ///< head of BbParaMergeNodeInfo list
134 BbParaMergeNodeInfo *mergeInfoTail; ///< tail of BbParaMergeNodeInfo list
135 /// times
136 double addingNodeToMergeStructTime; ///< accumulate time to add Node to merge struct
137 double generateMergeNodesCandidatesTime; ///< accumulate time to generate merge nodes candidates
138 double regenerateMergeNodesCandidatesTime; ///< accumulate time to regenerate merge nodes candidates
139 double mergeNodeTime; ///< accumulate time to make a merged node
140
141public:
142
144 int inVarIndexRange,
145 int inNBoundChangesOfBestNode,
146 ParaTimer *inParaTimer,
147 BbParaInstance *inParaInstance,
148 ParaParamSet *inParaParamSet
149 )
150 :
151 varIndexRange(inVarIndexRange),
152 nBoundChangesOfBestNode(inNBoundChangesOfBestNode),
153 paraTimer(inParaTimer),
154 instance(inParaInstance),
155 paraParamSet(inParaParamSet),
156 varIndexTable(0),
157 mergeInfoHead(0),
158 mergeInfoTail(0),
162 mergeNodeTime(0.0)
163 {
164 assert( varIndexRange > 0 );
166 for( int i = 0; i < varIndexRange; i++ )
167 {
168 varIndexTable[i] = 0;
169 }
170 mergeInfoHead = 0;
171 mergeInfoTail = 0;
172 }
173
175 )
176 {
177 }
178
179 ///
180 /// add a node to nodes merger
181 ///
183 BbParaNode *node ///< pointer to BbParaNode object to be merged
184 );
185
186 ///
187 /// generate merge nodes candidates
188 ///
190 ParaComm *paraComm, ///< pointer to paraComm object
191 ParaInitiator *paraInitiator ///< pointer to ParaInitiatior object, this can be 0, if it is not
192 );
193
194 ///
195 /// regenerate merge nodes candidates
196 ///
198 BbParaNode *node, ///< pointer to BbParaNode object to be removed from this merger
199 ParaComm *paraComm, ///< pointer to paraComm object
200 ParaInitiator *paraInitiator ///< pointer to ParaInitiatior object, this can be 0, if it is not
201 );
202
203 ///
204 /// delete merge node info
205 ///
207 BbParaMergeNodeInfo *mNode ///< pointer to BbParaMergeNodeInfo object to be removed
208 );
209
210 ///
211 /// make a merge node
212 /// @return the number of nodes merged
213 ///
214 int mergeNodes(
215 BbParaNode *node, ///< pointer to BbParaNode object which is the representative
216 BbParaNodePool *paraNodePool ///< pointer to BbParaNodePool object
217 );
218
219 ///
220 /// getter of addingNodeToMergeStructTime
221 /// @return addingNodeToMergeStructTime
222 ///
224 )
225 {
227 }
228
229 ///
230 /// getter of generateMergeNodesCandidatesTime
231 /// @return generateMergeNodesCandidatesTime
232 ///
234 )
235 {
237 }
238
239 ///
240 /// getter of regenerateMergeNodesCandidatesTime
241 /// @return regenerateMergeNodesCandidatesTime
242 ///
244 )
245 {
247 }
248
249 ///
250 /// getter of mergeNodeTime
251 /// @return mergeNodeTime
252 ///
254 )
255 {
256 return mergeNodeTime;
257 }
258
259};
260
261}
262
263#endif // __BB_PARA_NODES_MERGER_H__
Base class for instance data.
Class for the difference between instance and subproblem.
class for instance data
class BbParaNodePool
class BbParaNode
Definition: bbParaNode.h:62
double mergeNodeTime
accumulate time to make a merged node
double getMergeNodeTime()
getter of mergeNodeTime
double generateMergeNodesCandidatesTime
accumulate time to generate merge nodes candidates
double getGenerateMergeNodesCandidatesTime()
getter of generateMergeNodesCandidatesTime
BbParaMergeNodeInfo * mergeInfoHead
head of BbParaMergeNodeInfo list
int nBoundChangesOfBestNode
bound changes of the best node
double getAddingNodeToMergeStructTime()
getter of addingNodeToMergeStructTime
void deleteMergeNodeInfo(BbParaMergeNodeInfo *mNode)
delete merge node info
int mergeNodes(BbParaNode *node, BbParaNodePool *paraNodePool)
make a merge node
int varIndexRange
variable index range
ParaParamSet * paraParamSet
pointer to ParaParamSet object
BbParaMergeNodeInfo * mergeInfoTail
tail of BbParaMergeNodeInfo list times
BbParaFixedValue ** varIndexTable
variable indices table.
double regenerateMergeNodesCandidatesTime
accumulate time to regenerate merge nodes candidates
void generateMergeNodesCandidates(ParaComm *paraComm, ParaInitiator *paraInitiator)
generate merge nodes candidates
BbParaInstance * instance
pointer to ParaInstance object
double getRegenerateMergeNodesCandidatesTime()
getter of regenerateMergeNodesCandidatesTime
ParaTimer * paraTimer
normal timer used
BbParaNodesMerger(int inVarIndexRange, int inNBoundChangesOfBestNode, ParaTimer *inParaTimer, BbParaInstance *inParaInstance, ParaParamSet *inParaParamSet)
double addingNodeToMergeStructTime
accumulate time to add Node to merge struct
void regenerateMergeNodesCandidates(BbParaNode *node, ParaComm *paraComm, ParaInitiator *paraInitiator)
regenerate merge nodes candidates
void addNodeToMergeNodeStructs(BbParaNode *node)
add a node to nodes merger
Base class of communicator object.
Definition: paraComm.h:102
Class for initiator.
Definition: paraInitiator.h:63
class ParaParamSet
Definition: paraParamSet.h:850
class ParaTimer
Definition: paraTimer.h:49
static ScipParaInitiator * paraInitiator
Definition: fscip.cpp:76
struct BbParaFixedValue_ * BbParaFixedValuePtr
Base class of initiator that maintains original problem and incumbent solution.
Parameter set for UG framework.
Base class for Timer.
Fixed value struct.
BbParaFixedValue * next
point next ParaFixedValue struct
BbParaFixedVariable * head
point the head of the ParaFixedVariable
BbParaFixedVariable * tail
point the tail of the ParaFixedVarialbe
double value
value for a fixed variable
Fixed variable struct.
BbParaMergeNodeInfo * mnode
pointer to merge node info struct to which this info is belonging
BbParaFixedVariable * prev
pointer to the previous node which has the same fixed value
BbParaFixedVariable * next
pointer to the next node which has the same fixed value
int index
index of the variable among all solvers
int nSameValue
the number of same value fixed variables in the following nodes
Merge node information struct.
@ PARA_MERGE_CHECKING_TO_OTHER_NODE
checking possibility to merge with the other nodes
@ PARA_CANNOT_MERGE
cannot merge to the other node
@ PARA_DELETED
this node is deleted
@ PARA_MERGED_RPRESENTATIVE
representative node for merging
@ PARA_MERGING
in merging process
@ PARA_MERGED_TO_OTHER_NODE
merged to the other node
BbParaDiffSubproblem * mergedDiffSubproblem
merged DiffSubproblem, in case this node is merged and this is the head *‍/
BbParaMergeNodeInfo * mergedTo
pointer to merge node info to which this node is merged *‍/
int nMergedNodes
the number of merged nodes with this node.
BbParaDiffSubproblem * origDiffSubproblem
original DiffSubproblem *‍/
int keyIndex
The fixedVar of this index can reach all merging nodes.
BbParaNode * paraNode
BbParaNode corresponding to this ParaMergeModeInfo *‍/.
BbParaMergeNodeInfo * next
pointer to the next ParaMergeNodeInfo *‍/
BbParaFixedVariable * fixedVariables
array of fixed variable info
int nSameValueVariables
the number of fixed values which are the same as those of the merged node
enum UG::BbParaMergeNodeInfo_::@0 status
status of this ParaMargeNodeInfo
int nFixedVariables
the number of fixed variables
merged node list element stract
BbParaMergedNodeListElement * next
pointer to the next ParaMergedNodeListElement
BbParaNode * node
pointer to BbParaNode object
Sorted variable struct.
int idxInFixedVariabes
index in the fixedVariables array
BbParaFixedVariable * fixedVariable
pointer to the fixedVariable