AutoPas  3.0.0
Loading...
Searching...
No Matches
RuleBasedTuning.h
Go to the documentation of this file.
1
7#pragma once
8
9#include <fstream>
10#include <list>
11#include <unordered_map>
12
13#ifdef AUTOPAS_ENABLE_RULES_BASED_AND_FUZZY_TUNING
14#include "RuleBasedProgramParser.h"
15#include "RuleBasedProgramTree.h"
16#include "RuleVM.h"
17#endif
18
23
24namespace autopas {
80 public:
85#ifdef AUTOPAS_ENABLE_RULES_BASED_AND_FUZZY_TUNING
86 std::function<void(const RuleSyntax::ConfigurationOrder &order, const Configuration &actualBetterConfig,
87 unsigned long betterRuntime, const Configuration &shouldBeBetterConfig,
88 unsigned long shouldBeBetterRuntime, const LiveInfo &liveInfo)>;
89#else
90 int; // This is simply a dummy type and will never be used.
91#endif
92
100 explicit RuleBasedTuning(const std::set<Configuration> &searchSpace, bool verifyModeEnabled = false,
101 std::string ruleFileName = "tuningRules.rule",
102 PrintTuningErrorFunType tuningErrorPrinter = {});
103
104 TuningStrategyOption getOptionType() const override;
105
106 bool needsLiveInfo() const override;
107
108 void receiveLiveInfo(const LiveInfo &info) override;
109
110 void addEvidence(const Configuration &configuration, const Evidence &evidence) override;
111
112 bool reset(size_t iteration, size_t tuningPhase, std::vector<Configuration> &configQueue,
113 const autopas::EvidenceCollection &evidenceCollection) override;
114
119 [[nodiscard]] long getLifetimeWouldHaveSkippedTuningTime() const;
120
124 [[nodiscard]] long getLifetimeTuningTime() const;
125
126 bool optimizeSuggestions(std::vector<Configuration> &configQueue,
127 const EvidenceCollection &evidenceCollection) override;
128
129 private:
130#ifdef AUTOPAS_ENABLE_RULES_BASED_AND_FUZZY_TUNING
139 std::string rulesToString(const std::string &filePath) const;
140
148 void verifyCurrentConfigTime(const Configuration &configuration) const;
149
154 std::vector<RuleSyntax::ConfigurationOrder> applyRules(const std::vector<Configuration> &searchSpace);
155
156 std::vector<RuleSyntax::ConfigurationOrder> _lastApplicableConfigurationOrders{};
157
158 // The following member variables are only conditionally compiled to avoid warnings about unused variables.
159
160 bool _verifyModeEnabled{};
165 long _tuningTime{0};
166 long _wouldHaveSkippedTuningTime{0};
170 bool _rulesTooHarsh{false};
171 PrintTuningErrorFunType _tuningErrorPrinter{};
172#endif
173
174 std::set<Configuration> _searchSpace{};
175 std::list<Configuration> _originalSearchSpace{};
176 std::set<Configuration> _removedConfigurations{};
177
178 std::string _ruleFileName{};
179
180 std::unordered_map<Configuration, long, ConfigHash> _traversalTimes{};
181
182 long _tuningTimeLifetime{0};
183 long _wouldHaveSkippedTuningTimeLifetime{0};
184
185 LiveInfo _currentLiveInfo{};
186};
187} // namespace autopas
Class containing multiple options that form an algorithm configuration for the pairwise iteration.
Definition: Configuration.h:24
Class to manage all evidence.
Definition: EvidenceCollection.h:21
Helper class that associates a measurement with the iteration when it was taken.
Definition: Evidence.h:15
This class is able to gather and store important information for a tuning phase from a container and ...
Definition: LiveInfo.h:31
A tuning strategy that uses information collected live from the domain to exclude configurations that...
Definition: RuleBasedTuning.h:79
bool reset(size_t iteration, size_t tuningPhase, std::vector< Configuration > &configQueue, const autopas::EvidenceCollection &evidenceCollection) override
Reset all internal parameters to the beginning of a new tuning phase.
Definition: RuleBasedTuning.cpp:58
long getLifetimeTuningTime() const
Definition: RuleBasedTuning.cpp:87
void addEvidence(const Configuration &configuration, const Evidence &evidence) override
Notifies the strategy about empirically collected information for the given configuration.
Definition: RuleBasedTuning.cpp:43
TuningStrategyOption getOptionType() const override
Get this object's associated TuningStrategyOption type.
Definition: RuleBasedTuning.cpp:110
long getLifetimeWouldHaveSkippedTuningTime() const
Definition: RuleBasedTuning.cpp:85
void receiveLiveInfo(const LiveInfo &info) override
Virtual method that subclasses can override to receive the LiveInfo object before a tuning phase if t...
Definition: RuleBasedTuning.cpp:41
bool optimizeSuggestions(std::vector< Configuration > &configQueue, const EvidenceCollection &evidenceCollection) override
Optimizes the queue of configurations to process.
Definition: RuleBasedTuning.cpp:89
bool needsLiveInfo() const override
Returns whether this tuning strategy wants to get a LiveInfo object passed before a new tuning phase.
Definition: RuleBasedTuning.cpp:39
int PrintTuningErrorFunType
A function type used to print errors found in verify mode.
Definition: RuleBasedTuning.h:90
Interface for tuning strategies for the auto tuner.
Definition: TuningStrategyInterface.h:23
This is the main namespace of AutoPas.
Definition: AutoPasDecl.h:32
A ConfigurationOrder statement in the rule language e.g.
Definition: RuleBasedProgramTree.h:193