Class sdm::ValueFunction

Class List > sdm > ValueFunction

This class is the abstract class of value function. All value function must derived this class. More...

  • #include <value_function.hpp>

Inherits the following classes: sdm::BaseValueFunction, sdm::BinaryFunction

Inherited by the following classes: sdm::BaseTabularValueFunction, sdm::HyperplanValueFunction

Public Types inherited from sdm::BinaryFunction

See sdm::BinaryFunction

Type Name
typedef std::pair< TInput1, TInput2 > input_type
typedef TOutput output_type

Public Types inherited from sdm::Function

See sdm::Function

Type Name
typedef TInput input_type
typedef TOutput output_type

Public Attributes

Type Name
std::shared_ptr< BackupInterfaceForValueFunction > backup_
The backup operator.
double time_get_value_at = = 0
double time_pruning = =0
double time_update_value = =0
double total_time_evaluate = =0
double total_time_exist = =0
double total_time_update_backup = =0
double total_time_update_best_action = =0

Public Functions

Type Name
void StartTime ()
ValueFunction ()
ValueFunction (number horizon=0, const std::shared_ptr< Initializer > & intializer=nullptr, const std::shared_ptr< BackupInterfaceForValueFunction > & backup=nullptr, const std::shared_ptr< ActionVFInterface > & action=nullptr)
Construct a new Incremental Value Function object.
ValueFunction (const ValueFunction & copy)
TData backup (const std::shared_ptr< State > & state, const std::shared_ptr< Action > & action, number t)
Do the backup operator.
virtual void do_pruning (number t) = 0
virtual Pair< std::shared_ptr< State >, double > evaluate (const std::shared_ptr< State > & state, number t) = 0
Evaluate the element given.
std::shared_ptr< Action > getBestAction (const std::shared_ptr< State > & state, number t)
Select the best Action for a precise state and a time step.
Pair< std::shared_ptr< Action >, double > getBestActionAndValue (const std::shared_ptr< State > & state, number t)
Select the best Action and the value associated for a precise state and a time step.
std::shared_ptr< BinaryFunction< std::shared_ptr< State >, number, double > > getInitFunction ()
Get the Init Function .
virtual size_t getSize (number t) const = 0
Get the size of the value function at timestep t.
size_t getSize () const
Get the total size of the value function.
virtual std::vector< std::shared_ptr< State > > getSupport (number t) = 0
Return the possible indexes of the value function.
double getTime (std::string information)
virtual double getValueAt (const std::shared_ptr< State > & state, number t=0) = 0
Get the value at a given state.
std::shared_ptr< ValueFunction > getptr ()
Get shared pointer on the current QValueFunction .
virtual void initialize () = 0
Initialize the value function.
virtual void initialize (double v, number t=0) = 0
Initialize the value function with a default value.
void initialize (const std::shared_ptr< BinaryFunction< std::shared_ptr< State >, number, double >> & init_function)
Set a function as a interactive way to get initial values for state that are not already initialized.
virtual double operator() (const std::shared_ptr< State > & state, const number & t=0)
virtual std::string str () const = 0
Define this function in order to be able to display the value function.
void updateTime (std::chrono::high_resolution_clock::time_point start_time, std::string information)
virtual void updateValueAt (const std::shared_ptr< State > & state, number t=0) = 0
Update the value at a given state.
virtual void updateValueAt (const std::shared_ptr< State > & state, const std::shared_ptr< Action > & action, number t=0) = 0
Update the value at a given state knowing an action.
virtual ~ValueFunction ()
Destroy the value function.

Public Functions inherited from sdm::BaseValueFunction

See sdm::BaseValueFunction

Type Name
BaseValueFunction ()
BaseValueFunction (number horizon)
BaseValueFunction (const BaseValueFunction & copy)
virtual std::shared_ptr< Action > getBestAction (const TInput & input, number t) = 0
Get the best action to do at a state.
number getHorizon () const
virtual double getValueAt (const TInput & input, number t=0) = 0
Get the value at a given state.
std::shared_ptr< BaseValueFunction< TInput > > getptr ()
Get a shared pointer on the current object.
virtual void initialize () = 0
Initialize the value function.
virtual void initialize (double v, number t=0) = 0
Initialize the value function with a default value.
bool isFiniteHorizon () const
bool isInfiniteHorizon () const
virtual void load (std::string)
Load a value function from a file. The extension of the file will indicate the type of formatage for reading ( .txt = text format, '.xml' = XML format, other = binary format).
virtual void save (std::string)
Save a value function into a file. The extension of the file will indicate the type of formatage for recording ( .txt = text format, '.xml' = XML format, other = binary format).
virtual std::string str () const = 0
Define this function in order to be able to display the value function.
virtual void updateValueAt (const TInput & input, number t=0) = 0
Get the q-value at a state.
virtual ~BaseValueFunction ()
Destroy the value function.

Public Functions inherited from sdm::BinaryFunction

See sdm::BinaryFunction

Type Name
virtual output_type operator() (const TInput1 &, const TInput2 &) = 0
virtual output_type operator() (const input_type & p_input)
virtual ~BinaryFunction ()

Public Functions inherited from sdm::Function

See sdm::Function

Type Name
virtual output_type operator() (const input_type &) = 0
virtual ~Function ()

Protected Attributes

Type Name
std::shared_ptr< ActionVFInterface > action_
The evaluate operator.
std::shared_ptr< BinaryFunction< std::shared_ptr< State >, number, double > > init_function_ = = nullptr
Initialization function. If defined, algorithms on value functions will get inital values using this function.
std::shared_ptr< Initializer > initializer_
The initializer to use for this value function.

Protected Attributes inherited from sdm::BaseValueFunction

See sdm::BaseValueFunction

Type Name
number horizon_
The horizon for planning/learning.

Detailed Description

Template parameters:

  • std::shared_ptr<State> Type of the state.
  • std::shared_ptr<Action> Type of the action.
  • double Type of the value.

Public Attributes Documentation

variable backup_

std::shared_ptr<BackupInterfaceForValueFunction> sdm::ValueFunction::backup_;

variable time_get_value_at

double sdm::ValueFunction::time_get_value_at;

variable time_pruning

double sdm::ValueFunction::time_pruning;

variable time_update_value

double sdm::ValueFunction::time_update_value;

variable total_time_evaluate

double sdm::ValueFunction::total_time_evaluate;

variable total_time_exist

double sdm::ValueFunction::total_time_exist;

variable total_time_update_backup

double sdm::ValueFunction::total_time_update_backup;

variable total_time_update_best_action

double sdm::ValueFunction::total_time_update_best_action;

Public Functions Documentation

function StartTime

void sdm::ValueFunction::StartTime () 

function ValueFunction [1/3]

inline sdm::ValueFunction::ValueFunction () 

function ValueFunction [2/3]

sdm::ValueFunction::ValueFunction (
    number horizon=0,
    const std::shared_ptr< Initializer > & intializer=nullptr,
    const std::shared_ptr< BackupInterfaceForValueFunction > & backup=nullptr,
    const std::shared_ptr< ActionVFInterface > & action=nullptr
) 

Parameters:

  • backup
  • default_value

function ValueFunction [3/3]

sdm::ValueFunction::ValueFunction (
    const ValueFunction & copy
) 

function backup

template<typename TData typename TData>
inline TData sdm::ValueFunction::backup (
    const std::shared_ptr< State > & state,
    const std::shared_ptr< Action > & action,
    number t
) 

Parameters:

  • state : ELement to evaluate
  • t

Returns:

Pair<std::shared_ptr<State>, double>

function do_pruning

virtual void sdm::ValueFunction::do_pruning (
    number t
) = 0

function evaluate

virtual Pair < std::shared_ptr< State >, double > sdm::ValueFunction::evaluate (
    const std::shared_ptr< State > & state,
    number t
) = 0

Parameters:

  • state : ELement to evaluate
  • t

Returns:

Pair<std::shared_ptr<State>, double>

function getBestAction

std::shared_ptr< Action > sdm::ValueFunction::getBestAction (
    const std::shared_ptr< State > & state,
    number t
) 

Parameters:

  • const std::shared_ptr<State> & : current state
  • number : time step

Returns:

std::shared_ptr<Action>

function getBestActionAndValue

Pair < std::shared_ptr< Action >, double > sdm::ValueFunction::getBestActionAndValue (
    const std::shared_ptr< State > & state,
    number t
) 

Parameters:

  • const std::shared_ptr<State> & : current state
  • number : time step

Returns:

std::shared_ptr<Action>

function getInitFunction

std::shared_ptr< BinaryFunction < std::shared_ptr< State >, number , double > > sdm::ValueFunction::getInitFunction () 

Returns:

std::shared_ptr<BinaryFunction<std::shared_ptr<State>, number, double>>

function getSize [1/2]

virtual size_t sdm::ValueFunction::getSize (
    number t
) const = 0

function getSize [2/2]

size_t sdm::ValueFunction::getSize () const

function getSupport

virtual std::vector< std::shared_ptr< State > > sdm::ValueFunction::getSupport (
    number t
) = 0

Returns:

std::string

function getTime

double sdm::ValueFunction::getTime (
    std::string information
) 

function getValueAt

virtual double sdm::ValueFunction::getValueAt (
    const std::shared_ptr< State > & state,
    number t=0
) = 0

function getptr

std::shared_ptr< ValueFunction > sdm::ValueFunction::getptr () 

function initialize [1/3]

virtual void sdm::ValueFunction::initialize () = 0

Implements sdm::BaseValueFunction::initialize

function initialize [2/3]

virtual void sdm::ValueFunction::initialize (
    double v,
    number t=0
) = 0

Implements sdm::BaseValueFunction::initialize

function initialize [3/3]

void sdm::ValueFunction::initialize (
    const std::shared_ptr< BinaryFunction < std::shared_ptr< State >, number , double >> & init_function
) 

Parameters:

  • init_function the function that enables to get initial values

function operator()

virtual double sdm::ValueFunction::operator() (
    const std::shared_ptr< State > & state,
    const number & t=0
) 

Implements sdm::BinaryFunction::operator()

function str

virtual std::string sdm::ValueFunction::str () const = 0

Implements sdm::BaseValueFunction::str

function updateTime

void sdm::ValueFunction::updateTime (
    std::chrono::high_resolution_clock::time_point start_time,
    std::string information
) 

function updateValueAt [1/2]

virtual void sdm::ValueFunction::updateValueAt (
    const std::shared_ptr< State > & state,
    number t=0
) = 0

function updateValueAt [2/2]

virtual void sdm::ValueFunction::updateValueAt (
    const std::shared_ptr< State > & state,
    const std::shared_ptr< Action > & action,
    number t=0
) = 0

function ~ValueFunction

inline virtual sdm::ValueFunction::~ValueFunction () 

Protected Attributes Documentation

variable action_

std::shared_ptr<ActionVFInterface> sdm::ValueFunction::action_;

The action operator.

variable init_function_

std::shared_ptr<BinaryFunction<std::shared_ptr<State>, number, double> > sdm::ValueFunction::init_function_;

variable initializer_

std::shared_ptr<Initializer> sdm::ValueFunction::initializer_;

The documentation for this class was generated from the following file src/sdm/utils/value_function/value_function.hpp