|
Nemo
2.2.0
|
Parameters container, implemented in each SimComponent. More...
#include <param.h>
Collaboration diagram for ParamSet:Public Member Functions | |
| ParamSet () | |
| ParamSet (const ParamSet &PS) | |
| ~ParamSet () | |
| void | reset () |
| Put the container in the unset state, reset each Param it contains. | |
| void | clear () |
| Empties the parameter containers (no delete). | |
| bool | check_consistency () |
| Checks for the status of the required parameters. | |
| void | show_up () |
| print info to stdout. | |
| void | print (ofstream &FILE) |
| print all set parameters to the outpout file stream | |
| int | size () |
| Returns the number of parameters contained. | |
| map< string, Param * > & | getAllParams () |
| Returns the complete list of parameters. | |
| ParamSet & | operator= (const ParamSet &PS) |
Accessors to Param members. | |
| void | add_param (Param *param) |
| Adds the param argument to the list. | |
| void | add_param (string Name, param_t Type, bool mandatory, bool isBounded, double low_bnd, double up_bnd) |
| Adds a new param specified by arguments to the list. | |
| void | add_param (string Name, param_t Type, bool mandatory, bool isBounded, double low_bnd, double up_bnd, ParamUpdaterBase *updater) |
| bool | set_param (string Name, string Arg) |
| Look for a param named "Name" and try to set it with the "Arg" argument string. | |
| Param * | get_param (string name) |
| Look for a param "name" in its parameters list. | |
| bool | update_param (string Name, unsigned int generation) |
| Calls the updating procedure of each of its Param. | |
| void | setName (string value) |
| Sets the container's name. | |
| void | setIsRequired (bool value) |
| Sets the _isRequired flag meaning this container is mandatory and must be set in order to run a simulation. | |
| void | setOwner (SimComponent *owner) |
| Sets the pointer to the SimComponents that owns this set. | |
| bool | isSet () |
| Accessor to the status flag. | |
| string | getName () |
| Name accessor. | |
| bool | isRequired () |
| Accessor to the mandatory flag. | |
| bool | isSet (string name) |
| Accessor to the parameters status flag. | |
| bool | isMatrix (string name) |
| Check if the parameter "name" is of matrix type. | |
| string | getArg (string name) |
| Accessor to the parameters argument string. | |
| double | getValue (string name) |
| Accessor the parameters value. | |
| void | getMatrix (string name, TMatrix *mat) |
| Accessor to the parameters matrix. | |
| list< ParamUpdaterBase * > | getUpdaters () |
| Collects the parameter updaters from the set of parameters. | |
Private Attributes | |
| string | _name |
| bool | _isSet |
| bool | _isRequired |
| map< string, Param * > | _params |
| SimComponent * | _myOwner |
| Pointer to the component that declared this parameter. | |
Parameters container, implemented in each SimComponent.
A SimComponent is added to the set of active components of a simulation only if all its required parameters are set (isSet = true).
| ParamSet::ParamSet | ( | ) | [inline] |
Definition at line 192 of file param.h.
: _isSet(0), _isRequired(0) { }
| ParamSet::ParamSet | ( | const ParamSet & | PS | ) |
Definition at line 367 of file param.cc.
: _name(PS._name), _isSet(PS._isSet), _isRequired(PS._isRequired) { map<string, Param*>::iterator param; if( _params.size() ) { param = _params.begin(); while(param != _params.end()) { delete param->second; param++; } _params.clear(); } map<string, Param*> PS_params = PS._params; param = PS_params.begin(); while(param != PS_params.end()) { _params[param->first] = new Param( *param->second ); param++; } }
| ParamSet::~ParamSet | ( | ) |
| void ParamSet::add_param | ( | Param * | param | ) | [inline] |
Adds the param argument to the list.
Definition at line 215 of file param.h.
References Param::getName().
Referenced by SimComponent::add_parameter(), and ParamManager::ParamManager().
| void ParamSet::add_param | ( | string | Name, |
| param_t | Type, | ||
| bool | mandatory, | ||
| bool | isBounded, | ||
| double | low_bnd, | ||
| double | up_bnd | ||
| ) | [inline] |
Adds a new param specified by arguments to the list.
| Name | the name of the parameter |
| Type | the type of the parameter |
| mandatory | specifies if this parameter is required and must be set for the container to gain the "set" status |
| isBounded | specified whether this parameter is bounded |
| low_bnd | the lower value the parameter can take, used if isBounded is true |
| up_bnd | the upper value the parameter can take, used if isBounded is true |
Definition at line 224 of file param.h.
References add_param().
Referenced by add_param().
{add_param(Name, Type, mandatory, isBounded, low_bnd, up_bnd, 0);}
| void ParamSet::add_param | ( | string | Name, |
| param_t | Type, | ||
| bool | mandatory, | ||
| bool | isBounded, | ||
| double | low_bnd, | ||
| double | up_bnd, | ||
| ParamUpdaterBase * | updater | ||
| ) |
| bool ParamSet::check_consistency | ( | ) |
Checks for the status of the required parameters.
Definition at line 482 of file param.cc.
{
map<string, Param*>::iterator param = _params.begin();
bool isOK = true;
bool touched = false;
while(param != _params.end()) {
//check if all required field have been set properly
if(param->second->isRequired())
isOK &= param->second->isSet();
//else we don't care..
//check if at least one param has been set
touched |= param->second->isSet();
param++;
}
_isSet = isOK;
//return isOk or check if _isRequired in case no params are set (untouched params)
return ( isOK | (!_isRequired));// & !touched) );
}
| void ParamSet::clear | ( | ) | [inline] |
| Param * ParamSet::get_param | ( | string | name | ) |
Look for a param "name" in its parameters list.
Definition at line 459 of file param.cc.
Referenced by SimComponent::get_parameter().
| map<string, Param*>& ParamSet::getAllParams | ( | ) | [inline] |
| string ParamSet::getArg | ( | string | name | ) | [inline] |
Accessor to the parameters argument string.
Definition at line 260 of file param.h.
Referenced by LCE_Resize::execute(), SimRunner::init(), LCE_Selection_base::set_fit_model(), LCE_Selection_base::set_sel_model(), LCE_StatServiceNotifier::setParameters(), LCE_Disperse_EvolDisp::setParameters(), TProtoDeletMutations_bitstring::setSelectionParameters(), Metapop::setSourceParameters(), and LCE_Resize::updateParameters().
{return (get_param(name))->getArg();}
| void ParamSet::getMatrix | ( | string | name, |
| TMatrix * | mat | ||
| ) | [inline] |
Accessor to the parameters matrix.
Definition at line 264 of file param.h.
Referenced by LCE_Disperse_base::setParameters(), LCE_Resize::setParameters(), Metapop::setPatchCapacities(), LCE_Selection_base::setSelectionMatrix(), LCE_Selection_base::setSpatialMatrix(), and LCE_Resize::updateParameters().
{return (get_param(name))->getMatrix(mat);}
| string ParamSet::getName | ( | ) | [inline] |
Name accessor.
Definition at line 252 of file param.h.
Referenced by SimComponent::get_name().
{return _name;}
| list< ParamUpdaterBase * > ParamSet::getUpdaters | ( | ) |
Collects the parameter updaters from the set of parameters.
Definition at line 426 of file param.cc.
Referenced by SimComponent::loadUpdaters().
| double ParamSet::getValue | ( | string | name | ) | [inline] |
Accessor the parameters value.
Definition at line 262 of file param.h.
Referenced by SimComponent::get_parameter_value(), SimRunner::init(), SimRunner::init_random_seed(), LCE_Breed_base::setMatingSystem(), LCE_Disperse_base::setParameters(), LCE_StatServiceNotifier::setParameters(), LCE_Disperse_EvolDisp::setParameters(), Metapop::setPopulationParameters(), and Metapop::setSourceParameters().
{return (get_param(name))->getValue();}
| bool ParamSet::isMatrix | ( | string | name | ) | [inline] |
Check if the parameter "name" is of matrix type.
Definition at line 258 of file param.h.
Referenced by LCE_Resize::setParameters(), and Metapop::setPopulationParameters().
{return (get_param(name))->isMatrix();}
| bool ParamSet::isRequired | ( | ) | [inline] |
| bool ParamSet::isSet | ( | ) | [inline] |
Accessor to the status flag.
Definition at line 250 of file param.h.
Referenced by SimRunner::init(), Metapop::init(), SimRunner::init_random_seed(), LCE_Selection_base::set_fit_model(), LCE_Selection_base::set_sel_model(), LCE_Disperse_base::setIsland_PropagulePool_Matrix(), LCE_Disperse_base::setLatticeMatrix(), LCE_Breed_base::setMatingSystem(), LCE_Disperse_base::setParameters(), LCE_Disperse_EvolDisp::setParameters(), Metapop::setPopulationParameters(), Metapop::setSourceParameters(), and LCE_Selection_base::setSpatialMatrix().
{return _isSet;}
| bool ParamSet::isSet | ( | string | name | ) | [inline] |
Definition at line 504 of file param.cc.
{
if(this != &PS) {
_name = PS._name;
_isSet = PS._isSet;
_isRequired = PS._isRequired;
map<string, Param*>::iterator param;
if( _params.size() ) {
param = _params.begin();
while(param != _params.end()) {
delete param->second;
param++;
}
_params.clear();
}
map<string, Param*> PS_params = PS._params;
param = PS_params.begin();
while(param != PS_params.end()) {
_params[param->first] = new Param( *param->second );
param++;
}
}
return *this;
}
| void ParamSet::print | ( | ofstream & | FILE | ) |
print all set parameters to the outpout file stream
| void ParamSet::reset | ( | ) |
| bool ParamSet::set_param | ( | string | Name, |
| string | Arg | ||
| ) |
Look for a param named "Name" and try to set it with the "Arg" argument string.
| Name | the name of the parameter to find in the list |
| Arg | the argument string as found in the init params |
Definition at line 439 of file param.cc.
Referenced by LCE_Resize::execute().
{
map<string, Param*>::iterator param = _params.find(Name);
string error_msg;
if(param == _params.end()) {
// error("could not set \"%s\": parameter not found.\n",Name.c_str());
//exist silently
return false;
}
if( !param->second->set(Arg, error_msg) ) {
error("could not set \"%s\": %s.\n", Name.c_str(), error_msg.c_str());
return false;
} else
return true;
}
| void ParamSet::setIsRequired | ( | bool | value | ) | [inline] |
Sets the _isRequired flag meaning this container is mandatory and must be set in order to run a simulation.
Definition at line 246 of file param.h.
Referenced by ParamManager::ParamManager(), and SimComponent::set_paramset().
{_isRequired = value;}
| void ParamSet::setName | ( | string | value | ) | [inline] |
Sets the container's name.
Definition at line 244 of file param.h.
Referenced by ParamManager::ParamManager(), and SimComponent::set_paramset().
{_name = value;}
| void ParamSet::setOwner | ( | SimComponent * | owner | ) | [inline] |
Sets the pointer to the SimComponents that owns this set.
Definition at line 248 of file param.h.
Referenced by ParamManager::ParamManager(), and SimComponent::set_paramset().
{_myOwner = owner;}
| void ParamSet::show_up | ( | ) |
| int ParamSet::size | ( | ) | [inline] |
| bool ParamSet::update_param | ( | string | Name, |
| unsigned int | generation | ||
| ) |
bool ParamSet::_isRequired [private] |
bool ParamSet::_isSet [private] |
SimComponent* ParamSet::_myOwner [private] |
string ParamSet::_name [private] |
map<string, Param*> ParamSet::_params [private] |
1.7.5.1 -- Nemo is hosted by