Minotaur 0.4.1
Docs for developers
ParReliabilityBrancher.h
1//
2// Minotaur -- It's only 1/2 bull
3//
4// (C)opyright 2009 - 2025 The Minotaur Team.
5//
6
14#ifndef MINOTAURPARRELIABILITYBRANCHER_H
15#define MINOTAURPARRELIABILITYBRANCHER_H
16
17#include "Brancher.h"
18#include "ParTreeManager.h"
19
20namespace Minotaur {
21
22class Engine;
23class Timer;
24typedef Engine* EnginePtr;
25
27 UInt bndChange;
32 double strTime;
33};
34
35
38
39public:
47 ParReliabilityBrancher(EnvPtr env, HandlerVector & handlers);
48
51
52 // base class function.
55 BrancherStatus &, ModVector &) {return Branches();};
56
57 // Overloaded base class function.
58 Branches findBranches(RelaxationPtr rel, NodePtr node,
60 BrancherStatus & br_status, ModVector &mods,
61 UIntVector timesUp, UIntVector timesDown,
62 DoubleVector pseudoUp, DoubleVector pseudoDown,
63 UInt nodesProc);
64
66 bool getTrustCutoff();
67
70
72 UIntVector getLastStrBranched() {return lastStrBranched_;}
73
74 // base class function.
75 std::string getName() const;
76
81 DoubleVector getPCUp() const { return pseudoUp_; }
82
87 DoubleVector getPCDown() const { return pseudoDown_; }
88
93 UIntVector getTimesDown() const { return timesDown_; }
94
99 UIntVector getTimesUp() const { return timesUp_; }
100
102 UInt getThresh() const;
103
109 void initialize(RelaxationPtr rel);
110
112 void setTrustCutoff(bool val);
113
119 void setEngine(EnginePtr engine);
120
126 void setIterLim(UInt k);
127
129 void setLastStrBranched(UIntVector lastStrBranched) {lastStrBranched_ = lastStrBranched ;};
130
136 void setMaxDepth(UInt k);
137
143 void setMinNodeDist(UInt k);
144
149 void setPCUp(DoubleVector psuedoUp) { pseudoUp_ = psuedoUp; };
150
155 void setPCDown(DoubleVector psuedoDown) { pseudoDown_ = psuedoDown; };
156
161 void setTimesDown(UIntVector timesDown) { timesDown_ = timesDown; };
162
167 void setTimesUp(UIntVector timesUp) { timesUp_ = timesUp; };
168
169
177 void setThresh(UInt k);
178
179 // base class function.
181
183 void writeStats(std::ostream &out) const;
184
185private:
186
197 BrCandPtr findBestCandidate_(const double objval, double cutoff,
198 NodePtr node, DoubleVector pseudoUp,
199 DoubleVector pseudoDown, UInt nodesProc);
200
210 void findCandidates_(UIntVector *timesUp, UIntVector *timesDown,
211 DoubleVector *pseudoUp, DoubleVector *pseudoDown,
212 UInt nodesProc);
213
218 void freeCandidates_(BrCandPtr no_del);
219
228 void getPCScore_(BrCandPtr cand, double *ch_down, double *ch_up,
229 double *score, DoubleVector pseudoUp, DoubleVector pseudoDown);
230
237 double getScore_(const double & up_score, const double & down_score);
238
253 bool shouldPrune_(const double &chcutoff, const double &change,
254 const EngineStatus & status, bool *is_rel);
255
264 void strongBranch_(BrCandPtr cand, double & obj_up, double & obj_down,
265 EngineStatus & status_up, EngineStatus & status_down);
266
277 void updatePCost_(const int &i, const double &new_cost,
278 DoubleVector &cost, UIntVector &count);
279
295 void useStrongBranchInfo_(BrCandPtr cand, const double & chcutoff,
296 double & change_up, double & change_down,
297 const EngineStatus & status_up,
298 const EngineStatus & status_down);
299
308 void writeScore_(BrCandPtr cand, double score, double change_up,
309 double change_down);
310
317 void writeScores_(std::ostream &out);
318
320 EnginePtr engine_;
321
323 const double eTol_;
324
329 HandlerVector handlers_;
330
332 bool init_;
333
335 UIntVector lastStrBranched_;
336
339 UInt maxDepth_;
340
345 UInt maxIterations_;
346
350 UInt maxStrongCands_;
351
353 const static std::string me_;
354
359 UInt minNodeDist_;
360
362 ModVector mods_;
363
365 DoubleVector pseudoDown_;
366
368 DoubleVector pseudoUp_;
369
371 RelaxationPtr rel_;
372
374 std::vector<BrCandPtr> relCands_;
375
377 ParRelBrStats * stats_;
378
380 BrancherStatus status_;
381
383 Timer *timer_;
384
389 UIntVector timesDown_;
390
395 UIntVector timesUp_;
396
398 UInt thresh_;
399
401 bool trustCutoff_;
402
407 std::vector<BrCandPtr> unrelCands_;
408
410 DoubleVector x_;
411
412};
413typedef ParReliabilityBrancher* ParReliabilityBrancherPtr;
414}
415#endif
416
Declare the base class Brancher for finding and creating branches in Branch-and-Bound.
Base class for describing candidates for branching on a node in branch-and-bound.
Definition: BrCand.h:32
A brancher is used to find suitable branches for a given node. e.g. LexicoBrancher....
Definition: Brancher.h:33
Definition: Engine.h:34
Definition: Environment.h:28
Definition: Node.h:54
A class to select a variable for branching using reliability branching.
Definition: ParReliabilityBrancher.h:37
UIntVector getTimesDown() const
Definition: ParReliabilityBrancher.h:93
ParReliabilityBrancher(EnvPtr env, HandlerVector &handlers)
Construct using an environment pointer and handlers.
Definition: ParReliabilityBrancher.cpp:43
void setTimesDown(UIntVector timesDown)
Definition: ParReliabilityBrancher.h:161
UInt getThresh() const
Return the threshhold value.
Definition: ParReliabilityBrancher.cpp:408
DoubleVector getPCDown() const
Definition: ParReliabilityBrancher.h:87
void writeStats(std::ostream &out) const
Write statistics.
Definition: ParReliabilityBrancher.cpp:679
bool getTrustCutoff()
Return value of trustCutoff parameter.
Definition: ParReliabilityBrancher.cpp:361
void setPCDown(DoubleVector psuedoDown)
Definition: ParReliabilityBrancher.h:155
UInt getIterLim()
Get iteration limit of engine.
Definition: ParReliabilityBrancher.cpp:367
void setTrustCutoff(bool val)
Set value of trustCutoff parameter.
Definition: ParReliabilityBrancher.cpp:431
void initialize(RelaxationPtr rel)
Initialize data structures.
Definition: ParReliabilityBrancher.cpp:414
void setMinNodeDist(UInt k)
Don't do strong branching on a cand if we did it 'k' nodes or less ago.
Definition: ParReliabilityBrancher.cpp:455
void setIterLim(UInt k)
Set iteration limit of engine.
Definition: ParReliabilityBrancher.cpp:443
void setLastStrBranched(UIntVector lastStrBranched)
Return the vector of last strong branching information of candidates.
Definition: ParReliabilityBrancher.h:129
void setEngine(EnginePtr engine)
Set engine.
Definition: ParReliabilityBrancher.cpp:437
Branches findBranches(RelaxationPtr, NodePtr, ConstSolutionPtr, SolutionPoolPtr, BrancherStatus &, ModVector &)
Find a branching candidate.
Definition: ParReliabilityBrancher.h:53
void setPCUp(DoubleVector psuedoUp)
Definition: ParReliabilityBrancher.h:149
UIntVector getLastStrBranched()
Return the vector of last strong branching information of candidates.
Definition: ParReliabilityBrancher.h:72
DoubleVector getPCUp() const
Definition: ParReliabilityBrancher.h:81
void setTimesUp(UIntVector timesUp)
Definition: ParReliabilityBrancher.h:167
void setMaxDepth(UInt k)
Set the depth at which we stop strong branching.
Definition: ParReliabilityBrancher.cpp:449
void setThresh(UInt k)
Set reliability threshhold.
Definition: ParReliabilityBrancher.cpp:461
std::string getName() const
Return the name of this brancher.
Definition: ParReliabilityBrancher.cpp:373
UIntVector getTimesUp() const
Definition: ParReliabilityBrancher.h:99
void updateAfterSolve(NodePtr node, ConstSolutionPtr sol)
Update pseudo-costs after LP is solved.
Definition: ParReliabilityBrancher.cpp:544
~ParReliabilityBrancher()
Destroy.
Definition: ParReliabilityBrancher.cpp:70
Definition: Relaxation.h:53
Definition: SolutionPool.h:28
Definition: Solution.h:30
Definition: Timer.h:40
Definition: ActiveNodeStore.h:20
BrancherStatus
What can a brancher do to a node in branch-and-bound.
Definition: Types.h:193
unsigned int UInt
Unsigned integer.
Definition: Types.h:30
EngineStatus
Different status that an external engine may report.
Definition: Types.h:176
Definition: ParReliabilityBrancher.h:26
UInt engProbs
Number of times called to find a branching candidate.
Definition: ParReliabilityBrancher.h:29
double strTime
Number of times strong branching on a variable.
Definition: ParReliabilityBrancher.h:32
UInt strBrCalls
Number of iterations in strong-branching.
Definition: ParReliabilityBrancher.h:31
UInt iters
Number of times an unexpected engine status was met.
Definition: ParReliabilityBrancher.h:30
UInt calls
Number of times variable bounds were changed.
Definition: ParReliabilityBrancher.h:28

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