jubatus_core  0.1.2
Jubatus: Online machine learning framework for distributed environment
summation_storage.hpp
Go to the documentation of this file.
1 // Jubatus: Online machine learning framework for distributed environment
2 // Copyright (C) 2015 Preferred Networks and Nippon Telegraph and Telephone Corporation.
3 //
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License version 2.1 as published by the Free Software Foundation.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 
17 #ifndef JUBATUS_CORE_BANDIT_SUMMATION_STORAGE_HPP_
18 #define JUBATUS_CORE_BANDIT_SUMMATION_STORAGE_HPP_
19 
20 #include <string>
21 #include <vector>
22 
23 #include "bandit_base.hpp"
24 
25 namespace jubatus {
26 namespace core {
27 namespace bandit {
28 
30  public:
32 
33  explicit summation_storage(bool assume_unrewarded);
34 
35  bool register_arm(const std::string& arm_id);
36  bool delete_arm(const std::string& arm_id);
37 
38  void notify_selected(const std::string& player_id,
39  const std::string& arm_id);
40  bool register_reward(const std::string& player_id,
41  const std::string& arm_id,
42  double reward);
43 
44  arm_info get_arm_info(const std::string& player_id,
45  const std::string& arm_id) const;
46  double get_expectation(const std::string& player_id,
47  const std::string& arm_id) const;
48 
49  const std::vector<std::string>& get_arm_ids() const {
50  return arm_ids_;
51  }
52  arm_info_map get_arm_info_map(const std::string& player_id) const;
53 
54  void get_diff(table_t& diff) const;
55  bool put_diff(const table_t& diff);
56  static void mix(const table_t& lhs, table_t& rhs);
57 
58  bool reset(const std::string& player_id);
59  void clear();
60 
62 
63  private:
64  const bool assume_unrewarded_;
65  std::vector<std::string> arm_ids_;
66  table_t mixed_, unmixed_;
67 };
68 
69 } // namespace bandit
70 } // namespace core
71 } // namespace jubatus
72 
73 #endif // JUBATUS_CORE_BANDIT_SUMMATION_STORAGE_HPP_
bool reset(const std::string &player_id)
MSGPACK_DEFINE(arm_ids_, mixed_, unmixed_)
bool register_reward(const std::string &player_id, const std::string &arm_id, double reward)
jubatus::util::data::unordered_map< std::string, arm_info_map > diff_t
Definition: bandit_base.hpp:65
double get_expectation(const std::string &player_id, const std::string &arm_id) const
const std::vector< std::string > & get_arm_ids() const
void notify_selected(const std::string &player_id, const std::string &arm_id)
bool register_arm(const std::string &arm_id)
jubatus::util::data::unordered_map< std::string, arm_info > arm_info_map
Definition: arm_info.hpp:36
static void mix(const table_t &lhs, table_t &rhs)
arm_info get_arm_info(const std::string &player_id, const std::string &arm_id) const
arm_info_map get_arm_info_map(const std::string &player_id) const
bool delete_arm(const std::string &arm_id)