Minotaur 0.4.1
Docs for developers
RCHandler.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
14#ifndef MINOTAURRCHANDLER_H
15#define MINOTAURRCHANDLER_H
16
17#include <stack>
18
19#include "Handler.h"
20#include "Engine.h"
21#include "Problem.h"
22#include "Function.h"
23#include "Types.h"
24
25namespace Minotaur {
26
27
28struct RCStats {
29 size_t nlb;
30 size_t nub;
31 double time;
32};
33
34class CutManager;
35class Timer;
36class SimpleCutMan;
37class Environment;
38
42class RCHandler : public Handler {
43
44
45public:
50 RCHandler(EnvPtr env);
51
53 ~RCHandler();
54
56 Branches getBranches(BrCandPtr, DoubleVector &, RelaxationPtr,
58 {return Branches();};
59
60 // Base class method
62 const DoubleVector &, ModVector &,
63 BrVarCandSet &, BrCandVector &, bool &) {};
64
65 // Base class method
68 { return ModificationPtr(); };
69
70
71 // Base class method.
72 std::string getName() const;
73
74 // Base class method.
75 bool isFeasible(ConstSolutionPtr, RelaxationPtr, bool &, double &)
76 { return true; };
77
78 // Base class method
79 SolveStatus presolve(PreModQ *, bool *, Solution **)
80 { return Finished; };
81
82 // Base class method
84 ModVector &)
85 {return false;};
86
87 // Base class method.
88 void postsolveGetX(const double *, UInt, DoubleVector *) {};
89
90 // Base class method
92
93 // Base class method. calls relax_().
95
96 // Base class method.
98
99 // Base class method.
101
102
103 // Base class method. Used for tightening upper and lower bound of variables.
104 void separate(ConstSolutionPtr sol, NodePtr node, RelaxationPtr rel,
105 CutManager *cutman, SolutionPoolPtr s_pool, ModVector &p_mods,
106 ModVector &q_mods, bool *sol_found, SeparationStatus *status);
107
108 // Show statistics.
109 void writeStats(std::ostream &) const;
110
111private:
113 double lastBest_;
114
116 LoggerPtr logger_;
117
119 static const std::string me_;
120
122 double *rootDuals_;
123
125 double rootObj_;
126
128 double *rootX_;
129
131 RCStats *stats_;
132
134 const Timer* timer_;
135
136 // brief copy the root node dual information
137 // \param[in] solution pointer
138 // \param[in] relaxation problem pointer
139 void copyRootDetails_(ConstSolutionPtr sol, RelaxationPtr rel);
140
141 // brief reduced cost fixing using dual information of node
142 // \param[in] solution pointer
143 // \param[in] relaxation problem pointer
144 // \param[in]
145 // \param[in] incumbent solution value
146 // \param[in] relaxation object value
147 // \param[in] x[v->getIndex] value
148 // \param[in] reduced cost of variable
149 // \param[in] variable pointer
150 void rcfix_(RelaxationPtr rel, ModVector &r_mods,
151 double bestobj, const double rel_obj, double xval, double r,
152 VariablePtr v);
153};
154 typedef RCHandler* RCHandlerPtr;
155}
156
157
158#endif
159
Define the base class Engine.
Get information about a Function.
Define abstract base class for handlers of various kinds.
Declare the base class Modification.
Declare important 'types' used in Minotaur.
Base class for describing candidates for branching on a node in branch-and-bound.
Definition: BrCand.h:32
Abstract base class to manage cuts in the relaxation.
Definition: CutManager.h:42
Definition: Environment.h:28
Base class for handling specific types of constraints or objective.
Definition: Handler.h:49
Definition: Logger.h:37
Definition: Modification.h:29
Definition: Node.h:54
Handler for reduced cost strengthening.
Definition: RCHandler.h:42
SolveStatus presolve(PreModQ *, bool *, Solution **)
Initial presolve.
Definition: RCHandler.h:79
void relaxNodeInc(NodePtr, RelaxationPtr, bool *)
Create an incremental relaxation for a node.
Definition: RCHandler.h:100
bool presolveNode(RelaxationPtr, NodePtr, SolutionPoolPtr, ModVector &, ModVector &)
Presolve the problem and its relaxation at a node.
Definition: RCHandler.h:83
bool isFeasible(ConstSolutionPtr, RelaxationPtr, bool &, double &)
Check if a solution is feasible.
Definition: RCHandler.h:75
void getBranchingCandidates(RelaxationPtr, const DoubleVector &, ModVector &, BrVarCandSet &, BrCandVector &, bool &)
find branching candidates.
Definition: RCHandler.h:61
Branches getBranches(BrCandPtr, DoubleVector &, RelaxationPtr, SolutionPoolPtr)
Base class method.
Definition: RCHandler.h:56
~RCHandler()
Destroy.
Definition: RCHandler.cpp:46
RCHandler(EnvPtr env)
Constructor.
Definition: RCHandler.cpp:31
ModificationPtr getBrMod(BrCandPtr, DoubleVector &, RelaxationPtr, BranchDirection)
Get the modifcation that creates a given (up or down) branch.
Definition: RCHandler.h:66
void writeStats(std::ostream &) const
Write statistics to ostream out.
Definition: RCHandler.cpp:237
void relaxNodeFull(NodePtr, RelaxationPtr, bool *)
Create a relaxation for a node, building from scratch.
Definition: RCHandler.h:97
void relaxInitInc(RelaxationPtr, SolutionPool *, bool *)
Create root relaxation if doing incremental node relaxations.
Definition: RCHandler.h:94
void relaxInitFull(RelaxationPtr, SolutionPool *, bool *)
Create root relaxation if doing full node relaxations.
Definition: RCHandler.h:91
std::string getName() const
Return the name of the handler.
Definition: RCHandler.cpp:211
void separate(ConstSolutionPtr sol, NodePtr node, RelaxationPtr rel, CutManager *cutman, SolutionPoolPtr s_pool, ModVector &p_mods, ModVector &q_mods, bool *sol_found, SeparationStatus *status)
add cuts to separate a given point.
Definition: RCHandler.cpp:59
Definition: Relaxation.h:53
Derived class for managing cuts. Adds all violated cuts from the storage to the relaxation and never ...
Definition: SimpleCutMan.h:30
Definition: SolutionPool.h:28
Definition: Solution.h:30
Definition: Timer.h:40
Definition: Variable.h:31
Definition: ActiveNodeStore.h:20
BranchDirection
Two directions for branching.
Definition: Types.h:201
unsigned int UInt
Unsigned integer.
Definition: Types.h:30
SeparationStatus
Status from separation routine:
Definition: Types.h:217
SolveStatus
Different states an algorithm like branch-and-bound can be in.
Definition: Types.h:158
Definition: RCHandler.h:28
size_t nub
Number of lower bound changed.
Definition: RCHandler.h:30
double time
Number of Upper Bound Changed
Definition: RCHandler.h:31

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