jubatus_core  0.1.2
Jubatus: Online machine learning framework for distributed environment
bandit_base.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_BANDIT_BASE_HPP_
18 #define JUBATUS_CORE_BANDIT_BANDIT_BASE_HPP_
19 
20 #include <string>
21 
22 #include "arm_info.hpp"
23 
24 namespace msgpack {
25 template <typename T>
26 class packer;
27 } // namespace msgpack
28 namespace jubatus {
29 namespace core {
30 namespace framework {
33 } // namespace framework
34 namespace storage {
35 class version;
36 } // namespace storage
37 namespace bandit {
38 
39 class bandit_base {
40  public:
42  }
43  virtual ~bandit_base() {
44  }
45 
46  virtual bool register_arm(const std::string& arm_id) = 0;
47  virtual bool delete_arm(const std::string& arm_id) = 0;
48 
49  virtual std::string select_arm(const std::string& player_id) = 0;
50 
51  virtual bool register_reward(const std::string& player_id,
52  const std::string& arm_id,
53  double reward) = 0;
54 
55  virtual arm_info_map get_arm_info(const std::string& player_id) const = 0;
56 
57  virtual bool reset(const std::string& player_id) = 0;
58  virtual void clear() = 0;
59 
60  virtual std::string name() const = 0;
61 
62  virtual void pack(framework::packer& pk) const = 0;
63  virtual void unpack(msgpack::object o) = 0;
64 
65  typedef jubatus::util::data::unordered_map<std::string, arm_info_map> diff_t;
66 
67  virtual void get_diff(diff_t& diff) const = 0;
68  virtual bool put_diff(const diff_t& diff) = 0;
69  virtual void mix(const diff_t& lhs, diff_t& rhs) const = 0;
70 
71  virtual core::storage::version get_version() const = 0;
72 };
73 
74 } // namespace bandit
75 } // namespace core
76 } // namespace jubatus
77 
78 #endif // JUBATUS_CORE_BANDIT_BANDIT_BASE_HPP_
virtual bool register_reward(const std::string &player_id, const std::string &arm_id, double reward)=0
virtual arm_info_map get_arm_info(const std::string &player_id) const =0
virtual bool reset(const std::string &player_id)=0
virtual core::storage::version get_version() const =0
virtual void pack(framework::packer &pk) const =0
virtual bool delete_arm(const std::string &arm_id)=0
virtual void unpack(msgpack::object o)=0
jubatus::util::data::unordered_map< std::string, arm_info_map > diff_t
Definition: bandit_base.hpp:65
msgpack::packer< jubatus_packer > packer
Definition: bandit_base.hpp:31
jubatus::util::data::unordered_map< std::string, arm_info > arm_info_map
Definition: arm_info.hpp:36
virtual std::string name() const =0
virtual void mix(const diff_t &lhs, diff_t &rhs) const =0
virtual bool put_diff(const diff_t &diff)=0
virtual std::string select_arm(const std::string &player_id)=0
virtual bool register_arm(const std::string &arm_id)=0
virtual void get_diff(diff_t &diff) const =0