BioDynaMo  v1.03.58-27764645
Classes | Functions
bdm::experimental Namespace Reference

Classes

struct  Algorithm
 An interface for creating new optimization algorithms. More...
 
struct  AlgorithmRegistry
 Registry of all optimization algorithms. More...
 
class  CopyExecutionContext
 
struct  Counter
 
class  Database
 
class  GenericReducer
 
class  LineGraph
 
struct  ParameterSweep
 Perform an exhaustive sweep across specified parameters. More...
 
struct  ParticleSwarm
 
struct  Reducer
 
class  Style
 
class  TimeSeries
 

Functions

template<typename T >
Reduce (Simulation *sim, Functor< void, Agent *, T * > &agent_functor, Functor< T, const SharedData< T > & > &reduce_partial_results, Functor< bool, Agent * > *filter=nullptr)
 
uint64_t Count (Simulation *sim, Functor< bool, Agent * > &condition, Functor< bool, Agent * > *filter=nullptr)
 
AlgorithmCreateOptimizationAlgorithm (OptimizationParam *opt_params)
 
 BDM_REGISTER_ALGO (ParameterSweep)
 
 BDM_REGISTER_ALGO (ParticleSwarm)
 
template<typename Lambda >
void DynamicNestedLoop (const std::vector< OptimizationParamType * > &containers, const Lambda &action)
 
real_t Experiment (Functor< void, Param *, TimeSeries * > &simulation, size_t iterations, const Param *param, TimeSeries *real_ts=nullptr, Functor< void, const std::vector< TimeSeries > &, const TimeSeries &, const TimeSeries & > *post_simulation=nullptr)
 

Function Documentation

◆ BDM_REGISTER_ALGO() [1/2]

bdm::experimental::BDM_REGISTER_ALGO ( ParameterSweep  )

◆ BDM_REGISTER_ALGO() [2/2]

bdm::experimental::BDM_REGISTER_ALGO ( ParticleSwarm  )

◆ Count()

uint64_t bdm::experimental::Count ( Simulation sim,
Functor< bool, Agent * > &  condition,
Functor< bool, Agent * > *  filter = nullptr 
)
inline

Counts the number of agents for which condition evaluates to true. Let's assume we want to count all infected agents in a virus spreading simulation.

auto is_infected = L2F([](Agent* a) {
return bdm_static_cast<Person*>(a)->state_ == State::kInfected;
});
auto num_infected = Count(sim, is_infected));

The optional argument filter allows to count only a subset of all agents.
NB: For better performance consider using Counter instead.

Definition at line 317 of file reduce.h.

◆ CreateOptimizationAlgorithm()

Algorithm* bdm::experimental::CreateOptimizationAlgorithm ( OptimizationParam opt_params)
inline

Definition at line 71 of file algorithm_registry.h.

◆ DynamicNestedLoop()

template<typename Lambda >
void bdm::experimental::DynamicNestedLoop ( const std::vector< OptimizationParamType * > &  containers,
const Lambda &  action 
)
inline

Definition at line 30 of file dynamic_loop.h.

◆ Experiment()

real_t bdm::experimental::Experiment ( Functor< void, Param *, TimeSeries * > &  simulation,
size_t  iterations,
const Param param,
TimeSeries real_ts = nullptr,
Functor< void, const std::vector< TimeSeries > &, const TimeSeries &, const TimeSeries & > *  post_simulation = nullptr 
)
inline

Definition at line 36 of file experiment.h.

◆ Reduce()

template<typename T >
T bdm::experimental::Reduce ( Simulation sim,
Functor< void, Agent *, T * > &  agent_functor,
Functor< T, const SharedData< T > & > &  reduce_partial_results,
Functor< bool, Agent * > *  filter = nullptr 
)
inline

Iterates over all agents executing the agent_functor and updating a a thread-local and therefore partial result. The second parameter specifies how these partial results should be combined into a single value. Let's assume we want to sum up the data attribute of all agents.

auto sum_data = L2F([](Agent* agent, uint64_t* tl_result) {
*tl_result += bdm_static_cast<TestAgent*>(agent)->GetData();
});
SumReduction<uint64_t> combine_tl_results;
auto result = Reduce(sim, sum_data, combine_tl_results);

The optional argument filter allows to reduce only a subset of all agents.
NB: For better performance consider using GenericReducer instead.

Definition at line 183 of file reduce.h.

bdm::experimental::Reduce
T Reduce(Simulation *sim, Functor< void, Agent *, T * > &agent_functor, Functor< T, const SharedData< T > & > &reduce_partial_results, Functor< bool, Agent * > *filter=nullptr)
Definition: reduce.h:183
bdm::L2F
LambdaFunctor< decltype(&TLambda::operator())> L2F(const TLambda &l)
Definition: functor.h:110
bdm::experimental::Count
uint64_t Count(Simulation *sim, Functor< bool, Agent * > &condition, Functor< bool, Agent * > *filter=nullptr)
Definition: reduce.h:317