AIToolbox
A library that offers tools for AI problem solving.
AIToolbox::Factored::Bandit::QGreedyPolicy< Maximizer > Class Template Reference

This class implements a greedy policy through a QFunction. More...

#include <AIToolbox/Factored/Bandit/Policies/QGreedyPolicy.hpp>

Inheritance diagram for AIToolbox::Factored::Bandit::QGreedyPolicy< Maximizer >:
AIToolbox::Factored::Bandit::PolicyInterface AIToolbox::PolicyInterface< void, void, Action >

Public Member Functions

template<typename... Args>
 QGreedyPolicy (Action a, const FilterMap< QFunctionRule > &q, Args &&...args)
 Basic constructor with QFunctionRules. More...
 
template<typename... Args>
 QGreedyPolicy (Action a, const QFunction &q, Args &&...args)
 Basic constructor with QFunction. More...
 
virtual Action sampleAction () const override
 This function chooses the greediest action for state s. More...
 
virtual double getActionProbability (const Action &a) const override
 This function returns the probability of taking the specified action. More...
 
Maximizer & getMaximizer ()
 This function returns a reference to the internal maximizer. More...
 
const Maximizer & getMaximizer () const
 This function returns a reference to the internal maximizer. More...
 
const Maximizer::Graph & getGraph () const
 This function returns the currently set graph. More...
 
- Public Member Functions inherited from AIToolbox::PolicyInterface< void, void, Action >
 PolicyInterface (Action a)
 Basic constructor. More...
 
virtual ~PolicyInterface ()
 Basic virtual destructor. More...
 
virtual double getActionProbability (const Action &a) const =0
 This function returns the probability of taking the specified action. More...
 
const Action & getA () const
 This function returns the number of available actions to the agent. More...
 

Additional Inherited Members

- Public Types inherited from AIToolbox::Factored::Bandit::PolicyInterface
using Base = AIToolbox::PolicyInterface< void, void, Action >
 
- Protected Attributes inherited from AIToolbox::PolicyInterface< void, void, Action >
Action A
 
RandomEngine rand_
 

Detailed Description

template<typename Maximizer = VariableElimination>
class AIToolbox::Factored::Bandit::QGreedyPolicy< Maximizer >

This class implements a greedy policy through a QFunction.

This class allows you to select effortlessly the best greedy actions from a given list of QFunctionRules. In order to compute the best action, or a given action probability the QGreedyPolicy must run VariableElimination on the stored rules, so the process can get a bit expensive.

Constructor & Destructor Documentation

◆ QGreedyPolicy() [1/2]

template<typename Maximizer >
template<typename... Args>
AIToolbox::Factored::Bandit::QGreedyPolicy< Maximizer >::QGreedyPolicy ( Action  a,
const FilterMap< QFunctionRule > &  q,
Args &&...  args 
)

Basic constructor with QFunctionRules.

Parameters
aThe number of actions available to the agent.
qThe QFunctionRules this policy is linked with.
...argsParameters to pass to the maximizer on construction.

◆ QGreedyPolicy() [2/2]

template<typename Maximizer >
template<typename... Args>
AIToolbox::Factored::Bandit::QGreedyPolicy< Maximizer >::QGreedyPolicy ( Action  a,
const QFunction q,
Args &&...  args 
)

Basic constructor with QFunction.

Parameters
aThe number of actions available to the agent.
qThe QFunction this policy is linked with.
...argsParameters to pass to the maximizer on construction.

Member Function Documentation

◆ getActionProbability()

template<typename Maximizer >
double AIToolbox::Factored::Bandit::QGreedyPolicy< Maximizer >::getActionProbability ( const Action a) const
overridevirtual

This function returns the probability of taking the specified action.

Parameters
aThe selected action.
Returns
This function returns 1 if a is equal to the greediest action, and 0 otherwise.

◆ getGraph()

template<typename Maximizer >
const Maximizer::Graph & AIToolbox::Factored::Bandit::QGreedyPolicy< Maximizer >::getGraph

This function returns the currently set graph.

◆ getMaximizer() [1/2]

template<typename Maximizer >
const Maximizer & AIToolbox::Factored::Bandit::QGreedyPolicy< Maximizer >::getMaximizer

This function returns a reference to the internal maximizer.

This can be used to set the parameters of the chosen maximizer.

◆ getMaximizer() [2/2]

template<typename Maximizer = VariableElimination>
const Maximizer& AIToolbox::Factored::Bandit::QGreedyPolicy< Maximizer >::getMaximizer ( ) const

This function returns a reference to the internal maximizer.

◆ sampleAction()

template<typename Maximizer >
Action AIToolbox::Factored::Bandit::QGreedyPolicy< Maximizer >::sampleAction
overridevirtual

This function chooses the greediest action for state s.

Returns
The chosen action.

Implements AIToolbox::PolicyInterface< void, void, Action >.


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