|
AIToolbox
A library that offers tools for AI problem solving.
|
This class enumerates the indeces of all combinations where a value is fixed. More...
#include <AIToolbox/Factored/Utils/Core.hpp>
Public Member Functions | |
| PartialIndexEnumerator (const Factors &F, size_t fixedFactor, size_t val) | |
| Basic constructor. More... | |
| PartialIndexEnumerator (const Factors &F, const PartialKeys &factors, size_t fixedFactor, size_t val, bool missing=false) | |
| Basic constructor. More... | |
| size_t | operator* () const |
| This operator returns the current index. More... | |
| void | advance () |
| This function advances the PartialFactorsEnumerator to the next index. More... | |
| bool | isValid () |
| This function returns whether it is safe to dereference the PartialFactorsEnumerator. More... | |
| void | reset () |
| This function resets the PartialIndexEnumerator to the first valid index. More... | |
This class enumerates the indeces of all combinations where a value is fixed.
This class is somewhat similar to PartialFactorsEnumerator, but handles indexes rather than full enumerations. In particular, it lists all the indeces of the enumerations of certain key-values, where a given key-value is assumed fixed.
To make a concrete example, consider the list that PartialFactorsEnumerator generates for a space of (2,3).
(0,0) -> 0 (1,0) -> 1 (0,1) -> 2 (1,1) -> 3 (0,2) -> 4 (1,2) -> 5
With the arrows we have associated an index to each combination. We can then use PartialIndexEnumerator to list all indeces where the first key is zero, which would return
[0, 2, 4].
Otherwise, we could ask the indeces where the second key is one, which would return
[2, 3]
PartialFactorsEnumerator and PartialIndexEnumerator are guaranteed to be "in sync", in the sense that the indeces returned will always correspond to the n-th element generated by the PartialFactorsEnumerator.
Note that PartialIndexEnumerator is quite efficient, as it does not need to do any allocation, and advancing the enumeration only requires a couple of simple operations.
| AIToolbox::Factored::PartialIndexEnumerator::PartialIndexEnumerator | ( | const Factors & | F, |
| size_t | fixedFactor, | ||
| size_t | val | ||
| ) |
Basic constructor.
| F | The factor space to operate on. |
| fixedFactor | The factor to consider fixed. |
| val | The value of the fixed factor. |
| AIToolbox::Factored::PartialIndexEnumerator::PartialIndexEnumerator | ( | const Factors & | F, |
| const PartialKeys & | factors, | ||
| size_t | fixedFactor, | ||
| size_t | val, | ||
| bool | missing = false |
||
| ) |
Basic constructor.
| F | The factor space to operate on. |
| factors | The factors to take into considerations. |
| fixedFactor | The factor to consider fixed. |
| val | The value of the fixed factor. |
| missing | Whether fixedFactor is already present in the input PartialKeys, or not. |
| void AIToolbox::Factored::PartialIndexEnumerator::advance | ( | ) |
This function advances the PartialFactorsEnumerator to the next index.
| bool AIToolbox::Factored::PartialIndexEnumerator::isValid | ( | ) |
This function returns whether it is safe to dereference the PartialFactorsEnumerator.
| size_t AIToolbox::Factored::PartialIndexEnumerator::operator* | ( | ) | const |
This operator returns the current index.
| void AIToolbox::Factored::PartialIndexEnumerator::reset | ( | ) |
This function resets the PartialIndexEnumerator to the first valid index.