Minotaur 0.4.1
Docs for developers
MaxInfBrancher.h
Go to the documentation of this file.
1//
2// Minotaur -- It's only 1/2 bull
3//
4// (C)opyright 2009 - 2025 The Minotaur Team.
5//
6
13#ifndef MINOTAURMAXINFBRANCHER_H
14#define MINOTAURMAXINFBRANCHER_H
15
16#include "Brancher.h"
17
18namespace Minotaur {
19
20class Engine;
21class Timer;
22typedef Engine* EnginePtr;
23
25 UInt bndChange;
30 double time;
31};
32
34class MaxInfBrancher : public Brancher {
35public:
37 MaxInfBrancher(EnvPtr env, HandlerVector & handlers);
38
41
42 // Find a branching candidate. Returns NULL if x does not have any
43 // thing to branch on or if no branching candidates are needed.
44 Branches findBranches(RelaxationPtr rel, NodePtr node,
46 BrancherStatus & br_status, ModVector &mods);
47
48 // Update pseudo-cost/other information after branching.
50
51 // Write statistics.
52 void writeStats(std::ostream &out) const;
53
55 bool getTrustCutoff();
56
59
60 // base class function.
61 std::string getName() const;
62
64 UInt getThresh() const;
65
71 void initialize(RelaxationPtr rel);
72
74 void setTrustCutoff(bool val);
75
81 void setEngine(EnginePtr engine);
82
88 void setIterLim(UInt k);
89
95 void setMaxDepth(UInt k);
96
102 void setMinNodeDist(UInt k);
103
111 void setThresh(UInt k);
112
113 // Print inference score
114 void printMaxInferenceScores() const;
115
116 // Vector to store up score
117 std::vector<double> upScores_;
118
119 // Vector to store down score
120 std::vector<double> downScores_;
121
122 //Infrence score function
123 void infScore();
124 void statsTable()const;
125
126 //Normalize function to calculate score
127 double gFunction(double x) const;
128
129private:
130
131 // inference functions
132 void infAggregation_(int idx, int nvars, int nposbin, double wt1, double wt2, ConstraintPtr c);
133 void infPrecedence_(int idx, int nvars, int nnegbin, int nposbin, ConstraintPtr c);
134 void infVariableBound_(int idx, int nposbin, double wt, double wt1, double wt2, ConstraintPtr c);
135 void infSetPartition_(int idx, int nvars, double wt);
136 void infSetPack_(int idx, int nvars, double wt);
137 void infCardinality_(int idx, int nvars, int nposbin, int nnegcoefone, double wt, ConstraintPtr c);
138 void infEquationKnapsack_(int idx, int nvars, double wt, ConstraintPtr c, double sumnegwt);
139 void infBinPack_(int idx, int nvars, double wt, ConstraintPtr c, double sumnegwt);
140 void infKnapsack_(int idx, int nvars, double wt, ConstraintPtr c, int nposbin, double sumnegwt);
141 void infMixed_(VariablePtr v, int idx, double wt, ConstraintPtr c);
142 void findCandidates_();
143
144 void freeCandidates_(BrCandPtr no_del);
145 void getPCScore_(BrCandPtr cand, double *ch_down, double *ch_up, double *score);
146 double getScore_(const double & up_score, const double & down_score);
147 bool shouldPrune_(const double &chcutoff, const double &change, const EngineStatus & status, bool *is_rel);
148 BrCandPtr findBestCandidate_(const double objval, double cutoff,
149 NodePtr node);
150
159 void strongBranch_(BrCandPtr cand, double & obj_up, double & obj_down, EngineStatus & status_up, EngineStatus & status_down);
160
169 void updatePCost_(const int &i, const double &new_cost, DoubleVector &cost, UIntVector &count);
170
186 void useStrongBranchInfo_(BrCandPtr cand, const double & chcutoff, double & change_up, double & change_down, const EngineStatus & status_up, const EngineStatus & status_down);
187
196 void writeScore_(BrCandPtr cand, double score, double change_up, double change_down);
197 void writeScores_(std::ostream &out);
198
199 EnginePtr engine_;
200 const double eTol_;
201 UIntVector lastStrBranched_;
202 UInt maxDepth_;
203 UInt maxIterations_;
204 UInt maxStrongCands_;
205 UInt minNodeDist_;
206 ModVector mods_;
207 DoubleVector pseudoDown_;
208 DoubleVector pseudoUp_;
209 std::vector<BrCandPtr> relCands_;
210 UIntVector timesDown_;
211 UIntVector timesUp_;
212 UInt thresh_;
213 bool trustCutoff_;
214 std::vector<BrCandPtr> unrelCands_;
215 BrancherStatus status_;
216 RelaxationPtr rel_;
217 DoubleVector x_;
218 HandlerVector handlers_;
219 Timer *timer_;
220 MaxInfBrStats *stats_;
221 BrVarCandSet cands_;
222 bool init_;
227 UIntVector fracCount_;
228
233 UIntVector unfixedCount_;
238 void updateFracCount_();
243 void updateUnfixedCount_();
244
246 UIntVector actualTimesUp_;
247
249 UIntVector actualTimesDown_;
250 std::vector<std::string> variableNames_;
251
252
254 const static std::string me_;
255};
256
258
259} // namespace Minotaur
260
261#endif // MINOTAURMAXINFBRANCHER_H
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
The Constraint class is used to manage a constraint.
Definition: Constraint.h:61
Definition: Engine.h:34
Definition: Environment.h:28
A class to select a variable for branching using maximum-inference branching.
Definition: MaxInfBrancher.h:34
void setThresh(UInt k)
Set reliability threshhold.
Definition: MaxInfBrancher.cpp:530
void setMaxDepth(UInt k)
Set the depth at which we stop strong branching.
Definition: MaxInfBrancher.cpp:520
void setMinNodeDist(UInt k)
Don't do strong branching on a cand if we did it 'k' nodes or less ago.
Definition: MaxInfBrancher.cpp:525
void initialize(RelaxationPtr rel)
Initialize data structures.
Definition: MaxInfBrancher.cpp:168
void setIterLim(UInt k)
Set iteration limit of engine.
Definition: MaxInfBrancher.cpp:515
void setEngine(EnginePtr engine)
Set engine.
Definition: MaxInfBrancher.cpp:510
MaxInfBrancher(EnvPtr env, HandlerVector &handlers)
Construct using an environment pointer and initialize.
Definition: MaxInfBrancher.cpp:39
UInt getIterLim()
Get iteration limit of engine.
Definition: MaxInfBrancher.cpp:428
void writeStats(std::ostream &out) const
Write statistics to the given out stream.
Definition: MaxInfBrancher.cpp:385
void setTrustCutoff(bool val)
Set value of trustCutoff parameter.
Definition: MaxInfBrancher.cpp:505
UInt getThresh() const
Return the threshhold value.
Definition: MaxInfBrancher.cpp:499
bool getTrustCutoff()
Return value of trustCutoff parameter.
Definition: MaxInfBrancher.cpp:423
void updateAfterSolve(NodePtr node, ConstSolutionPtr sol)
Update pseudo-costs after LP is solved.
Definition: MaxInfBrancher.cpp:355
Branches findBranches(RelaxationPtr rel, NodePtr node, ConstSolutionPtr sol, SolutionPoolPtr s_pool, BrancherStatus &br_status, ModVector &mods)
Find a branching candidate.
Definition: MaxInfBrancher.cpp:72
std::string getName() const
Return the name of this brancher.
Definition: MaxInfBrancher.cpp:402
~MaxInfBrancher()
Destroy.
Definition: MaxInfBrancher.cpp:66
Definition: Node.h:54
Definition: Relaxation.h:53
Definition: SolutionPool.h:28
Definition: Solution.h:30
Definition: Timer.h:40
Definition: Variable.h:31
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: MaxInfBrancher.h:24
UInt strBrCalls
Number of iterations in strong-branching.
Definition: MaxInfBrancher.h:29
UInt engProbs
Number of times called to find a branching candidate.
Definition: MaxInfBrancher.h:27
UInt calls
Number of times variable bounds were changed.
Definition: MaxInfBrancher.h:26
UInt iters
Number of times an unexpected engine status was met.
Definition: MaxInfBrancher.h:28
double time
Number of times strong branching on a variable.
Definition: MaxInfBrancher.h:30

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