Reinforcement Learning  1.1
reinforcement_learning::ranking_response Class Reference

choose_rank() returns the action choice using ranking_response. ranking_response contains all the actions and distribution from with the action was sampled. It also contains the chosen action id and the unique event_id representing the choice. This unique event_id must be used to report back outcomes against this choice for the online trainer. More...

#include <ranking_response.h>

Public Types

using iterator = slot_ranking::iterator
 
using const_iterator = slot_ranking::const_iterator
 

Public Member Functions

 ranking_response (char const *event_id)
 Construct a new ranking response object. More...
 
const char * get_event_id () const
 Unique event_id for this ranking request. This event_id must be used when calling report_outcome so it can be joined with the chosen action. More...
 
void set_event_id (const char *event_id)
 Set the event_id. (This is set internally by the API) More...
 
int get_chosen_action_id (size_t &action_id, api_status *status=nullptr) const
 Get the chosen action id. More...
 
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) More...
 
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 internally by the API) This is used in CCB where subsequent ranking_responses have subsets of the orignal actionset. More...
 
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) More...
 
size_t size () const
 Size of the action collection. More...
 
void set_model_id (const char *model_id)
 Set the model_id. Every rank call is associated with a unique model used to predict. A unique model_id is associated with each unique model. (This is set internally by the API) More...
 
void set_model_id (std::string &&model_id)
 Set the model_id. Every rank call is associated with a unique model used to predict. A unique model_id is associated with each unique model. (This is set internally by the API). Input model_id is left in an unspecified but valid state. More...
 
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 predict. A unique model_id is associated with each unique model. (This is set internally by the API) More...
 
void clear ()
 Clear the ranking response object so that it can be reused. The goal is to reuse response without reallocating as much as possible.
 
 ranking_response (ranking_response &&) noexcept
 Move construct a new ranking response object. The underlying data is taken from the rvalue reference.
 
ranking_responseoperator= (ranking_response &&) noexcept
 Move assignment operator for ranking response. The underlying data is taken from rvalue reference, and then it is cleared. More...
 
 ranking_response (const ranking_response &)=delete
 Copy constructor is removed since implementation will be deleted twice.
 
ranking_responseoperator= (const ranking_response &)=delete
 assignment operator is removed since implementation will be deleted twice
 
const_iterator begin () const
 Returns an iterator pointing to the first element of the (action, probability) collection.
 
iterator begin ()
 
const_iterator end () const
 Returns an iterator referring to the past-the-end element of the (action, probability) collection.
 
iterator end ()
 

Detailed Description

choose_rank() returns the action choice using ranking_response. ranking_response contains all the actions and distribution from with the action was sampled. It also contains the chosen action id and the unique event_id representing the choice. This unique event_id must be used to report back outcomes against this choice for the online trainer.

Examples
rl_sim.cc.

Constructor & Destructor Documentation

◆ ranking_response()

reinforcement_learning::ranking_response::ranking_response ( char const *  event_id)

Construct a new ranking response object.

Parameters
event_idThe unique identifier for this interaction. This event_id must be used when reporting the outcome for this action

Member Function Documentation

◆ get_chosen_action_id()

int reinforcement_learning::ranking_response::get_chosen_action_id ( size_t &  action_id,
api_status status = nullptr 
) const

Get the chosen action id.

Parameters
action_idChosen action id
statusOptional field with detailed string description if there is an error
Returns
int Error code

◆ get_event_id()

const char* reinforcement_learning::ranking_response::get_event_id ( ) const

Unique event_id for this ranking request. This event_id must be used when calling report_outcome so it can be joined with the chosen action.

Returns
const char*

◆ get_model_id()

const char* reinforcement_learning::ranking_response::get_model_id ( ) const

Get the model_id. Every rank call (single or multi slot) is associated with a unique model used to predict. A unique model_id is associated with each unique model. (This is set internally by the API)

Returns
const char*

◆ operator=()

ranking_response& reinforcement_learning::ranking_response::operator= ( ranking_response &&  )
noexcept

Move assignment operator for ranking response. The underlying data is taken from rvalue reference, and then it is cleared.

Returns
ranking_response&

◆ push_back()

void reinforcement_learning::ranking_response::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)

Parameters
action_id
prob

◆ set_chosen_action_id()

int reinforcement_learning::ranking_response::set_chosen_action_id ( size_t  action_id,
api_status status = nullptr 
)

Set the chosen action id. (This is set internally by the API)

Parameters
action_idChosen action id
statusOptional field with detailed string description if there is an error
Returns
int Error code

◆ set_chosen_action_id_unchecked()

int reinforcement_learning::ranking_response::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 internally by the API) This is used in CCB where subsequent ranking_responses have subsets of the orignal actionset.

Parameters
action_idChosen action id
statusOptional field with detailed string description if there is an error
Returns
int Error code

◆ set_event_id()

void reinforcement_learning::ranking_response::set_event_id ( const char *  event_id)

Set the event_id. (This is set internally by the API)

Parameters
event_id

◆ set_model_id() [1/2]

void reinforcement_learning::ranking_response::set_model_id ( const char *  model_id)

Set the model_id. Every rank call is associated with a unique model used to predict. A unique model_id is associated with each unique model. (This is set internally by the API)

Parameters
model_id

◆ set_model_id() [2/2]

void reinforcement_learning::ranking_response::set_model_id ( std::string &&  model_id)

Set the model_id. Every rank call is associated with a unique model used to predict. A unique model_id is associated with each unique model. (This is set internally by the API). Input model_id is left in an unspecified but valid state.

Parameters
model_id

◆ size()

size_t reinforcement_learning::ranking_response::size ( ) const

Size of the action collection.

Returns
size_t

The documentation for this class was generated from the following file: