Nemo  2.3.56
Simulate forward-in-time genetic evolution in a spatially explicit, individual-based stochastic simulator
SimBuilder Class Reference

Provides methods to build the user's selected set of life cycle events and traits from the parameters. More...

#include <basicsimulation.h>

+ Inheritance diagram for SimBuilder:
+ Collaboration diagram for SimBuilder:

Public Member Functions

 SimBuilder ()
 
 SimBuilder (const SimBuilder &SB)
 copy cstor. More...
 
 ~SimBuilder ()
 
bool build_currentParams (map< string, string > &simparams)
 Builds the list of parameters from user's defined input parameters. More...
 
map< trait_t, TraitPrototype * > & build_currentTraits ()
 Selects the trait prototypes that have their parameters set. More...
 
void build_LifeCycle ()
 Selects the life cycle events that have their parameters set. More...
 
TraitPrototypeget_current_trait (trait_t type)
 Accessor to the list of current trait prototypes. More...
 
TraitPrototypeget_current_traitWithParameter (string &param)
 Accessor to the current trait prototypes conditioned on ownership of a specified parameter. More...
 
LifeCycleEventget_current_event (string &name)
 Accessor to the list of current LCEs. More...
 
LifeCycleEventget_current_eventWithParameter (string &param)
 Accessor to the current LCEs conditioned on ownership of a specified parameter. More...
 
list< ParamSet * > & get_currentParams ()
 Accessor to the list of the selected parameter sets. More...
 
age_t getFirstRequiredAgeInLifeCycle ()
 
- Public Member Functions inherited from ParamManager
 ParamManager ()
 Cstor. More...
 
 ~ParamManager ()
 
void add_paramset (ParamSet *paramset)
 Adds a ParamSet to the list of the parameter sets of the simulation. More...
 
ParamSetget_paramset (string &name)
 Looks for paramset with "name" in the list of parameter sets. More...
 
void build_allParams ()
 Clears and fills the _allParams list with the ParamSet's of the simulation components. More...
 
list< ParamSet * > & get_allParams ()
 Accessor of the whole list of the parameter sets. More...
 
bool set_parameters (map< string, string > &simparams, bool silent)
 Sets the parameters of the simulation with the argument strings given in input. More...
 
bool param_consistency_check ()
 Checks if all the mandatory parameters are set so that the simulation can be launched. More...
 
void build_records (map< string, vector< string > > &initParams)
 Builds the list of simulation parameters from the parsed input file(s). More...
 
list< map< string, string > > & get_simRecords ()
 Accessor to the simulations parameter list. More...
 
map< string, string > & get_firstRecord ()
 Accessor to the first element in the simulations parameter list. More...
 
int get_nbSims ()
 Accessor to the size of the simulations parameter list, i.e. More...
 
- Public Member Functions inherited from ComponentManager
 ComponentManager ()
 
 ~ComponentManager ()
 
void build_component_list ()
 Clears and builds the list of all components from the lists of trait prototype templates and life cycle event templates. More...
 
void add_component (SimComponent *cmpt)
 Push a component at the back of the component list. More...
 
void add_trait (TraitPrototype *trait)
 Add a trait prototype to the template and component lists. More...
 
void add_LCE (LifeCycleEvent *event)
 Add a life cycle event to the template and component lists. More...
 
TraitPrototypeget_trait (string name)
 Search for component with "name" in the trait prototype list. More...
 
LifeCycleEventget_LCE (string name)
 Search for component with "name" in the life cycle events list. More...
 

Protected Types

typedef map< int, LifeCycleEvent * >::const_iterator LCE_ITER
 
typedef map< trait_t, TraitPrototype * >::const_iterator TRAIT_ITER
 

Protected Attributes

list< ParamSet * > _currentParams
 List of the selected simulation components from the user defined input parameters. More...
 
map< trait_t, TraitPrototype * > _currentTraits
 List of the selected trait prototypes from the user defined input parameters. More...
 
map< int, LifeCycleEvent * > _LifeCycle
 List of the selected life cycle events from the user defined input parameters. More...
 
- Protected Attributes inherited from ParamManager
list< ParamSet * > _allParams
 A list of all the parameter sets of all the simulation components loaded in the _component list of the ComponentManager. More...
 
map< string, string > _inputParams
 A map of the parameters and their arguments of the current (running) simulation. More...
 
map< unsigned int, list< pair< string, string > > > _temporalParams
 Lists of parameters to be updated during a simulation indexed by generation update time. More...
 
list< map< string, string > > _simRecords
 Sets of parameters of all the simulations to perform. More...
 
ParamSet _paramSet
 The ParamSet param set of the simulation. More...
 
- Protected Attributes inherited from ComponentManager
list< SimComponent * > _components
 List of all the simulation components. More...
 
list< TraitPrototype * > _TTrait_Templates
 List of all trait prototypes of the simulation, a subset of _components list. More...
 
list< LifeCycleEvent * > _LCE_Templates
 List of all the life-cycle events of the simulation, a subset of _components list. More...
 

Detailed Description

Provides methods to build the user's selected set of life cycle events and traits from the parameters.

This class implements methods to build the lists of selected traits and life cycle events from the user's defined parameters. Each simulation component that has its ParamSet in the "set" state is elligible to be part of the current simulation. Accessors to these components are provided. This class does however not provide a runnable simulation object.

Member Typedef Documentation

◆ LCE_ITER

typedef map<int,LifeCycleEvent*>::const_iterator SimBuilder::LCE_ITER
protected

◆ TRAIT_ITER

typedef map<trait_t,TraitPrototype*>::const_iterator SimBuilder::TRAIT_ITER
protected

Constructor & Destructor Documentation

◆ SimBuilder() [1/2]

SimBuilder::SimBuilder ( )
inline
170{ }

◆ SimBuilder() [2/2]

SimBuilder::SimBuilder ( const SimBuilder SB)

copy cstor.

611{
612 list< TraitPrototype* >::const_iterator TT = SB._TTrait_Templates.begin();
613
614 for(;TT != SB._TTrait_Templates.end(); TT++) add_trait( (*TT)->clone() );
615
616 list< LifeCycleEvent* >::const_iterator LCE = SB._LCE_Templates.begin();
617
618 for(;LCE != SB._LCE_Templates.end(); LCE++) add_LCE( (*LCE)->clone() );
619
620
621 _paramSet = SB._paramSet;
622
624}
list< LifeCycleEvent * > _LCE_Templates
List of all the life-cycle events of the simulation, a subset of _components list.
Definition: basicsimulation.h:75
list< TraitPrototype * > _TTrait_Templates
List of all trait prototypes of the simulation, a subset of _components list.
Definition: basicsimulation.h:73
void add_LCE(LifeCycleEvent *event)
Add a life cycle event to the template and component lists.
Definition: basicsimulation.h:58
void add_trait(TraitPrototype *trait)
Add a trait prototype to the template and component lists.
Definition: basicsimulation.h:56
void build_allParams()
Clears and fills the _allParams list with the ParamSet's of the simulation components.
Definition: basicsimulation.cc:116
ParamSet _paramSet
The ParamSet param set of the simulation.
Definition: basicsimulation.h:151

References ComponentManager::_LCE_Templates, ParamManager::_paramSet, ComponentManager::_TTrait_Templates, ComponentManager::add_LCE(), ComponentManager::add_trait(), and ParamManager::build_allParams().

◆ ~SimBuilder()

SimBuilder::~SimBuilder ( )
629{
630#ifdef _DEBUG_
631 message("SimBuilder::~SimBuilder\n");
632#endif
633
634 _components.clear();
635
636 list< TraitPrototype* >::iterator TT_it = _TTrait_Templates.begin();
637
638 while(TT_it != _TTrait_Templates.end()) {
639 delete (*TT_it);
640 TT_it++;
641 }
642
643 list< LifeCycleEvent* >::iterator LCE_it = _LCE_Templates.begin();
644
645 while(LCE_it != _LCE_Templates.end()) {
646 delete (*LCE_it);
647 LCE_it++;
648 }
649
650}
list< SimComponent * > _components
List of all the simulation components.
Definition: basicsimulation.h:71
void message(const char *message,...)
Definition: output.cc:40

References ComponentManager::_components, ComponentManager::_LCE_Templates, ComponentManager::_TTrait_Templates, and message().

Member Function Documentation

◆ build_currentParams()

bool SimBuilder::build_currentParams ( map< string, string > &  simparams)

Builds the list of parameters from user's defined input parameters.

Parameters
simparamsHashtable of the parsed input parameters
Returns
TRUE if parameters are consitently set
716{
717 if(! this->set_parameters(simparams, false) ) return false;
718
719 //empty the current parameters container:
720 _currentParams.clear();
721
722 list<ParamSet*>::iterator current_paramset = this->_allParams.begin();
723
724 //add all set parameters to the list of the current params:
725 while(current_paramset != this->_allParams.end()){
726 if((*current_paramset)->isSet()) {
727#ifdef _DEBUG_
728 message("SimBuilder::build_currentParams:adding paramset %s\n",
729 (*current_paramset)->getName().c_str());
730#endif
731 _currentParams.push_back(*current_paramset);
732 }
733 current_paramset++;
734 }
735
736 return true;
737}
bool set_parameters(map< string, string > &simparams, bool silent)
Sets the parameters of the simulation with the argument strings given in input.
Definition: basicsimulation.cc:151
list< ParamSet * > _allParams
A list of all the parameter sets of all the simulation components loaded in the _component list of th...
Definition: basicsimulation.h:143
list< ParamSet * > _currentParams
List of the selected simulation components from the user defined input parameters.
Definition: basicsimulation.h:220

References ParamManager::_allParams, _currentParams, message(), and ParamManager::set_parameters().

Referenced by BinaryDataLoader::extractPop(), and SimRunner::init_components().

+ Here is the caller graph for this function:

◆ build_currentTraits()

map< trait_t, TraitPrototype * > & SimBuilder::build_currentTraits ( )

Selects the trait prototypes that have their parameters set.

Returns
Hashtable of the trait prototypes
742{
743 //build the list of Traits for this simulation:
744 list< TraitPrototype* >::iterator trait = this->_TTrait_Templates.begin();
745
746 _currentTraits.clear();
747
748 while(trait != this->_TTrait_Templates.end()) {
749
750 if( (*trait)->get_paramset()->isSet() ){
751 _currentTraits[(*trait)->get_type()] = (*trait);
752 }
753
754 trait++;
755 }
756
757 return _currentTraits;
758}
map< trait_t, TraitPrototype * > _currentTraits
List of the selected trait prototypes from the user defined input parameters.
Definition: basicsimulation.h:222

References _currentTraits, and ComponentManager::_TTrait_Templates.

Referenced by BinaryDataLoader::extractPop(), and SimRunner::init_components().

+ Here is the caller graph for this function:

◆ build_LifeCycle()

void SimBuilder::build_LifeCycle ( )

Selects the life cycle events that have their parameters set.

763{
764 //build the list of the life cycle events for this simulation:
765 list< LifeCycleEvent* >::iterator LCE = this->_LCE_Templates.begin();
766
767 _LifeCycle.clear();
768
769
770 while(LCE != this->_LCE_Templates.end()) {
771 if( (*LCE)->get_paramset()->isSet() ){
772#ifdef _DEBUG_
773 cout <<"adding LCE "<< (*LCE)->get_event_name() <<" : "<< (*LCE)->get_rank() << endl;
774#endif
775 _LifeCycle[(int)(*LCE)->get_rank()] = (*LCE);
776 }
777 LCE++;
778 }
779
780}
map< int, LifeCycleEvent * > _LifeCycle
List of the selected life cycle events from the user defined input parameters.
Definition: basicsimulation.h:224

References ComponentManager::_LCE_Templates, and _LifeCycle.

Referenced by SimRunner::setLifeCycle().

+ Here is the caller graph for this function:

◆ get_current_event()

LifeCycleEvent * SimBuilder::get_current_event ( string &  name)

Accessor to the list of current LCEs.

Parameters
namethe name of the LCE
Returns
ptr to the LCE
684{
685 LCE_ITER LCE = _LifeCycle.begin();
686
687 while(LCE != _LifeCycle.end()) {
688 if( LCE->second->get_event_name().compare(name) == 0)
689 return LCE->second;
690 LCE++;
691 }
692
693 return NULL;
694}
map< int, LifeCycleEvent * >::const_iterator LCE_ITER
Definition: basicsimulation.h:226

References _LifeCycle.

Referenced by Metapop::loadPopFromBinarySource(), and SimRunner::run_event().

+ Here is the caller graph for this function:

◆ get_current_eventWithParameter()

LifeCycleEvent * SimBuilder::get_current_eventWithParameter ( string &  param)

Accessor to the current LCEs conditioned on ownership of a specified parameter.

Parameters
thename of the parameter of interest
Returns
a pointer to the LCE, is NULL if no trait found
699{
700 LifeCycleEvent* event = NULL;
701
702 for(LCE_ITER LCE = _LifeCycle.begin(); LCE != _LifeCycle.end(); LCE++)
703 {
704 if( LCE->second->has_parameter(param)) {
705 event = LCE->second;
706 break; //this assumes that parameters are unique, the first component found with that parameter is returned
707 }
708 }
709
710 return event;
711}
Base class of the Life Cycle Events, declares the LCE interface.
Definition: lifecycleevent.h:73

References _LifeCycle.

Referenced by Metapop::loadPopFromBinarySource().

+ Here is the caller graph for this function:

◆ get_current_trait()

TraitPrototype * SimBuilder::get_current_trait ( trait_t  type)

Accessor to the list of current trait prototypes.

Parameters
typethe trait type
Returns
ptr to the prototype
655{
656 TRAIT_ITER trait = _currentTraits.find(type);
657
658 if(trait != _currentTraits.end())
659 return trait->second;
660 else
661 return NULL;
662}
map< trait_t, TraitPrototype * >::const_iterator TRAIT_ITER
Definition: basicsimulation.h:227

References _currentTraits.

Referenced by Metapop::loadPopFromBinarySource().

+ Here is the caller graph for this function:

◆ get_current_traitWithParameter()

TraitPrototype * SimBuilder::get_current_traitWithParameter ( string &  param)

Accessor to the current trait prototypes conditioned on ownership of a specified parameter.

Parameters
thename of the parameter of interest
Returns
a pointer to the trait prototype, is NULL if no trait found
667{
668 TraitPrototype* TP = NULL;
669
670 for(TRAIT_ITER trait = _currentTraits.begin(); trait != _currentTraits.end(); trait++)
671 {
672 if( trait->second->has_parameter(param)) {
673 TP = trait->second;
674 break; //this assumes that parameters are unique, the first component found with that parameter is returned
675 }
676 }
677
678 return TP;
679}
TTrait setter.
Definition: ttrait.h:125

References _currentTraits.

Referenced by Metapop::loadPopFromBinarySource().

+ Here is the caller graph for this function:

◆ get_currentParams()

list< ParamSet * > & SimBuilder::get_currentParams ( )
inline

Accessor to the list of the selected parameter sets.

Returns
list of ParamSet
214{return _currentParams;}

References _currentParams.

◆ getFirstRequiredAgeInLifeCycle()

age_t SimBuilder::getFirstRequiredAgeInLifeCycle ( )
785{
786 age_t requiredAgeClass = NONE;
787
788 for(LCE_ITER IT = _LifeCycle.begin();
789 IT != _LifeCycle.end() && requiredAgeClass == NONE;
790 IT++)
791 requiredAgeClass = IT->second->requiredAgeClass();
792
793 return requiredAgeClass;
794}
#define NONE
No age flag.
Definition: types.h:48
unsigned int age_t
Age class flags.
Definition: types.h:46

References _LifeCycle, and NONE.

Referenced by Metapop::setPopulation().

+ Here is the caller graph for this function:

Member Data Documentation

◆ _currentParams

list< ParamSet* > SimBuilder::_currentParams
protected

List of the selected simulation components from the user defined input parameters.

Referenced by build_currentParams(), and get_currentParams().

◆ _currentTraits

map< trait_t, TraitPrototype* > SimBuilder::_currentTraits
protected

List of the selected trait prototypes from the user defined input parameters.

Referenced by build_currentTraits(), get_current_trait(), get_current_traitWithParameter(), SimRunner::register_component_handlers(), and SimRunner::run().

◆ _LifeCycle


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

Generated for Nemo v2.3.56 by  doxygen 1.9.0 -- Nemo is hosted on  Download Nemo

Locations of visitors to this page
Catalogued on GSR