AIToolbox
A library that offers tools for AI problem solving.
AIToolbox::Factored::FactoredVector Struct Reference

This class represents a factored vector. More...

#include <AIToolbox/Factored/Utils/FactoredMatrix.hpp>

Public Member Functions

double getValue (const Factors &space, const Factors &value) const
 This function returns the value of the FactoredVector at the specified point. More...
 
double getValue (const Factors &space, const Factors &value, const Vector &weights) const
 This function returns the value of the FactoredVector multiplied by the input weights. More...
 
FactoredVectoroperator*= (const Vector &w)
 This function multiplies each basis function with a weight. More...
 
FactoredVectoroperator*= (const double v)
 This function multiplies all bases with a scalar. More...
 

Public Attributes

std::vector< BasisFunctionbases
 

Detailed Description

This class represents a factored vector.

A factored vector is a function over the whole factor space, resulting from the sum of a set of BasisFunctions. This representation turns out to be convenient as it allows to do many operations much more efficiently than if we had to represent the function explicitly.

This representation is used, for example, to represent each Qa, or Ra in factored MDPs.

Note that, in most cases, one should try to avoid duplicate BasisFunctions in here; i.e. BasisFunctions with equal tag, or where the tag of one is a strict superset of another. Such BasisFunctions can simply be merged, thus keeping the representation as simple as possible.

At the same time, sometimes duplicates are needed: for example when specifying the BasisFunctions of a factored ValueFunction. This is because usually a factored ValueFunction is composed of two components: the BasisFunctions, and a set of weight. Being able to assign separate weights to two different BasisFunctions, even if defined over the same tag, is important, so we don't completely forbid duplicates.

Member Function Documentation

◆ getValue() [1/2]

double AIToolbox::Factored::FactoredVector::getValue ( const Factors space,
const Factors value 
) const

This function returns the value of the FactoredVector at the specified point.

Parameters
spaceThe factor space to use.
valueThe value of the factor space to compute the value for.
Returns
The value of the FactoredVector at the specified point.

◆ getValue() [2/2]

double AIToolbox::Factored::FactoredVector::getValue ( const Factors space,
const Factors value,
const Vector weights 
) const

This function returns the value of the FactoredVector multiplied by the input weights.

Note that if the weights contain an additional element, it will be added to the value as a constant basis.

Parameters
spaceThe factor space to use.
valueThe value of the factor space to compute the value for.
weightsThe weights to multiply the bases with, with an optional constant basis.
Returns
The value of the FactoredVector at the specified point.

◆ operator*=() [1/2]

FactoredVector& AIToolbox::Factored::FactoredVector::operator*= ( const double  v)

This function multiplies all bases with a scalar.

Parameters
vThe scalar to multiply with.
Returns
A reference to this FactoredVector.

◆ operator*=() [2/2]

FactoredVector& AIToolbox::Factored::FactoredVector::operator*= ( const Vector w)

This function multiplies each basis function with a weight.

The input Vector must have the same number of elements as the number of bases in this FactoredVector, or one optional more.

Each basis is multiplied by its respective scalar. If an additional weight is present in the input, it is divided by the number of bases and added to each of them. Note that if the FactoredVector contains duplicate tags this is probably not what you want!!

Parameters
wThe weights to multiply with.
Returns
A reference to this FactoredVector.

Member Data Documentation

◆ bases

std::vector<BasisFunction> AIToolbox::Factored::FactoredVector::bases

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