jubatus_core  0.1.2
Jubatus: Online machine learning framework for distributed environment
burst_result.hpp
Go to the documentation of this file.
1 // Jubatus: Online machine learning framework for distributed environment
2 // Copyright (C) 2014 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_BURST_BURST_RESULT_HPP_
18 #define JUBATUS_CORE_BURST_BURST_RESULT_HPP_
19 
20 #include <stdint.h>
21 #include <algorithm> // for std::swap
22 #include <vector>
23 #include <msgpack.hpp>
24 #include "jubatus/util/lang/shared_ptr.h"
25 
26 #include "window_fwd.hpp"
27 #include "../framework/mixable_helper.hpp"
28 
29 namespace jubatus {
30 namespace core {
31 namespace burst {
32 
33 class burst_result {
34  public:
35  burst_result();
36  burst_result(const input_window& input,
37  double scaling_param,
38  double gamma,
39  double costcut_threshold,
40  const burst_result& prev_result,
41  int max_reuse_batches);
42  // for testing
43  explicit burst_result(const result_window& src);
44 
45  // copy ctor is not user-defined (uses shared_ptr's one, CoW)
46  // window(const window& x);
47 
48  void swap(burst_result& x) {
49  p_.swap(x.p_);
50  }
51  friend void swap(burst_result& x, burst_result& y) {
52  x.swap(y);
53  }
54 
55  bool is_valid() const;
56 
57  static const double invalid_pos; // = -1
58  double get_start_pos() const;
59  double get_end_pos() const;
60  bool contains(double pos) const;
61 
62  int get_batch_size() const;
63  double get_batch_interval() const;
64  double get_all_interval() const;
65 
66  // comparing start_pos
67  // floating number error is considered
68  bool has_start_pos_older_than(double start_pos) const;
69  bool has_start_pos_newer_than(double start_pos) const;
70  bool has_same_start_pos_to(double start_pos) const;
71 
72  // compares batch_interval; floating number error is allowed
73  bool has_same_batch_interval(const burst_result& x) const;
74 
75  const std::vector<batch_result>& get_batches() const;
76 
77  const batch_result& get_batch_at(double pos) const;
78  bool is_bursted_at(double pos) const;
79  bool is_bursted_at_latest_batch() const;
80 
81  bool mix(const burst_result& w);
82 
84  void msgpack_unpack(msgpack::object o);
85 
86  private:
87  jubatus::util::lang::shared_ptr<const result_window> p_;
88 };
89 
90 } // namespace burst
91 } // namespace core
92 } // namespace jubatus
93 
94 #endif // JUBATUS_CORE_BURST_BURST_RESULT_HPP_
bool mix(const burst_result &w)
bool has_same_start_pos_to(double start_pos) const
void msgpack_unpack(msgpack::object o)
bool has_same_batch_interval(const burst_result &x) const
bool contains(double pos) const
bool is_bursted_at(double pos) const
bool has_start_pos_newer_than(double start_pos) const
const std::vector< batch_result > & get_batches() const
friend void swap(burst_result &x, burst_result &y)
void msgpack_pack(framework::packer &packer) const
msgpack::packer< jubatus_packer > packer
Definition: bandit_base.hpp:31
bool has_start_pos_older_than(double start_pos) const
const batch_result & get_batch_at(double pos) const
jubatus::util::lang::shared_ptr< const result_window > p_