RockyML  0.0.1
A High-Performance Scientific Computing Framework
rocky::zagros::basic_scontainer< T_e, T_dim > Class Template Reference

a data container representing a scontainer More...

#include <scontainer.h>

Public Member Functions

 basic_scontainer (int n_particles, int group_size)
 
int n_particles () const
 
int group_size () const
 
int n_groups () const
 
void reset_values ()
 
void allocate ()
 
T_e * particle (int p)
 get the starting address of a specific particle More...
 
int particle_group (int p)
 get the group of a particle More...
 
T_e * group (int g)
 get the address to the starting point of a group More...
 
std::pair< int, int > group_range (int g) const
 starting and endind point of a group More...
 
T_e * value (int p)
 pointer to the value of a particle More...
 
void sample_n_particles (int *indices, int n=1)
 sample n distinct particles from a group efficient when n is small More...
 
std::pair< int, int > sample_pair (int group)
 sample a pair of distinct particles More...
 
int sample_particle (int group)
 sample a single particle from a group More...
 
int sample_dim ()
 choose a dimension randomly More...
 
size_t space () const
 amount of allocated memory in bytes More...
 
T_e best_min ()
 find the best solution in the container More...
 
std::pair< T_e, int > best_min_index ()
 find the best solution and the corresponding index in the container More...
 
void evaluate_and_update (system< T_e > *problem, int rng_start, int rng_end)
 evaluate and update the particles within a range More...
 
void evaluate_and_update (system< T_e > *problem, int p)
 evaluate and update a single particle More...
 
void evaluate_and_update (system< T_e > *problem)
 evaluate and update all particles More...
 
void best_k (int *indices, int k)
 find top-k solutions and fill the indices More...
 
void worst_k (int *indices, int k)
 find worst-k solutions and fill the indices More...
 
void replace_with (basic_scontainer< T_e, T_dim > *cnt)
 replace the best values from another container More...
 
std::discrete_distribution< int > weighted_sampler ()
 weighted particle sampling More...
 

Public Attributes

std::vector< std::vector< T_e > > particles
 
std::vector< T_e > values
 

Protected Attributes

int n_particles_
 
int group_size_
 

Detailed Description

template<typename T_e, int T_dim>
class rocky::zagros::basic_scontainer< T_e, T_dim >

a data container representing a scontainer

Member Function Documentation

◆ best_k()

template<typename T_e , int T_dim>
void rocky::zagros::basic_scontainer< T_e, T_dim >::best_k ( int *  indices,
int  k 
)
inline

find top-k solutions and fill the indices

Parameters
indicesan integer array to access the result
knumber of picks

◆ best_min()

template<typename T_e , int T_dim>
T_e rocky::zagros::basic_scontainer< T_e, T_dim >::best_min ( )
inline

find the best solution in the container

◆ best_min_index()

template<typename T_e , int T_dim>
std::pair<T_e, int> rocky::zagros::basic_scontainer< T_e, T_dim >::best_min_index ( )
inline

find the best solution and the corresponding index in the container

Returns
a pair <T_e, int> containing best min value and index of the particle

◆ evaluate_and_update() [1/3]

template<typename T_e , int T_dim>
void rocky::zagros::basic_scontainer< T_e, T_dim >::evaluate_and_update ( system< T_e > *  problem)
inline

evaluate and update all particles

Parameters
problena zagros system
Returns
* void

◆ evaluate_and_update() [2/3]

template<typename T_e , int T_dim>
void rocky::zagros::basic_scontainer< T_e, T_dim >::evaluate_and_update ( system< T_e > *  problem,
int  p 
)
inline

evaluate and update a single particle

Parameters
problema zagros system
pindex of the target particle
Returns
* void

◆ evaluate_and_update() [3/3]

template<typename T_e , int T_dim>
void rocky::zagros::basic_scontainer< T_e, T_dim >::evaluate_and_update ( system< T_e > *  problem,
int  rng_start,
int  rng_end 
)
inline

evaluate and update the particles within a range

Parameters
problema zagros system
rng_start
rng_end
Returns
* void

◆ group()

template<typename T_e , int T_dim>
T_e* rocky::zagros::basic_scontainer< T_e, T_dim >::group ( int  g)
inline

get the address to the starting point of a group

Parameters
ggroup's index
Returns
* T_e*

◆ group_range()

template<typename T_e , int T_dim>
std::pair<int, int> rocky::zagros::basic_scontainer< T_e, T_dim >::group_range ( int  g) const
inline

starting and endind point of a group

Parameters
ggroup index
Returns
* std::pair<int, int>

◆ particle()

template<typename T_e , int T_dim>
T_e* rocky::zagros::basic_scontainer< T_e, T_dim >::particle ( int  p)
inline

get the starting address of a specific particle

Parameters
pindex of the particle
Returns
* T_e*

◆ particle_group()

template<typename T_e , int T_dim>
int rocky::zagros::basic_scontainer< T_e, T_dim >::particle_group ( int  p)
inline

get the group of a particle

Parameters
pparticle index
Returns
* int

◆ replace_with()

template<typename T_e , int T_dim>
void rocky::zagros::basic_scontainer< T_e, T_dim >::replace_with ( basic_scontainer< T_e, T_dim > *  cnt)
inline

replace the best values from another container

Parameters
cntsource container
Returns
** void

◆ sample_dim()

template<typename T_e , int T_dim>
int rocky::zagros::basic_scontainer< T_e, T_dim >::sample_dim ( )
inline

choose a dimension randomly

Returns
* int

◆ sample_n_particles()

template<typename T_e , int T_dim>
void rocky::zagros::basic_scontainer< T_e, T_dim >::sample_n_particles ( int *  indices,
int  n = 1 
)
inline

sample n distinct particles from a group efficient when n is small

Parameters
indicesan array to store the result
nsample size

◆ sample_pair()

template<typename T_e , int T_dim>
std::pair<int, int> rocky::zagros::basic_scontainer< T_e, T_dim >::sample_pair ( int  group)
inline

sample a pair of distinct particles

Parameters
group
Returns
* std::pair<int, int>

◆ sample_particle()

template<typename T_e , int T_dim>
int rocky::zagros::basic_scontainer< T_e, T_dim >::sample_particle ( int  group)
inline

sample a single particle from a group

Parameters
group
Returns
* int index of the particle

◆ space()

template<typename T_e , int T_dim>
size_t rocky::zagros::basic_scontainer< T_e, T_dim >::space ( ) const
inline

amount of allocated memory in bytes

◆ value()

template<typename T_e , int T_dim>
T_e* rocky::zagros::basic_scontainer< T_e, T_dim >::value ( int  p)
inline

pointer to the value of a particle

Returns
* T_e*

◆ weighted_sampler()

template<typename T_e , int T_dim>
std::discrete_distribution<int> rocky::zagros::basic_scontainer< T_e, T_dim >::weighted_sampler ( )
inline

weighted particle sampling

Returns
a discrete distribution for weighted sampling

◆ worst_k()

template<typename T_e , int T_dim>
void rocky::zagros::basic_scontainer< T_e, T_dim >::worst_k ( int *  indices,
int  k 
)
inline

find worst-k solutions and fill the indices

Parameters
indicesan integer array to access the result
knumber of picks

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