Minotaur 0.4.1
Docs for developers
Node.h
Go to the documentation of this file.
1//
2// Minotaur -- It's only 1/2 bull
3//
4// (C)opyright 2008 - 2025 The Minotaur Team.
5//
6
14#ifndef MINOTAURNODE_H
15#define MINOTAURNODE_H
16
17#include "Types.h"
18
19namespace Minotaur {
20
21 class Node;
22 class Relaxation;
23 class WarmStart;
24 typedef const Node *ConstNodePtr;
25 typedef Relaxation *RelaxationPtr;
26 typedef WarmStart *WarmStartPtr;
27
54 class Node {
55
56 public:
58 Node();
59
64 Node(NodePtr parentNode, BranchPtr branch);
65
67 virtual ~Node();
68
70 void addChild(NodePtr childNode);
71
73 void addCutToPool(CutPtr cut, RelaxationPtr rel);
74
81 void addPMod(ModificationPtr m) { pMods_.push_back(m); }
82
89 void addRMod(ModificationPtr m) { rMods_.push_back(m); }
90
97
102 void applyPMods(ProblemPtr p);
103
108 void applyRMods(RelaxationPtr rel);
109
116
121
123 NodePtrIterator childrenBegin() { return children_.begin(); }
124
126 NodePtrIterator childrenEnd() { return children_.end(); }
127
132 BranchPtr getBranch() const { return branch_; }
133
135 CutList getCutPool() { return cutPool_; }
136
138 UInt getDepth() const { return depth_; }
139
141 UInt getId() const { return id_; }
142
144 UIntVector getLastStrongBranched() { return lastStrBranched_; }
145
147 double getLb() const { return lb_; }
148
150 size_t getNumChildren() { return children_.size(); }
151
153 NodePtr getParent() const { return parent_; }
154
159 //DoubleVector getPCDown() const { return pseudoDown_; }
160 DoubleVector getPCDown() { return pseudoDown_; }
161
166 UIntVector getBrCands() const { return brCands_; }
167
172 DoubleVector getPCUp() const { return pseudoUp_; }
173
175 NodeStatus getStatus() const { return status_; }
176
178 double getTbScore() const { return tbScore_; }
179
180 double setVioVal(double v) { return vioVal_ = v; }
181
182 double getVioVal() { return vioVal_; }
183
188 UIntVector getTimesDown() const { return timesDown_; }
189
194 UIntVector getTimesUp() const { return timesUp_; }
195
197 WarmStartPtr getWarmStart() { return ws_; }
198
200 void makeChildOf(const Node *parent);
201
207 ModificationConstIterator modsBegin() const { return pMods_.begin(); }
208 ModificationConstIterator modsrBegin() const { return rMods_.begin(); }
209
211 ModificationConstIterator modsEnd() const { return pMods_.end(); }
212 ModificationConstIterator modsrEnd() const { return rMods_.end(); }
213
215 ModificationRConstIterator modsRBegin() const { return pMods_.rbegin(); }
216
218 ModificationRConstIterator modsREnd() const { return pMods_.rend(); }
219
224 void removeChild(NodePtrIterator childNodeIter);
225
227 void removeChildren();
228
230 void removeParent();
231
233 void removeWarmStart();
234
236 void setBrCands(UIntVector brCands) { brCands_ = brCands; }
237
239 void setDepth(UInt depth);
240
245 void setId(UInt id);
246
248 void setLastStrongBranched(UIntVector lstStrnBrnchd)
249 {
250 lastStrBranched_ = lstStrnBrnchd;
251 }
252
254 void setLb(double value);
255
257 void setPCDown(DoubleVector pcDown) { pseudoDown_ = pcDown; }
258
260 void setPCUp(DoubleVector pcUp) { pseudoUp_ = pcUp; }
261
263 void setStatus(NodeStatus status) { status_ = status; }
264
266 void setTbScore(double d) { tbScore_ = d; }
267
269 void setTimesDown(UIntVector timesDown) { timesDown_ = timesDown; }
270
272 void setTimesUp(UIntVector timesUp) { timesUp_ = timesUp; }
273
275 void setWarmStart(WarmStartPtr ws);
276
281 void undoPMods(ProblemPtr p);
282
287 void undoRMods(RelaxationPtr r);
288
295
300 void undoMods(RelaxationPtr rel, ProblemPtr p);
301
305 void updateBrCands(UInt index);
306
310 void updateLastStrBranched(UInt index, double value);
311
315 void updatePCDown(UInt index, double value);
316
320 void updatePCUp(UInt index, double value);
321
325 void updateTimesDown(UInt index, double value);
326
330 void updateTimesUp(UInt index, double value);
331
333 void write(std::ostream &o) const;
334
335 private:
340 BranchPtr branch_;
341
343 NodePtrVector children_;
344
346 UInt depth_;
347
349 UInt id_;
350
352 UIntVector lastStrBranched_;
353
358 double lb_;
359
364 std::vector<ModificationPtr> pMods_;
365
370 std::vector<ModificationPtr> rMods_;
371
373 NodePtr parent_;
374
379 UIntVector brCands_;
380
382 DoubleVector pseudoDown_;
383
385 DoubleVector pseudoUp_;
386
388 NodeStatus status_;
389
391 double vioVal_;
392
394 double tbScore_;
395
397 CutList cutPool_;
398
403 UIntVector timesDown_;
404
409 UIntVector timesUp_;
410
412 WarmStartPtr ws_;
413
415 Node(const Node &node);
416
418 Node(NodePtr node);
419 };
420
421
422} //namespace Minotaur
423#endif
Declare important 'types' used in Minotaur.
Base class for storing branching modifications.
Definition: Branch.h:33
Store function, bounds and other information about a cut.
Definition: Cut.h:52
Definition: Modification.h:29
Definition: Node.h:54
void setLastStrongBranched(UIntVector lstStrnBrnchd)
Set the vector of last strong branched information of candidates.
Definition: Node.h:248
void removeWarmStart()
Remove warm start information associated with this node.
Definition: Node.cpp:244
void updateBrCands(UInt index)
Definition: Node.cpp:396
UIntVector getTimesDown() const
Definition: Node.h:188
size_t getNumChildren()
Number of children of this node.
Definition: Node.h:150
double getLb() const
Return the lower bound of the relaxation obtained at this node.
Definition: Node.h:147
void addPMod(ModificationPtr m)
Definition: Node.h:81
void applyCutsByIndex(RelaxationPtr rel)
Definition: Node.cpp:155
void undoRMods(RelaxationPtr r)
Definition: Node.cpp:315
void setTbScore(double d)
Get the tie-breaking score.
Definition: Node.h:266
void write(std::ostream &o) const
Write the node.
Definition: Node.cpp:446
void removeParent()
Remove the pointer to the parent node. Used when deleting a node.
Definition: Node.cpp:238
void undoRModsTrans(RelaxationPtr r)
Definition: Node.cpp:343
void undoMods(RelaxationPtr rel, ProblemPtr p)
Definition: Node.cpp:389
UInt getDepth() const
Return the depth of the node in the tree.
Definition: Node.h:138
void applyMods(RelaxationPtr rel, ProblemPtr p)
Definition: Node.cpp:219
ModificationConstIterator modsBegin() const
Definition: Node.h:207
void applyRModsTrans(RelaxationPtr rel)
Definition: Node.cpp:179
void removeChild(NodePtrIterator childNodeIter)
Definition: Node.cpp:226
ModificationConstIterator modsEnd() const
End of modifications applied at this node.
Definition: Node.h:211
void updateLastStrBranched(UInt index, double value)
Definition: Node.cpp:401
UIntVector getTimesUp() const
Definition: Node.h:194
void setTimesDown(UIntVector timesDown)
Set the times down for this node.
Definition: Node.h:269
CutList getCutPool()
Return the cut-pool of this node.
Definition: Node.h:135
DoubleVector getPCDown()
Definition: Node.h:160
double getTbScore() const
Get the tie-breaking score.
Definition: Node.h:178
NodeStatus getStatus() const
Get the status of this node.
Definition: Node.h:175
void setPCDown(DoubleVector pcDown)
Set the down pseudocosts for this node.
Definition: Node.h:257
void addCutToPool(CutPtr cut, RelaxationPtr rel)
Add cut to the cut-pool of this node.
Definition: Node.cpp:133
void setDepth(UInt depth)
Set the depth of the node in the tree.
Definition: Node.cpp:257
void removeChildren()
Disassociate all children from this node.
Definition: Node.cpp:232
void applyRMods(RelaxationPtr rel)
Definition: Node.cpp:113
UIntVector getLastStrongBranched()
Return the vector of last strong branching information of candidates.
Definition: Node.h:144
void setPCUp(DoubleVector pcUp)
Set the up pseudocosts for this node.
Definition: Node.h:260
void updateTimesUp(UInt index, double value)
Definition: Node.cpp:437
void applyPMods(ProblemPtr p)
Definition: Node.cpp:93
BranchPtr getBranch() const
Definition: Node.h:132
virtual ~Node()
Default destructor.
Definition: Node.cpp:64
void setLb(double value)
Set a lower bound for the relaxation at this node.
Definition: Node.cpp:269
void addChild(NodePtr childNode)
Add a child node.
Definition: Node.cpp:87
UInt getId() const
Return the ID of this node.
Definition: Node.h:141
WarmStartPtr getWarmStart()
Get the warm start information.
Definition: Node.h:197
DoubleVector getPCUp() const
Definition: Node.h:172
NodePtrIterator childrenEnd()
Last child.
Definition: Node.h:126
void setId(UInt id)
Definition: Node.cpp:263
void setWarmStart(WarmStartPtr ws)
Set warm start information.
Definition: Node.cpp:275
NodePtr getParent() const
Return a pointer to the parent node.
Definition: Node.h:153
void setBrCands(UIntVector brCands)
Set the branching candidate information for this node.
Definition: Node.h:236
ModificationRConstIterator modsRBegin() const
Reverse iterators.
Definition: Node.h:215
NodePtrIterator childrenBegin()
Access the children by iterating over the vector.
Definition: Node.h:123
void setTimesUp(UIntVector timesUp)
Set the times up for this node.
Definition: Node.h:272
void addRMod(ModificationPtr m)
Definition: Node.h:89
void undoPMods(ProblemPtr p)
Definition: Node.cpp:287
Node()
Default constructor.
Definition: Node.cpp:30
ModificationRConstIterator modsREnd() const
Reverse iterators.
Definition: Node.h:218
void updatePCDown(UInt index, double value)
Definition: Node.cpp:410
void updateTimesDown(UInt index, double value)
Definition: Node.cpp:428
void makeChildOf(const Node *parent)
UIntVector getBrCands() const
Definition: Node.h:166
void updatePCUp(UInt index, double value)
Definition: Node.cpp:419
void setStatus(NodeStatus status)
Set the status of this node.
Definition: Node.h:263
Definition: Problem.h:74
Definition: Relaxation.h:53
Definition: WarmStart.h:45
Definition: ActiveNodeStore.h:20
unsigned int UInt
Unsigned integer.
Definition: Types.h:30
NodeStatus
Status of a node in branch-and-bound.
Definition: Types.h:204

Minotaur source code documented by Doxygen 1.9.4 on Thu Apr 24 2025