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