Scheduler
configuration.cpp
Go to the documentation of this file.
1 
10 #include "configuration.h"
11 #include "rlDiscipline.h"
12 
17 
18 #include <memory>
19 
20 using namespace RlScheduler;
21 
22 std::unique_ptr<Scheduler::SchedulingDiscipline> Configuration::getDisciplineFromFile()
23 {
24  std::unique_ptr<Scheduler::SchedulingDiscipline> discipline = SchedulerConfiguration::getDisciplineFromFile();
25  if (discipline == nullptr)
26  {
27  std::string value = getStringValue("scheduler", "discipline");
28  if (!value.compare(RlDiscipline::configKey))
29  discipline = std::make_unique<RlDiscipline>(std::dynamic_pointer_cast<Configuration>(shared_from_this()));
30  }
31  return discipline;
32 }
33 
35 {
36  std::vector<std::string> str = getStringList("rlDiscipline", "maxTempEstimator");
37  if (str.size() == 0)
38  return nullptr;
39  if (!str[0].compare(EnvelopeDetector::configKey))
40  {
41  double decayCoeff = getDoubleValue("rlDiscipline","peakDecaySpeed");
42  return new EnvelopeDetector(decayCoeff);
43  }
44  if (!str[0].compare(SquareMaxTempEstimator::configKey))
45  return new SquareMaxTempEstimator();
46  if (!str[0].compare(MonomialMaxTempEstimator::configKey))
47  {
48  int order = 2;
49  if (str.size() > 1)
50  order = std::stoi(str[1]);
51  return new MonomialMaxTempEstimator(order);
52  }
53  if (!str[0].compare(ExponentialMaxTempEstimator::configKey))
54  {
55  double scaling = 1.0;
56  double offset = 0.0;
57  if (str.size() > 1)
58  {
59  scaling = std::stod(str[1]);
60  offset = std::stod(str[2]);
61  }
62  return new ExponentialMaxTempEstimator(scaling, offset);
63  }
64  return nullptr;
65 }
66 
67 
68 
70 {
71  double tempLimit = getDoubleValue("rlDiscipline", "tempLimit");
72  return tempLimit;
73 }
74 
75 
76 
77 
78 
79 
80 
81 
82 
static constexpr const char * configKey
MaxTempEstimator * getMaxTempEstimatorFromFile()
virtual double getDoubleValue(std::string section, std::string key)
virtual std::unique_ptr< Scheduler::SchedulingDiscipline > getDisciplineFromFile()
virtual std::vector< std::string > getStringList(std::string section, std::string key)
static constexpr const char * configKey
Definition: rlDiscipline.h:41
static const constexpr char * configKey
virtual std::string getStringValue(std::string section, std::string key)