Program Listing for File subtask_sel_probability.hpp

Return to documentation for file (cosm/ta/subtask_sel_probability.hpp)

#pragma once

/*******************************************************************************
 * Includes
 ******************************************************************************/
#include <string>

#include "rcppsw/er/client.hpp"
#include "rcppsw/math/rng.hpp"
#include "rcppsw/math/sigmoid.hpp"

#include "cosm/ta/time_estimate.hpp"

/*******************************************************************************
 * Namespaces/Decls
 ******************************************************************************/
namespace cosm::ta {

namespace config {
struct sigmoid_sel_config;
} /* namespace config */

/*******************************************************************************
 * Class Definitions
 ******************************************************************************/
class subtask_sel_probability final : public rer::client<subtask_sel_probability>,
                                      public rmath::sigmoid {
 public:
  static constexpr const double kHARWELL2018_REACTIVITY = 8.0;
  static constexpr const double kHARWELL2018_OFFSET = 1.25;
  static constexpr const double kHARWELL2018_GAMMA = 1.0;

  static constexpr const double kBRUTSCHY2014_REACTIVITY = 1.0;
  static constexpr const double kBRUTSCHY2014_OFFSET = 8.0;
  static constexpr const double kBRUTSCHY2014_GAMMA = 0.01;

  static inline const std::string kMethodBrutschy2014 = "brutschy2014";
  static inline const std::string kMethodHarwell2018 = "harwell2018";
  static inline const std::string kMethodRandom = "random";

  explicit subtask_sel_probability(std::string method);
  ~subtask_sel_probability(void) override = default;

  explicit subtask_sel_probability(const config::sigmoid_sel_config* config);

  const std::string& method(void) const { return mc_method; }

  void init_sigmoid(double reactivity, double offset, double gamma);

  double operator()(const time_estimate* subtask1,
                    const time_estimate* subtask2,
                    rmath::rng* rng);

 private:
  double calc_random(rmath::rng* rng);

  double calc_brutschy2014(const time_estimate& int_est1,
                           const time_estimate& int_est2);

  double calc_harwell2018(const time_estimate& exec_est1,
                          const time_estimate& exec_est2);

  double calc_sigmoid(const time_estimate& est1,
                      const time_estimate& est2) RCPPSW_PURE;

  /* clang-format off */
  const std::string mc_method;
  /* clang-format on */
};

} /* namespace cosm::ta */