Reinforcement Learning  1.1
ranking_response.h
Go to the documentation of this file.
1 
9 #pragma once
10 #include "container_iterator.h"
11 #include "slot_ranking.h"
12 
13 #include <cstddef>
14 #include <iterator>
15 #include <string>
16 #include <vector>
17 
18 namespace reinforcement_learning
19 {
20 class api_status;
21 
29 {
30 private:
31  std::string _model_id;
32  slot_ranking _slot_impl;
33 
34 public:
35  ranking_response() = default;
36  ~ranking_response() = default;
37 
44  ranking_response(char const* event_id);
45 
51  const char* get_event_id() const;
52 
57  void set_event_id(const char* event_id);
58 
67  size_t& action_id, api_status* status = nullptr) const; // id of the top action chosen by the model
68 
76  int set_chosen_action_id(size_t action_id, api_status* status = nullptr); // id of the top action chosen by the model
77 
86  int set_chosen_action_id_unchecked(size_t action_id, api_status* status = nullptr);
87 
94  void push_back(const size_t action_id, const float prob);
95 
101  size_t size() const;
102 
109  void set_model_id(const char* model_id);
110 
118  void set_model_id(std::string&& model_id);
119 
126  const char* get_model_id() const;
127 
132  void clear();
133 
139 
145  ranking_response& operator=(ranking_response&&) noexcept;
146 
151 
155  ranking_response& operator=(const ranking_response&) = delete;
156 
157 public:
158  using iterator = slot_ranking::iterator;
159  using const_iterator = slot_ranking::const_iterator;
160 
162  const_iterator begin() const;
163  iterator begin();
164 
166  const_iterator end() const;
167  iterator end();
168 };
169 } // namespace reinforcement_learning
Report status of all API calls.
Definition: api_status.h:22
choose_rank() returns the action choice using ranking_response. ranking_response contains all the act...
Definition: ranking_response.h:29
void clear()
Clear the ranking response object so that it can be reused. The goal is to reuse response without rea...
const_iterator begin() const
Returns an iterator pointing to the first element of the (action, probability) collection.
size_t size() const
Size of the action collection.
ranking_response(char const *event_id)
Construct a new ranking response object.
const char * get_model_id() const
Get the model_id. Every rank call (single or multi slot) is associated with a unique model used to pr...
void set_event_id(const char *event_id)
Set the event_id. (This is set internally by the API)
int set_chosen_action_id(size_t action_id, api_status *status=nullptr)
Set the chosen action id. (This is set internally by the API)
void push_back(const size_t action_id, const float prob)
Add (action id, probability) pair to the slot (This is set internally by the API)
void set_model_id(std::string &&model_id)
Set the model_id. Every rank call is associated with a unique model used to predict....
ranking_response(ranking_response &&) noexcept
Move construct a new ranking response object. The underlying data is taken from the rvalue reference.
int get_chosen_action_id(size_t &action_id, api_status *status=nullptr) const
Get the chosen action id.
const_iterator end() const
Returns an iterator referring to the past-the-end element of the (action, probability) collection.
int set_chosen_action_id_unchecked(size_t action_id, api_status *status=nullptr)
Set the chosen action id, but do not verify the index fits within the ranking. (This is set internall...
void set_model_id(const char *model_id)
Set the model_id. Every rank call is associated with a unique model used to predict....
const char * get_event_id() const
Unique event_id for this ranking request. This event_id must be used when calling report_outcome so i...
[Error Generator]
Definition: live_model.h:25