|
bitrl & cuberl Documentation
Simulation engine for reinforcement learning agents
|
Namespaces | |
| namespace | detail_ |
| namespace | optim |
Classes | |
| class | LpMetric |
| The LpMetric class It conforms to the metric policy. More... | |
Typedefs | |
| using | ManhattanMetric = LpMetric< 1, false > |
| some useful shortcuts | |
| using | SqrEuclidean_metric = LpMetric< 2, false > |
| using | EuclideanMetric = LpMetric< 2, true > |
Functions | |
| template<typename MatType > | |
| void | exchange_rows (MatType &mat, uint_t r1, uint_t r2) |
| Exchange the rows of the matrix. | |
| template<typename MatType > | |
| std::set< uint_t > | shuffle_matrix_rows (MatType &mat) |
| Shuffle the rows of the matrix. Returns a set with the rows that have been shuffled. | |
| template<typename T > | |
| DynVec< T > | get_row (const DynMat< T > &matrix, uint_t row_idx) |
| Extract the cidx-th column from the matrix. | |
| template<typename T > | |
| T | get_row_max (const DynMat< T > &matrix, uint_t row_idx) |
| template<typename T > | |
| T | get_row_min (const DynMat< T > &matrix, uint_t row_idx) |
| template<utils::concepts::float_or_integral_vector VectorType> | |
| VectorType | element_product (const VectorType &v1, const VectorType &v2) |
| template<typename IteratorType > | |
| std::iterator_traits< IteratorType >::value_type | sum (IteratorType begin, IteratorType end, bool parallel=true) |
| template<typename VectorType > | |
| VectorType::value_type | sum (const VectorType &vec, bool parallel=true) |
| template<typename IteratorType > | |
| real_t | mean (IteratorType begin, IteratorType end, bool parallel=true) |
| mean Compute the mean value of the values in the provided iterator range | |
| template<utils::concepts::float_or_integral_vector VectorType> | |
| real_t | mean (const VectorType &vector, bool parallel=true) |
| mean Computes the mean value of the vector. If parallel=true it uses std::reduce | |
| template<typename T > | |
| real_t | mean (const DynVec< T > &vector, bool parallel=true) |
| mean computes the mean value of the given DynVec | |
| template<typename IteratorType > | |
| std::iterator_traits< IteratorType >::value_type | variance (IteratorType begin, IteratorType end, bool parallel=true) |
| real_t | variance (const std::vector< real_t > &vals, bool parallel=true) |
| Compute the variance of the given std::vector of real values. | |
| std::vector< real_t > | standardize (const std::vector< real_t > &vals, real_t tol=bitrl::consts::TOLERANCE) |
| Standardize the given vector. | |
| template<utils::concepts::float_vector Vec2> | |
| uint_t | choice (const Vec2 &probs, uint_t seed=42) |
| choice. Implements similar functionality to numpy.choice function | |
| template<utils::concepts::integral_vector Vec1, utils::concepts::float_vector Vec2> | |
| uint_t | choice (const Vec1 &choices, const Vec2 &probs, uint_t seed=42) |
| choice. Implements similar functionality to numpy.choice function | |
| template<utils::concepts::float_vector Vec> | |
| Vec::value_type | choose_value (const Vec &vals, uint_t seed=42) |
| template<utils::concepts::float_or_integral_vector Vec> | |
| void | randomize_vec (Vec &v, const Vec &walk_set, uint_t seed=42) |
| Given a vector of intergal or floating point values and a set of values to choose from, randomize the entries ofv. | |
| template<typename T > | |
| std::vector< T > & | randomize (std::vector< T > &vec, T a, T b, uint_t seed=42) |
| Fill in the given vector with random values. | |
| template<utils::concepts::float_or_integral_vector Vec> | |
| Vec & | divide (Vec &v1, typename Vec::value_type val) |
| template<utils::concepts::float_or_integral_vector Vec> | |
| Vec & | add (Vec &v1, const Vec &v2) |
| template<utils::concepts::float_or_integral_vector VectorType> | |
| VectorType | exponentiate (const VectorType &vec) |
| template<utils::concepts::float_or_integral_vector VectorType> | |
| VectorType | exponentiate (const VectorType &vec, typename VectorType::value_type v) |
| template<typename T > | |
| std::vector< T > | softmax_vec (const std::vector< T > &vec, real_t tau=1.0) |
| applies softmax operation to the elements of the vector and returns a vector with the result | |
| template<typename T > | |
| DynVec< T > | softmax_vec (const DynVec< T > &vec, real_t tau=1.0) |
| applies softmax operation to the elements of the vector and returns a vector with the result | |
| template<typename IteratorType > | |
| DynVec< typename IteratorType::value_type > | softmax_vec (IteratorType begin, IteratorType end, real_t tau=1.0) |
| applies softmax operation to the elements of the vector and returns a vector with the result | |
| template<typename VectorType > | |
| uint_t | arg_max (const VectorType &vec) |
| Returns the index of the element that has the maximum value in the array. Implementation taken from http://www.jclay.host/dev-journal/simple_cpp_argmax_argmin.html. | |
| template<typename VectorType > | |
| uint_t | arg_min (const VectorType &vec) |
| Returns the index of the element that has the minimum value in the array. Implementation taken from http://www.jclay.host/dev-journal/simple_cpp_argmax_argmin.html. | |
| template<typename T > | |
| std::vector< uint_t > | max_indices (const DynVec< T > &vec) |
| template<typename VecTp > | |
| std::vector< uint_t > | max_indices (const VecTp &vec) |
| Returns the indices of vec where the maximum value in vec occurs. | |
| template<typename T > | |
| std::vector< T > | extract_subvector (const std::vector< T > &vec, uint_t end, bool up_to=true) |
| template<typename SequenceTp > | |
| uint_t | bin_index (const typename SequenceTp::value_type &x, const SequenceTp &sequence) |
| bin_index. Compute sequnce[i - 1] <= x sequnce[i] and returns the index. Sequence should be sorted | |
| template<typename VectorType > | |
| VectorType | zero_center (const VectorType &vec, bool parallel=true) |
| zero_center. Subtracts the mean value of the given vector from every value of the vector | |
| template<typename VectorType > | |
| VectorType | normalize (const VectorType &vec, typename VectorType::value_type v) |
| Normalize the values of the given vector with the given value. Essentially this function divides the elements of the vector with the value provided. | |
| template<typename T > | |
| std::vector< T > | normalize_max (const std::vector< T > &vec) |
| template<typename T > | |
| std::vector< T > | normalize_min (const std::vector< T > &vec) |
| std::vector< real_t > | logspace (real_t start, real_t end, uint_t num, real_t base=10.0) |
| template<typename IteratorType > | |
| std::iterator_traits< IteratorType >::value_type | dot_product (IteratorType bv1, IteratorType ev1, IteratorType bv2, IteratorType ev2) |
| template<typename VectorType > | |
| real_t | dot_product (const VectorType &v1, const VectorType &v2, uint_t start_idx=0) |
| using cuberl::maths::EuclideanMetric = typedef LpMetric<2, true> |
| using cuberl::maths::ManhattanMetric = typedef LpMetric<1, false> |
some useful shortcuts
| using cuberl::maths::SqrEuclidean_metric = typedef LpMetric<2, false> |
| Vec & cuberl::maths::add | ( | Vec & | v1, |
| const Vec & | v2 | ||
| ) |
| uint_t cuberl::maths::arg_max | ( | const VectorType & | vec | ) |
Returns the index of the element that has the maximum value in the array. Implementation taken from http://www.jclay.host/dev-journal/simple_cpp_argmax_argmin.html.
| uint_t cuberl::maths::arg_min | ( | const VectorType & | vec | ) |
Returns the index of the element that has the minimum value in the array. Implementation taken from http://www.jclay.host/dev-journal/simple_cpp_argmax_argmin.html.
| uint_t cuberl::maths::bin_index | ( | const typename SequenceTp::value_type & | x, |
| const SequenceTp & | sequence | ||
| ) |
bin_index. Compute sequnce[i - 1] <= x sequnce[i] and returns the index. Sequence should be sorted
| uint_t cuberl::maths::choice | ( | const Vec1 & | choices, |
| const Vec2 & | probs, | ||
| uint_t | seed = 42 |
||
| ) |
choice. Implements similar functionality to numpy.choice function
https://www.cplusplus.com/reference/random/discrete_distribution/
| uint_t cuberl::maths::choice | ( | const Vec2 & | probs, |
| uint_t | seed = 42 |
||
| ) |
choice. Implements similar functionality to numpy.choice function
https://www.cplusplus.com/reference/random/discrete_distribution/
| Vec::value_type cuberl::maths::choose_value | ( | const Vec & | vals, |
| uint_t | seed = 42 |
||
| ) |
| Vec & cuberl::maths::divide | ( | Vec & | v1, |
| typename Vec::value_type | val | ||
| ) |
| real_t cuberl::maths::dot_product | ( | const VectorType & | v1, |
| const VectorType & | v2, | ||
| uint_t | start_idx = 0 |
||
| ) |
| std::iterator_traits< IteratorType >::value_type cuberl::maths::dot_product | ( | IteratorType | bv1, |
| IteratorType | ev1, | ||
| IteratorType | bv2, | ||
| IteratorType | ev2 | ||
| ) |
| VectorType cuberl::maths::element_product | ( | const VectorType & | v1, |
| const VectorType & | v2 | ||
| ) |
| void cuberl::maths::exchange_rows | ( | MatType & | mat, |
| uint_t | r1, | ||
| uint_t | r2 | ||
| ) |
Exchange the rows of the matrix.
| VectorType cuberl::maths::exponentiate | ( | const VectorType & | vec | ) |
| VectorType cuberl::maths::exponentiate | ( | const VectorType & | vec, |
| typename VectorType::value_type | v | ||
| ) |
| std::vector< T > cuberl::maths::extract_subvector | ( | const std::vector< T > & | vec, |
| uint_t | end, | ||
| bool | up_to = true |
||
| ) |
| DynVec< T > cuberl::maths::get_row | ( | const DynMat< T > & | matrix, |
| uint_t | row_idx | ||
| ) |
Extract the cidx-th column from the matrix.
get_column_means. Computes the means of the matrix columns
get_column_variances. Computes the variances of the matrix columns
Extract the row_idx-th row from the matrix
| std::vector< real_t > cuberl::maths::logspace | ( | real_t | start, |
| real_t | end, | ||
| uint_t | num, | ||
| real_t | base = 10.0 |
||
| ) |
Return numbers spaced evenly on a log scale. The implementation is inspired from numpy: https://numpy.org/doc/stable/reference/generated/numpy.logspace.html See also: https://quick-bench.com/q/Hs39BWQf5kr5Gjnv6zQkLXMrsDw
The starting point of the scale is: std::pow(base, start) Similarly the endpoint is: std::pow(base, end) The intermediate points are aligned as std::pow(base, point) where point = start + i*dx where dx = (end - start) / (num - 1)
| std::vector< uint_t > cuberl::maths::max_indices | ( | const VecTp & | vec | ) |
Returns the indices of vec where the maximum value in vec occurs.
| real_t cuberl::maths::mean | ( | const DynVec< T > & | vector, |
| bool | parallel = true |
||
| ) |
mean computes the mean value of the given DynVec
| real_t cuberl::maths::mean | ( | const VectorType & | vector, |
| bool | parallel = true |
||
| ) |
mean Computes the mean value of the vector. If parallel=true it uses std::reduce
| real_t cuberl::maths::mean | ( | IteratorType | begin, |
| IteratorType | end, | ||
| bool | parallel = true |
||
| ) |
mean Compute the mean value of the values in the provided iterator range
| VectorType cuberl::maths::normalize | ( | const VectorType & | vec, |
| typename VectorType::value_type | v | ||
| ) |
Normalize the values of the given vector with the given value. Essentially this function divides the elements of the vector with the value provided.
| vec | |
| v | |
| parallel |
| std::vector< T > cuberl::maths::normalize_max | ( | const std::vector< T > & | vec | ) |
| std::vector< T > cuberl::maths::normalize_min | ( | const std::vector< T > & | vec | ) |
| std::vector< T > & cuberl::maths::randomize | ( | std::vector< T > & | vec, |
| T | a, | ||
| T | b, | ||
| uint_t | seed = 42 |
||
| ) |
Fill in the given vector with random values.
| vec | The vector to fill in |
| seed | The seed for the random engine |
| void cuberl::maths::randomize_vec | ( | Vec & | v, |
| const Vec & | walk_set, | ||
| uint_t | seed = 42 |
||
| ) |
Given a vector of intergal or floating point values and a set of values to choose from, randomize the entries ofv.
| std::set< uint_t > cuberl::maths::shuffle_matrix_rows | ( | MatType & | mat | ) |
Shuffle the rows of the matrix. Returns a set with the rows that have been shuffled.
| DynVec< T > cuberl::maths::softmax_vec | ( | const DynVec< T > & | vec, |
| real_t | tau = 1.0 |
||
| ) |
applies softmax operation to the elements of the vector and returns a vector with the result
| std::vector< T > cuberl::maths::softmax_vec | ( | const std::vector< T > & | vec, |
| real_t | tau = 1.0 |
||
| ) |
applies softmax operation to the elements of the vector and returns a vector with the result
| DynVec< typename IteratorType::value_type > cuberl::maths::softmax_vec | ( | IteratorType | begin, |
| IteratorType | end, | ||
| real_t | tau = 1.0 |
||
| ) |
applies softmax operation to the elements of the vector and returns a vector with the result
| std::vector< real_t > cuberl::maths::standardize | ( | const std::vector< real_t > & | vals, |
| real_t | tol = bitrl::consts::TOLERANCE |
||
| ) |
Standardize the given vector.
| VectorType::value_type cuberl::maths::sum | ( | const VectorType & | vec, |
| bool | parallel = true |
||
| ) |
| std::iterator_traits< IteratorType >::value_type cuberl::maths::sum | ( | IteratorType | begin, |
| IteratorType | end, | ||
| bool | parallel = true |
||
| ) |
Compute the variance of the given std::vector of real values.
| std::iterator_traits< IteratorType >::value_type cuberl::maths::variance | ( | IteratorType | begin, |
| IteratorType | end, | ||
| bool | parallel = true |
||
| ) |
| VectorType cuberl::maths::zero_center | ( | const VectorType & | vec, |
| bool | parallel = true |
||
| ) |
zero_center. Subtracts the mean value of the given vector from every value of the vector