Program Listing for File bi_tdgraph_allocator.hpp

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

#pragma once

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

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

/*******************************************************************************
 * Namespaces/Decls
 ******************************************************************************/
namespace cosm::ta {
class polled_task;
namespace ds {
class bi_tdgraph;
} /* namespace ds */
namespace config {
struct task_alloc_config;
} /* namespace config */

/*******************************************************************************
 * Class Definitions
 ******************************************************************************/
class bi_tdgraph_allocator : public rer::client<bi_tdgraph_allocator> {
 public:
  static inline const std::string kPolicyRandom = "random";

  static inline const std::string kPolicyEplisonGreedy = "epsilon_greedy";

  static inline const std::string kPolicyStrictGreedy = "strict_greedy";

  static inline const std::string kPolicyStochNBHD1 = "stoch_nbhd1";

  static inline const std::string kPolicyUCB1 = "UCB1";

  bi_tdgraph_allocator(const config::task_alloc_config* config,
                       ds::bi_tdgraph* graph,
                       rmath::rng* rng)
      : ER_CLIENT_INIT("cosm.ta.bi_tdgraph_allocator"),
        mc_config(config),
        m_graph(graph),
        m_rng(rng) {}

  bi_tdgraph_allocator(const bi_tdgraph_allocator&) = delete;
  bi_tdgraph_allocator& operator=(const bi_tdgraph_allocator&) = delete;

  polled_task* operator()(const polled_task* current_task,
                          size_t alloc_count) const;

  /* clang-format off */
  const config::task_alloc_config* mc_config;

  ds::bi_tdgraph*                  m_graph;
  rmath::rng*                      m_rng;
  /* clang-format on */
};

} /* namespace cosm::ta */