12#include <unordered_map>
48 std::unordered_map<std::string, std::any> &&extra);
129 template <typename T> const T &
get_extra(std::
string name) const;
135 const std::unordered_map<std::
string, std::any> &
info() const noexcept {
return extra_; }
141 std::unordered_map<std::string, std::any> &
info() noexcept {
return extra_; }
167 std::unordered_map<std::string, std::any> extra_;
170template <
typename StateTp>
176template <
typename StateTp>
179 : type_(type), reward_(reward), obs_(obs), discount_(discount_factor), extra_()
183template <
typename StateTp>
185 :
TimeStep<StateTp>(type, reward, obs, 1.0)
189template <
typename StateTp>
192 std::unordered_map<std::string, std::any> &&extra)
193 : type_(type), reward_(reward), obs_(obs), discount_(discount_factor), extra_(extra)
197template <
typename StateTp>
199 : type_(other.type_), reward_(other.reward_), obs_(other.obs_), discount_(other.discount_),
204template <
typename StateTp>
209 reward_ = other.reward_;
211 discount_ = other.discount_;
212 extra_ = other.extra_;
216template <
typename StateTp>
218 : type_(other.type_), reward_(other.reward_), obs_(other.obs_), discount_(other.discount_),
224template <
typename StateTp>
229 reward_ = other.reward_;
231 discount_ = other.discount_;
232 extra_ = other.extra_;
247template <
typename StateTp>
252 auto itr = extra_.find(name);
254 if (itr == extra_.end())
256 throw std::logic_error(
"Property " + name +
" does not exist");
259 return std::any_cast<const T &>(itr->second);
262template <
typename StateTp>
267 out <<
"Reward........" << step.
reward() << std::endl;
268 out <<
"Observation..." << step.
observation() << std::endl;
269 out <<
"Discount..... " << step.
discount() << std::endl;
278 out <<
"Reward........" << step.reward() << std::endl;
280 auto obs = step.observation();
282 out <<
"Observation...";
285 out <<
"Discount..... " << step.discount() << std::endl;
Forward declaration.
Definition time_step.h:22
TimeStep(TimeStepTp type, real_t reward, const state_type &obs, real_t discount_factor, std::unordered_map< std::string, std::any > &&extra)
TimeStep. Constructor.
Definition time_step.h:190
state_type observation() const
observation
Definition time_step.h:102
bool last() const noexcept
last
Definition time_step.h:90
const std::unordered_map< std::string, std::any > & info() const noexcept
info
Definition time_step.h:135
void clear() noexcept
clear
Definition time_step.h:237
TimeStep(TimeStepTp type, real_t reward, const state_type &obs, real_t discount_factor)
TimeStep. Constructor.
Definition time_step.h:177
TimeStep(TimeStep &&other) noexcept
TimeStep.
Definition time_step.h:217
bool done() const noexcept
done
Definition time_step.h:119
real_t reward() const noexcept
reward
Definition time_step.h:108
std::unordered_map< std::string, std::any > & info() noexcept
info
Definition time_step.h:141
TimeStep & operator=(TimeStep &&other) noexcept
operator =
Definition time_step.h:225
TimeStep(TimeStepTp type, real_t reward, const state_type &obs)
TimeStep. Constructor.
Definition time_step.h:184
TimeStep & operator=(const TimeStep &other)
Assignment operator.
Definition time_step.h:205
bool mid() const noexcept
mid
Definition time_step.h:84
StateTp state_type
state_ Type of the state
Definition time_step.h:27
real_t discount() const noexcept
discount. Returns the discount factor
Definition time_step.h:113
TimeStep(const TimeStep &other)
TimeStep.
Definition time_step.h:198
bool first() const noexcept
first
Definition time_step.h:78
const T & get_extra(std::string name) const
get_extra
Definition time_step.h:249
TimeStep()
TimeStep.
Definition time_step.h:171
TimeStepTp type() const noexcept
type
Definition time_step.h:96
std::ostream & print_vector(std::ostream &out, const std::vector< T > &obs)
Definition io_utils.h:23
Definition bitrl_consts.h:14
std::ostream & operator<<(std::ostream &out, const Null &)
Definition bitrl_types.h:165
double real_t
real_t
Definition bitrl_types.h:23
TimeStepTp
The TimeStepTp enum.
Definition time_step_type.h:16
static std::string to_string(TimeStepTp type)
Definition time_step_type.cpp:37