jubatus_core  0.1.2
Jubatus: Online machine learning framework for distributed environment
bandit.cpp
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 #include "bandit.hpp"
18 
19 #include <map>
20 #include <string>
21 #include <utility>
22 #include <vector>
23 
24 #include "../bandit/bandit_factory.hpp"
25 
26 using jubatus::util::lang::shared_ptr;
28 
29 namespace jubatus {
30 namespace core {
31 namespace driver {
32 
33 bandit::bandit(const std::string& method_name,
34  const common::jsonconfig::config& param)
35  : bandit_(bandit_factory::create(method_name, param)),
36  mixable_storage_(bandit_) {
38 }
39 
40 bool bandit::register_arm(const std::string& arm_id) {
41  return bandit_->register_arm(arm_id);
42 }
43 bool bandit::delete_arm(const std::string& arm_id) {
44  return bandit_->delete_arm(arm_id);
45 }
46 
47 std::string bandit::select_arm(const std::string& player_id) {
48  return bandit_->select_arm(player_id);
49 }
50 
51 bool bandit::register_reward(const std::string& player_id,
52  const std::string& arm_id,
53  double reward) {
54  return bandit_->register_reward(player_id, arm_id, reward);
55 }
56 
58  const std::string& player_id) const {
59  return bandit_->get_arm_info(player_id);
60 }
61 
62 bool bandit::reset(const std::string& player_id) {
63  return bandit_->reset(player_id);
64 }
65 
66 void bandit::clear() {
67  bandit_->clear();
68 }
70  bandit_->pack(pk);
71 }
72 void bandit::unpack(msgpack::object o) {
73  bandit_->unpack(o);
74 }
75 
76 } // namespace driver
77 } // namespace core
78 } // namespace jubatus
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
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
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
void register_mixable(framework::mixable *mixable)
Definition: driver.cpp:242