Minotaur 0.4.1
Docs for developers
MsProcessor.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 MINOTAURMSPROCESSOR_H
14#define MINOTAURMSPROCESSOR_H
15
16#include "NodeProcessor.h"
17#include "Types.h"
18
19namespace Minotaur {
20
21 class Engine;
22 class Problem;
23 class Solution;
24 typedef const Solution* ConstSolutionPtr;
25
26 struct MBPStats {
27 UInt bra;
33 };
34
43 class MsProcessor : public NodeProcessor {
44
45 public:
48
50 MsProcessor(EnvPtr env, EnginePtr engine, HandlerVector handlers_);
51
54
55 // True if a new solution was found while processing this node.
56 bool foundNewSolution();
57
58 // Find branches that will be used to branch at this node.
59 Branches getBranches();
60
61 // Get warm-start information.
63
64 // Implement NodeProcessor::process().
65 void process(NodePtr node, RelaxationPtr rel,
66 SolutionPoolPtr s_pool);
67
68 // Get a corner of the variable space box randomly
69 double* getBoxCorner(UInt n, RelaxationPtr rel1,
70 int threadid, int K);
71
72 // Get a corner of the variable space box randomly
73 double* getFarBoxCorner(UInt n, RelaxationPtr rel1,
74 int threadid, double* prev_opt, int K);
75
76
77 // Generate a random starting point within variable bounds (for relaxations)
78 double* getStartPointScheme1(UInt n, RelaxationPtr rel1);
79
84 double* getStartPointScheme2(UInt n, RelaxationPtr rel1, int threadid,
85 double radius, int numsols,
86 double* prev_start_point);
87
92 double* getStartPointScheme4(UInt n, RelaxationPtr rel1, int threadid,
93 double radius, int numsols,
94 double* prev_start_point,
95 double* prev_opt, double costhetalim);
96
101 double* getStartPointScheme5(UInt n, RelaxationPtr rel1, int threadid,
102 double radius, double* prev_start_point,
103 double* prev_opt, int K, double lambda);
104
111 //double* getStartPointScheme6(UInt n, RelaxationPtr rel1, int threadid,
112 //double radius, int numsols,
113 //double* prev_start_point,
114 //double* prev_opt, int K, double lambda);
115
116 // Generate initial point based on variable fixing
117 double* genInitialPoint(UInt n, RelaxationPtr rel);
118
119 // Calculating inner product of two vectors
120 double InnerProduct(double b[], double c[], UInt n);
121
122 // Calculating Euclidean norm
123 double ENorm(double b[], UInt n);
124
125 // Calculate the Euclidean distance between two vectors
126 double EDist(double b[], double c[], UInt n);
127
128 // Testing parallelism
129 void par();
130
131 // write statistics. Base class method.
132 void writeStats(std::ostream &out) const;
133
134 // write statistics. Base class method.
135 void writeStats() const;
136
137 protected:
138
140 std::stack<Modification *> relMods_;
141
143 Branches branches_;
144
150
152 double cutOff_;
153
156
159
162
164 HandlerVector handlers_;
165
168
170 static const std::string me_;
171
174
177
180
183
186
189
192
199 virtual bool isFeasible_(NodePtr node, ConstSolutionPtr sol,
200 SolutionPoolPtr s_pool, bool &should_prune);
201
203 virtual void solveRelaxation_();
204
206 virtual void solveRelaxation_(EnginePtr e1);
207
208
213 virtual bool shouldPrune_(NodePtr node, double solval,
214 SolutionPoolPtr s_pool);
215
216 };
217
219
220}
221#endif
222
Define the NodeProcessor class for processing nodes in the branch-and-bound algorithm.
Declare important 'types' used in Minotaur.
Definition: Engine.h:34
Definition: Environment.h:28
Definition: Logger.h:37
Simple multi-start node-processor for branch-and-bound.
Definition: MsProcessor.h:43
WarmStartPtr ws_
Warm-start information for start processing the children.
Definition: MsProcessor.h:191
bool foundNewSolution()
Definition: MsProcessor.cpp:90
static const std::string me_
For logging.
Definition: MsProcessor.h:170
HandlerVector handlers_
All the handlers that are used for this processor.
Definition: MsProcessor.h:164
UInt numRestarts_
Number of restarts to improve the first intial point.
Definition: MsProcessor.h:176
bool contOnErr_
Definition: MsProcessor.h:149
Branches branches_
Branches found by this processor for this node.
Definition: MsProcessor.h:143
RelaxationPtr relaxation_
Relaxation that is processed by this processor.
Definition: MsProcessor.h:182
EnvPtr env_
Environment pointer.
Definition: MsProcessor.h:161
LoggerPtr logger_
Log.
Definition: MsProcessor.h:167
double * getStartPointScheme5(UInt n, RelaxationPtr rel1, int threadid, double radius, double *prev_start_point, double *prev_opt, int K, double lambda)
Definition: MsProcessor.cpp:553
double * getStartPointScheme2(UInt n, RelaxationPtr rel1, int threadid, double radius, int numsols, double *prev_start_point)
Definition: MsProcessor.cpp:317
virtual bool shouldPrune_(NodePtr node, double solval, SolutionPoolPtr s_pool)
Definition: MsProcessor.cpp:934
virtual void solveRelaxation_()
Solve the relaxation.
Definition: MsProcessor.cpp:1050
Branches getBranches()
Find branches that will be used to branch at this node.
Definition: MsProcessor.cpp:96
std::stack< Modification * > relMods_
Modifications done to NLP before solving it.
Definition: MsProcessor.h:140
virtual bool isFeasible_(NodePtr node, ConstSolutionPtr sol, SolutionPoolPtr s_pool, bool &should_prune)
Definition: MsProcessor.cpp:109
double * getStartPointScheme4(UInt n, RelaxationPtr rel1, int threadid, double radius, int numsols, double *prev_start_point, double *prev_opt, double costhetalim)
Definition: MsProcessor.cpp:426
void writeStats() const
Write statistics to our own logger.
Definition: MsProcessor.cpp:1085
double cutOff_
If lb is greater than cutOff_, we can prune this node.
Definition: MsProcessor.h:152
~MsProcessor()
Destroy.
Definition: MsProcessor.cpp:84
MBPStats stats_
Statistics.
Definition: MsProcessor.h:188
UInt schemeId_
Scheme id for generating initial point.
Definition: MsProcessor.h:185
EnginePtr engine_
Engine used to process the relaxation.
Definition: MsProcessor.h:155
UInt numThreads_
Number of processing cores to be used by the processor.
Definition: MsProcessor.h:179
void process(NodePtr node, RelaxationPtr rel, SolutionPoolPtr s_pool)
Definition: MsProcessor.cpp:666
UInt numSolutions_
How many new solutions were found by the processor.
Definition: MsProcessor.h:173
EngineStatus engineStatus_
Status of the engine.
Definition: MsProcessor.h:158
double * genInitialPoint(UInt n, RelaxationPtr rel)
Definition: MsProcessor.cpp:635
WarmStartPtr getWarmStart()
Definition: MsProcessor.cpp:103
MsProcessor(EnvPtr env)
Default constructor.
Definition: MsProcessor.cpp:39
Definition: NodeProcessor.h:49
Definition: Node.h:54
Definition: Relaxation.h:53
Definition: SolutionPool.h:28
Definition: Solution.h:30
Definition: WarmStart.h:45
Definition: ActiveNodeStore.h:20
unsigned int UInt
Unsigned integer.
Definition: Types.h:30
EngineStatus
Different status that an external engine may report.
Definition: Types.h:176
Definition: MsProcessor.h:26
UInt opt
Number of times relaxation became infeasible.
Definition: MsProcessor.h:29
UInt prob
Number of times relaxation gave optimal feasible solution.
Definition: MsProcessor.h:30
UInt ub
Number of nodes processed.
Definition: MsProcessor.h:32
UInt inf
Number of times relaxation became infeasible.
Definition: MsProcessor.h:28
UInt proc
Number of times problem ocurred in solving.
Definition: MsProcessor.h:31

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