jubatus_core  0.1.2
Jubatus: Online machine learning framework for distributed environment
ucb1.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_UCB1_HPP_
18 #define JUBATUS_CORE_BANDIT_UCB1_HPP_
19 
20 #include <string>
21 
22 #include "bandit_base.hpp"
23 #include "summation_storage.hpp"
24 
25 namespace jubatus {
26 namespace core {
27 namespace bandit {
28 
29 class ucb1 : public bandit_base {
30  public:
31  explicit ucb1(bool assume_unrewarded);
32 
33  std::string select_arm(const std::string& player_id);
34 
35  bool register_arm(const std::string& arm_id);
36  bool delete_arm(const std::string& arm_id);
37 
38  bool register_reward(const std::string& player_id,
39  const std::string& arm_id,
40  double reward);
41 
42  arm_info_map get_arm_info(const std::string& player_id) const;
43 
44  bool reset(const std::string& player_id);
45  void clear();
46 
47  std::string name() const {
48  return "ucb1";
49  }
50 
51  void pack(framework::packer& pk) const;
52  void unpack(msgpack::object o);
53 
54  void get_diff(diff_t& diff) const;
55  bool put_diff(const diff_t& diff);
56  void mix(const diff_t& lhs, diff_t& rhs) const;
58 
59  private:
61 };
62 
63 } // namespace bandit
64 } // namespace core
65 } // namespace jubatus
66 
67 #endif // JUBATUS_CORE_BANDIT_UCB1_HPP_
std::string name() const
Definition: ucb1.hpp:47
void unpack(msgpack::object o)
Definition: ucb1.cpp:93
bool delete_arm(const std::string &arm_id)
Definition: ucb1.cpp:69
storage::version get_version() const
Definition: ucb1.cpp:106
bool put_diff(const diff_t &diff)
Definition: ucb1.cpp:100
ucb1(bool assume_unrewarded)
Definition: ucb1.cpp:30
arm_info_map get_arm_info(const std::string &player_id) const
Definition: ucb1.cpp:79
std::string select_arm(const std::string &player_id)
Definition: ucb1.cpp:34
bool register_reward(const std::string &player_id, const std::string &arm_id, double reward)
Definition: ucb1.cpp:73
jubatus::util::data::unordered_map< std::string, arm_info_map > diff_t
Definition: bandit_base.hpp:65
bool reset(const std::string &player_id)
Definition: ucb1.cpp:83
jubatus::util::data::unordered_map< std::string, arm_info > arm_info_map
Definition: arm_info.hpp:36
void get_diff(diff_t &diff) const
Definition: ucb1.cpp:97
void mix(const diff_t &lhs, diff_t &rhs) const
Definition: ucb1.cpp:103
summation_storage s_
Definition: ucb1.hpp:60
void pack(framework::packer &pk) const
Definition: ucb1.cpp:90
bool register_arm(const std::string &arm_id)
Definition: ucb1.cpp:66