jubatus_core  0.1.2
Jubatus: Online machine learning framework for distributed environment
bandit.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_DRIVER_BANDIT_HPP_
18 #define JUBATUS_CORE_DRIVER_BANDIT_HPP_
19 
20 #include <map>
21 #include <string>
22 #include <vector>
23 #include "jubatus/util/lang/shared_ptr.h"
24 #include "../bandit/bandit_base.hpp"
25 #include "../common/jsonconfig.hpp"
26 #include "../framework/mixable.hpp"
27 #include "../framework/mixable_helper.hpp"
28 #include "driver.hpp"
29 
30 namespace jubatus {
31 namespace core {
32 namespace driver {
33 
34 class bandit : public driver_base {
35  public:
37 
38  bandit(const std::string& method_name,
39  const common::jsonconfig::config& param);
40 
41  bool register_arm(const std::string& arm_id);
42  bool delete_arm(const std::string& arm_id);
43 
44  std::string select_arm(const std::string& player_id);
45 
46  bool register_reward(const std::string& player_id,
47  const std::string& arm_id,
48  double reward);
49 
51  const std::string& player_id) const;
52 
53  bool reset(const std::string& player_id);
54 
55  void clear();
56  void pack(framework::packer& pk) const;
57  void unpack(msgpack::object o);
58 
59  private:
60  jubatus::util::lang::shared_ptr<bandit_base> bandit_;
63 };
64 
65 } // namespace driver
66 } // namespace core
67 } // namespace jubatus
68 
69 #endif // JUBATUS_CORE_DRIVER_BANDIT_HPP_
framework::linear_mixable_helper< bandit_base, bandit_base::diff_t > mixable_storage_
Definition: bandit.hpp:62
bool register_arm(const std::string &arm_id)
Definition: bandit.cpp:40
void unpack(msgpack::object o)
Definition: bandit.cpp:72
core::bandit::arm_info_map get_arm_info(const std::string &player_id) const
Definition: bandit.cpp:57
core::bandit::bandit_base bandit_base
Definition: bandit.hpp:36
bool register_reward(const std::string &player_id, const std::string &arm_id, double reward)
Definition: bandit.cpp:51
void pack(framework::packer &pk) const
Definition: bandit.cpp:69
jubatus::util::data::unordered_map< std::string, arm_info_map > diff_t
Definition: bandit_base.hpp:65
std::string select_arm(const std::string &player_id)
Definition: bandit.cpp:47
jubatus::util::data::unordered_map< std::string, arm_info > arm_info_map
Definition: arm_info.hpp:36
bandit(const std::string &method_name, const common::jsonconfig::config &param)
Definition: bandit.cpp:33
bool delete_arm(const std::string &arm_id)
Definition: bandit.cpp:43
bool reset(const std::string &player_id)
Definition: bandit.cpp:62
jubatus::util::lang::shared_ptr< bandit_base > bandit_
Definition: bandit.hpp:60