Nemo
2.3.56
Simulate forward-in-time genetic evolution in a spatially explicit, individual-based stochastic simulator
|
This structure stores one parameter, its definition and its string argument. More...
#include <param.h>
Public Member Functions | |
Param (string &Name, param_t Type, bool mandatory, bool bounded, double low_bnd, double up_bnd, SimComponent *owner, ParamUpdaterBase *updater) | |
Constructor. More... | |
Param (const Param &P) | |
Copy cstor, provides shallow copy of the parameter definition, do not copy arguments. More... | |
virtual | ~Param () |
void | reset () |
Clears the _isSet flag and the argument string. More... | |
void | setName (string value) |
Sets the parameter's name. More... | |
void | setArg (string value) |
Sets the parameter's argument. More... | |
void | setType (param_t value) |
Sets the parameter's type (see types.h) More... | |
void | setIsSet (bool value) |
Sets the _isSet flag. More... | |
void | setIsBounded (bool value) |
Sets the _isBounded flag. More... | |
void | setIsRequired (bool value) |
Sets the isRequired flag. More... | |
void | setBounds (double low_bnd, double up_bnd) |
Sets the bounds. More... | |
void | setOwner (SimComponent *owner) |
Sets the pointer to owner. More... | |
void | setUpdater (ParamUpdaterBase *updater) |
Sets the pointer to the updater object. More... | |
void | setAtGeneration (unsigned int generation) |
string | getName () |
string | getArg () |
param_t | getType () |
bool | isSet () |
bool | isBounded () |
bool | isRequired () |
bool | isTemporal () |
bool | hasMultipleArgs () |
bool | hasExternalFile () |
double | getBound (unsigned int i) |
SimComponent * | getOwner () |
ParamUpdaterBase * | getUpdater () |
deque< unsigned int > | getUpdatingDates () |
deque< string > | getTemporalArgs () |
vector< string > | getMultiArgs () |
vector< string > | getExternalFiles () |
bool | set (string arg, string &errmsg) |
Sets the _isSet flag to true and _arg to arg if the arg is of the right type and whithin the bounds. More... | |
bool | update (unsigned int generation) |
Updates the parameter value at a given generation during the simulation. More... | |
double | getValue () |
Returns the argument value according to its type. More... | |
bool | isMatrix () |
Checks if the argument is of matrix type. More... | |
void | getMatrix (TMatrix *mat) |
Sets the matrix from the argument string if the parameter is set and of matrix type. More... | |
void | getVariableMatrix (vector< vector< double > > *mat) |
void | parse_matrix (TMatrix *mat) |
Parses the matrix from the argument string. More... | |
void | parse_variable_matrix (vector< vector< double > > *mat) |
bool | parseArgument (string &arg) |
bool | parseTemporalArgument (const string &arg) |
bool | parseAgeSpecArgument (const string &arg) |
bool | parseSubParamArgument (const string &arg) |
string | checkArgumentForExpansion (string arg) |
string | getArgumentFromFile (string file) |
void | show_up () |
Print state to stdout. More... | |
Private Attributes | |
string | _name |
The name of the parameter as read in the init file. More... | |
string | _arg |
The argument string, set by the ParamsParser upon initialization. More... | |
string | _input_arg |
The input argument string, kept untouched as a backup for logging. More... | |
param_t | _type |
The type of the argument, must one of DBL, INT, BOOL, STR or MAT (see types.h). More... | |
bool | _isSet |
Flag set once the parameter has recieved the right argument. More... | |
bool | _isBounded |
Flag telling if the parameter has a bounded argument value. More... | |
bool | _isRequired |
Flag telling if this parameter is mandatory. More... | |
double | _bounds [2] |
The argument value boundaries. More... | |
unsigned int | _setAtGeneration |
Generation at which the parameter has been set/updated. More... | |
SimComponent * | _myOwner |
Pointer to the component that declared this parameter. More... | |
ParamUpdaterBase * | _myUpdater |
Pointer to an ParamUpdater object. More... | |
vector< string > | _externalFile |
External argument file. More... | |
bool | _hasExternalFile |
map< unsigned int, string > | _temporalArgs |
The temporal arguments. More... | |
bool | _isTemporal |
Flag telling if this parameter has temporal arguments. More... | |
vector< string > | _multiArgs |
Multiple arguments. More... | |
bool | _hasMultipleArgs |
This structure stores one parameter, its definition and its string argument.
Parameters are aggregated into a ParamSet.
Param::Param | ( | string & | Name, |
param_t | Type, | ||
bool | mandatory, | ||
bool | bounded, | ||
double | low_bnd, | ||
double | up_bnd, | ||
SimComponent * | owner, | ||
ParamUpdaterBase * | updater | ||
) |
Constructor.
Name | the name of the parameter as read in the init file |
Type | the type of the parameter argument (see types.h), used to convert the argument string into a value |
mandatory | specifies whether this parameter is mandatory for the ParamSet owning it |
bounded | specifies whether the values this parameter can take are bounded |
low_bnd | the lower bound of the parameter value |
up_bnd | the upper bound |
owner | pointer to the SimComponents that owns this parameter |
updater | the param updater object used to update the parameter's state during a simulation |
References _bounds.
Param::Param | ( | const Param & | P | ) |
Copy cstor, provides shallow copy of the parameter definition, do not copy arguments.
References _bounds.
|
virtual |
References _myUpdater.
string Param::checkArgumentForExpansion | ( | string | arg | ) |
References getArgumentFromFile().
Referenced by parseArgument(), parseTemporalArgument(), and set().
|
inline |
References _input_arg.
Referenced by LCE_Cross::loadFileServices(), TProtoQuanti::loadFileServices(), Metapop::loadPopFromBinarySource(), ParamSet::print(), LCE_Breed_base::setFecundity(), TProtoQuanti::setMutationParameters(), BinaryDataSaver::setParameters(), LCE_Breed_Disperse::setParameters(), LCE_Cross::setParameters(), LCE_QuantiModifier::setParameters(), and TProtoDispersal::setRandom().
string Param::getArgumentFromFile | ( | string | file | ) |
References _externalFile, _hasExternalFile, fatal(), StreamParser::readArguments(), and tstring::removeFirstCharOf().
Referenced by checkArgumentForExpansion().
|
inline |
References _externalFile.
void Param::getMatrix | ( | TMatrix * | mat | ) |
Sets the matrix from the argument string if the parameter is set and of matrix type.
Passes the param 'mat' to function Param::parse_matrix.
mat | a TMatrix ptr, mat dimensions and values will be reset to the values read in the init file. |
References _isSet, _name, isMatrix(), parse_matrix(), and warning().
Referenced by LCE_Selection_base::loadFileServices(), Metapop::loadFileServices(), LCE_FileServicesNotifier::loadFileServices(), TProtoBDMI::loadFileServices(), TProtoDeletMutations_bitstring::loadFileServices(), TProtoNeutralGenes::loadFileServices(), TProtoQuanti::loadFileServices(), LCE_Patch_Extinction::set_matrix_param(), LCE_Selection_base::set_param_rate_of_change(), LCE_Selection_base::set_sel_model(), LCE_Selection_base::set_std_rate_of_change(), TProtoQuanti::setContinuousMutationModel(), TProtoQuanti::setDiallelicMutationModel(), TProtoQuanti::setDominanceParameters(), TProtoDeletMutations_bitstring::setEffectsFromInput(), LCE_Breed_base::setFecundity(), TTProtoWithMap::setGeneticMapParameters(), TTProtoWithMap::setNumLociPerChromosome(), LCE_StatServiceNotifier::setOccurence(), LCE_QuantiModifier::setParameters(), TProtoBDMI::setParameters(), TProtoQuanti::setParameters(), LCE_Breed_Wolbachia::setParameters(), and TProtoDispersal::setRandom().
vector< string > Param::getMultiArgs | ( | ) |
References _arg, _hasMultipleArgs, and _multiArgs.
Referenced by LCE_FileServicesNotifier::loadFileServices(), LCE_Selection_base::set_sel_model(), LCE_Selection_base::setParameters(), and Metapop::setSourceParameters().
|
inline |
References _name.
Referenced by ParamSet::add_param(), and ParamSet::print().
|
inline |
deque< string > Param::getTemporalArgs | ( | ) |
References _temporalArgs.
Referenced by LCE_StatServiceNotifier::setOccurence().
|
inline |
References _myUpdater.
deque< unsigned int > Param::getUpdatingDates | ( | ) |
References _temporalArgs.
Referenced by LCE_StatServiceNotifier::setOccurence().
double Param::getValue | ( | ) |
Returns the argument value according to its type.
References _arg, _isSet, _type, isMatrix(), and STR.
Referenced by LCE_Selection_base::loadFileServices(), Metapop::loadFileServices(), LCE_FileServicesNotifier::loadFileServices(), TProtoBDMI::loadFileServices(), TProtoDeletMutations_bitstring::loadFileServices(), TProtoNeutralGenes::loadFileServices(), TProtoQuanti::loadFileServices(), LCE_Patch_Extinction::set_matrix_param(), TProtoDispersal::setNonRandom(), and LCE_StatServiceNotifier::setOccurence().
void Param::getVariableMatrix | ( | vector< vector< double > > * | mat | ) |
References _isSet, _name, isMatrix(), parse_variable_matrix(), and warning().
Referenced by TTProtoWithMap::setGeneticMapParameters(), LCE_Disperse_EvolDisp::setParameters(), and LCE_Disperse_base::setReducedMatricesBySex().
|
inline |
References _hasExternalFile.
|
inline |
References _hasMultipleArgs.
Referenced by Metapop::setSourceParameters().
|
inline |
References _isBounded.
|
inline |
Checks if the argument is of matrix type.
References _arg, _type, and MAT.
Referenced by getMatrix(), getValue(), getVariableMatrix(), LCE_Selection_base::loadFileServices(), Metapop::loadFileServices(), LCE_FileServicesNotifier::loadFileServices(), TProtoBDMI::loadFileServices(), TProtoDeletMutations_bitstring::loadFileServices(), TProtoNeutralGenes::loadFileServices(), TProtoQuanti::loadFileServices(), LCE_Patch_Extinction::set_matrix_param(), LCE_StatServiceNotifier::setOccurence(), LCE_QuantiModifier::setParameters(), TProtoQuanti::setParameters(), and LCE_Selection_base::setSelectionMatrix().
|
inline |
References _isRequired.
|
inline |
References _isSet.
Referenced by LCE_Selection_base::loadFileServices(), Metapop::loadFileServices(), LCE_FileServicesNotifier::loadFileServices(), TProtoBDMI::loadFileServices(), TProtoDeletMutations_bitstring::loadFileServices(), TProtoNeutralGenes::loadFileServices(), TProtoQuanti::loadFileServices(), ParamSet::print(), TProtoNeutralGenes::resetParameterFromSource(), LCE_Disperse_base::setBaseParameters(), TTProtoWithMap::setGeneticMapParameters(), LCE_Breed_base::setMatingSystem(), TProtoDispersal::setNonRandom(), BinaryDataSaver::setParameters(), LCE_Breed_Disperse::setParameters(), LCE_Cross::setParameters(), LCE_Breed_Quanti::setParameters(), LCE_FileServicesNotifier::setParameters(), LCE_Init_BDMI::setParameters(), TProtoDeletMutations_bitstring::setParameters(), TProtoNeutralGenes::setParameters(), TProtoQuanti::setParameters(), TProtoDispersal::setRandom(), LCE_Selection_base::setSelectionMatrix(), and LCE_Resize::updateParameters().
|
inline |
References _isTemporal.
Referenced by LCE_StatServiceNotifier::setOccurence().
void Param::parse_matrix | ( | TMatrix * | mat | ) |
Parses the matrix from the argument string.
mat | a TMatrix ptr, mat dimensions and values will be reset to the values read in the init file. |
References _arg, _name, fatal(), TMatrix::reset(), and TMatrix::set().
Referenced by getMatrix().
void Param::parse_variable_matrix | ( | vector< vector< double > > * | mat | ) |
References _arg.
Referenced by getVariableMatrix().
bool Param::parseAgeSpecArgument | ( | const string & | arg | ) |
Referenced by parseArgument().
bool Param::parseArgument | ( | string & | arg | ) |
Parse an argument string enclosed in '( )', might hold temporal or multiple values.
References _hasMultipleArgs, _isTemporal, _multiArgs, _myUpdater, _name, _temporalArgs, checkArgumentForExpansion(), error(), parseAgeSpecArgument(), parseTemporalArgument(), tstring::removeEnclosingChar(), tstring::splitExcludeEnclosedDelimiters(), and warning().
Referenced by set().
bool Param::parseSubParamArgument | ( | const string & | arg | ) |
bool Param::parseTemporalArgument | ( | const string & | arg | ) |
References _name, _temporalArgs, checkArgumentForExpansion(), error(), tstring::removeFirstCharOf(), tstring::split(), and tstring::str2uint().
Referenced by parseArgument().
void Param::reset | ( | ) |
Clears the _isSet flag and the argument string.
References _arg, _externalFile, _hasExternalFile, _hasMultipleArgs, _input_arg, _isSet, _isTemporal, _multiArgs, _setAtGeneration, and _temporalArgs.
bool Param::set | ( | string | arg, |
string & | errmsg | ||
) |
Sets the _isSet flag to true and _arg to arg if the arg is of the right type and whithin the bounds.
Called at simulation setup (i.e. generation 0). For parameter update during the simulation, check the Param::update member function.
!a matrix may also be specified!! in that case, we don't check values here
References _arg, _bounds, _externalFile, _input_arg, _isBounded, _isSet, _type, BOOL, checkArgumentForExpansion(), DBL, INT, tstring::isanumber(), MAT, parseArgument(), tstring::str2dble(), and tstring::str2int().
Referenced by update().
|
inline |
Sets the parameter's argument.
References _arg, and _input_arg.
Referenced by TTProtoWithMap::recordRandomMap(), TProtoDispersal::setParameters(), TTProtoWithMap::setRecombinationMapRandom(), and TProtoDeletMutations_bitstring::write_effects_to_parameter().
|
inline |
References _setAtGeneration.
|
inline |
|
inline |
|
inline |
|
inline |
Sets the _isSet flag.
References _isSet.
Referenced by TTProtoWithMap::recordRandomMap(), TProtoDispersal::setParameters(), TTProtoWithMap::setRecombinationMapRandom(), and TProtoDeletMutations_bitstring::write_effects_to_parameter().
|
inline |
|
inline |
|
inline |
|
inline |
void Param::show_up | ( | ) |
Print state to stdout.
References _arg, _isSet, _name, _setAtGeneration, and message().
bool Param::update | ( | unsigned int | generation | ) |
Updates the parameter value at a given generation during the simulation.
References _name, _temporalArgs, error(), and set().
Referenced by ParamSet::update_param().
|
private |
The argument string, set by the ParamsParser upon initialization.
Referenced by getMultiArgs(), getValue(), isMatrix(), parse_matrix(), parse_variable_matrix(), reset(), set(), setArg(), and show_up().
|
private |
The argument value boundaries.
Referenced by getBound(), Param(), set(), and setBounds().
|
private |
External argument file.
Referenced by getArgumentFromFile(), getExternalFiles(), reset(), and set().
|
private |
Referenced by getArgumentFromFile(), hasExternalFile(), and reset().
|
private |
Referenced by getMultiArgs(), hasMultipleArgs(), parseArgument(), and reset().
|
private |
|
private |
Flag telling if the parameter has a bounded argument value.
Referenced by isBounded(), set(), and setIsBounded().
|
private |
Flag telling if this parameter is mandatory.
A SimComponent with a mandatory parameter in the 'unset' state will not be selected to be part of a running simulation component.
Referenced by isRequired(), and setIsRequired().
|
private |
Flag set once the parameter has recieved the right argument.
Referenced by getMatrix(), getValue(), getVariableMatrix(), isSet(), reset(), set(), setIsSet(), and show_up().
|
private |
Flag telling if this parameter has temporal arguments.
Referenced by isTemporal(), parseArgument(), and reset().
|
private |
Multiple arguments.
Referenced by getMultiArgs(), parseArgument(), and reset().
|
private |
Pointer to the component that declared this parameter.
Referenced by getOwner(), and setOwner().
|
private |
Pointer to an ParamUpdater object.
Referenced by getUpdater(), parseArgument(), setUpdater(), and ~Param().
|
private |
The name of the parameter as read in the init file.
Referenced by getMatrix(), getName(), getVariableMatrix(), parse_matrix(), parseArgument(), parseTemporalArgument(), setName(), show_up(), and update().
|
private |
Generation at which the parameter has been set/updated.
Referenced by reset(), setAtGeneration(), and show_up().
|
private |
The temporal arguments.
Referenced by getTemporalArgs(), getUpdatingDates(), parseArgument(), parseTemporalArgument(), reset(), and update().
|
private |
The type of the argument, must one of DBL, INT, BOOL, STR or MAT (see types.h).
Referenced by getType(), getValue(), isMatrix(), set(), and setType().