bpp-core
2.2.0
|
The parameter list object. More...
#include <Bpp/Numeric/ParameterList.h>
Public Member Functions | |
ParameterList () | |
Build a new ParameterList object. More... | |
ParameterList (const ParameterList &pl) | |
Copy constructor. More... | |
ParameterList & | operator= (const ParameterList &pl) |
ParameterList * | clone () const |
Create a copy of this object and send a pointer to it. More... | |
virtual | ~ParameterList () |
size_t | size () const |
virtual const Parameter & | operator[] (size_t i) const |
virtual Parameter & | operator[] (size_t i) |
virtual const Parameter & | getParameter (const std::string &name) const throw (ParameterNotFoundException) |
Get the parameter with name name. More... | |
virtual double | getParameterValue (const std::string &name) const throw (ParameterNotFoundException) |
Get the value of the parameter with name name. More... | |
virtual Parameter & | getParameter (const std::string &name) throw (ParameterNotFoundException) |
Get the parameter with name name. More... | |
virtual ParameterList | subList (const std::vector< std::string > &names) const throw (ParameterNotFoundException) |
Get given parameters as a sublist. More... | |
virtual ParameterList | subList (const std::string &name) const throw (ParameterNotFoundException) |
Get given parameter as a sublist. More... | |
virtual ParameterList | subList (const std::vector< size_t > ¶meters) const |
Get given parameters as a sublist. More... | |
virtual ParameterList | subList (size_t parameter) const |
Get given parameter as a sublist. More... | |
virtual ParameterList | getCommonParametersWith (const ParameterList ¶ms) const |
Get the sublist containing all common parameter between this list and pl. More... | |
virtual std::vector< std::string > | getParameterNames () const |
Get all parameter names in the list. More... | |
virtual std::vector< std::string > | getMatchingParameterNames (const std::string &pattern) const |
Get all parameter names matching with the given name. Up to now, only "*" jokers are available. More... | |
virtual void | addParameter (const Parameter ¶m) throw (ParameterException) |
Add a new parameter at the end of the list. More... | |
virtual void | addParameter (Parameter *param) throw (ParameterException) |
Add a new parameter at the end of the list. More... | |
virtual void | setParameter (size_t index, const Parameter ¶m) throw (IndexOutOfBoundsException) |
Change given parameter. More... | |
virtual void | addParameters (const ParameterList ¶ms) throw (ParameterException) |
Add new parameters at the end of the list. More... | |
virtual void | includeParameters (const ParameterList ¶ms) |
Add parameters to the list. If the parameter already exists, only the value is updated, otherwise the new parameter is added at the end of the list. More... | |
virtual void | setParameterValue (const std::string &name, double value) throw (ParameterNotFoundException, ConstraintException) |
Set the value of parameter with name name to be equal to value. More... | |
virtual void | setAllParametersValues (const ParameterList ¶ms) throw (ParameterNotFoundException, ConstraintException) |
Set the parameters to be equals to params. More... | |
virtual void | setParametersValues (const ParameterList ¶ms) |
Update the parameters from the ones in params that have matching names. More... | |
A string name | |
Returns true if the Parameter of the given name exists. | |
virtual bool | hasParameter (const std::string &name) const |
virtual bool | testParametersValues (const ParameterList ¶ms) const |
Tests the parameters from params. More... | |
virtual bool | matchParametersValues (const ParameterList ¶ms, std::vector< size_t > *updatedParameters=0) throw (ConstraintException) |
Update the parameters from params. More... | |
virtual void | setAllParameters (const ParameterList ¶ms) throw (ParameterNotFoundException) |
Set the parameters to be equals to params. More... | |
virtual void | setParameters (const ParameterList ¶ms) throw (ParameterNotFoundException) |
Update the parameters from params. More... | |
virtual void | matchParameters (const ParameterList ¶ms) |
Update the parameters from params. More... | |
virtual void | deleteParameter (const std::string &name) throw (ParameterNotFoundException) |
Delete a parameter from the list. More... | |
virtual void | deleteParameters (const std::vector< std::string > &names, bool mustExist=true) throw (ParameterNotFoundException) |
Delete several parameters from the list. More... | |
virtual void | deleteParameter (size_t index) throw (IndexOutOfBoundsException) |
Delete a parameter from the list. More... | |
virtual void | deleteParameters (const std::vector< size_t > &indices) throw (IndexOutOfBoundsException) |
Delete several parameters from the list. More... | |
virtual size_t | whichParameterHasName (const std::string &name) const throw (ParameterNotFoundException) |
Get the position of a given parameter according to its name. More... | |
virtual void | printParameters (OutputStream &out) const |
Print all parameters. More... | |
virtual void | printParameters (std::ostream &out) const |
virtual void | reset () |
Reset the list: delete all parameters. More... | |
Private Attributes | |
std::vector< Parameter * > | parameters_ |
The parameter list object.
Definition at line 61 of file ParameterList.h.
|
inline |
Build a new ParameterList object.
Definition at line 71 of file ParameterList.h.
Referenced by clone().
ParameterList::ParameterList | ( | const ParameterList & | pl | ) |
Copy constructor.
All parameters in the list will be cloned.
Copy constructor:
Definition at line 51 of file ParameterList.cpp.
References parameters_, and size().
|
virtual |
|
virtual |
Add a new parameter at the end of the list.
param | The parameter to add to the list. |
Definition at line 224 of file ParameterList.cpp.
Referenced by bpp::AbstractParametrizable::addParameter_(), bpp::AbstractParameterAliasable::addParameter_(), bpp::AbstractParameterAliasable::aliasParameters(), bpp::DirichletDiscreteDistribution::discretize(), bpp::AbstractParameterAliasable::getAliasedParameters(), bpp::OneDimensionOptimizationTools::lineMinimization(), bpp::OneDimensionOptimizationTools::lineSearch(), bpp::Simplex::setFrequencies(), bpp::FullHmmTransitionMatrix::setTransitionProbabilities(), subList(), and bpp::NumTools::uniRoot().
|
virtual |
Add a new parameter at the end of the list.
This function is more efficient than its reference counterpart, as it avoid an object copy. The ParameterList will own the pointer after addition, if it is successful.
param | A ppointer toward the parameter to add to the list. |
Definition at line 233 of file ParameterList.cpp.
|
virtual |
Add new parameters at the end of the list.
params | The parameter list containing the new paramters to add to the list. |
Definition at line 264 of file ParameterList.cpp.
Referenced by bpp::AbstractParametrizable::addParameters_(), and bpp::AbstractParameterAliasable::addParameters_().
|
inlinevirtual |
Create a copy of this object and send a pointer to it.
Implements bpp::Clonable.
Definition at line 82 of file ParameterList.h.
References ParameterList().
Referenced by bpp::AbstractParameterAliasable::aliasParameters(), bpp::FullHmmTransitionMatrix::FullHmmTransitionMatrix(), includeParameters(), bpp::FullHmmTransitionMatrix::setTransitionProbabilities(), and subList().
|
virtual |
Delete a parameter from the list.
name | The name of the parameter to delete from the list. |
Definition at line 446 of file ParameterList.cpp.
References bpp::Parameter::getName().
Referenced by bpp::AbstractParametrizable::deleteParameter_(), and bpp::AbstractParameterAliasable::deleteParameter_().
|
virtual |
Delete a parameter from the list.
index | The position of the parameter to delete in the list. |
Definition at line 481 of file ParameterList.cpp.
|
virtual |
Delete several parameters from the list.
names | The names of the parameters to delete from the list. |
mustExist | If true, an exception is thrown if a name does not match an extant parameter. |
Definition at line 462 of file ParameterList.cpp.
Referenced by bpp::AbstractParametrizable::deleteParameters_().
|
virtual |
Delete several parameters from the list.
indices | The positions of the parameters to delete in the list. Duplicated positions will be considered only one time. |
Definition at line 490 of file ParameterList.cpp.
|
virtual |
Get the sublist containing all common parameter between this list and pl.
params | The list to compare to. |
Definition at line 162 of file ParameterList.cpp.
References bpp::Parameter::clone(), bpp::Parameter::getName(), hasParameter(), parameters_, and size().
|
virtual |
Get all parameter names matching with the given name. Up to now, only "*" jokers are available.
pattern | a pattern of name |
Definition at line 190 of file ParameterList.cpp.
References bpp::StringTokenizer::hasMoreToken(), bpp::StringTokenizer::nextToken(), parameters_, and size().
|
virtual |
Get the parameter with name name.
name | The name of the parameter to look for. |
ParameterNotFoundException | If no parameter with the given name is found. |
Definition at line 89 of file ParameterList.cpp.
References bpp::Parameter::getName().
Referenced by bpp::AbstractParameterAliasable::aliasParameters(), bpp::ParametersStopCondition::getCurrentTolerance(), bpp::AbstractParametrizable::getParameter(), bpp::AbstractParametrizable::getParameter_(), bpp::ParametersStopCondition::isToleranceReached(), matchParameters(), setParametersValues(), and testParametersValues().
|
virtual |
Get the parameter with name name.
name | The name of the parameter to look for. |
ParameterNotFoundException | If no parameter with the given name is found. |
Definition at line 111 of file ParameterList.cpp.
References bpp::Parameter::getName().
|
virtual |
Get all parameter names in the list.
Definition at line 178 of file ParameterList.cpp.
References parameters_, and size().
Referenced by bpp::NumTools::computeHessianMatrix(), bpp::BppODiscreteDistributionFormat::read(), and bpp::BppODiscreteDistributionFormat::write().
|
virtual |
Get the value of the parameter with name name.
name | The name of the parameter to look for. |
ParameterNotFoundException | If no parameter with the given name is found. |
Definition at line 100 of file ParameterList.cpp.
References bpp::Parameter::getName(), and bpp::Parameter::getValue().
Referenced by bpp::AbstractOptimizer::getParameterValue(), bpp::TwoPointsNumericalDerivative::updateDerivatives(), bpp::ThreePointsNumericalDerivative::updateDerivatives(), and bpp::FivePointsNumericalDerivative::updateDerivatives().
|
virtual |
Definition at line 421 of file ParameterList.cpp.
References bpp::Parameter::getName(), parameters_, and size().
Referenced by bpp::AbstractParameterAliasable::aliasParameters(), bpp::AbstractParameterAliasable::deleteParameter_(), bpp::AbstractParameterAliasable::getAliasedParameters(), getCommonParametersWith(), bpp::AbstractParametrizable::hasParameter(), bpp::ParametrizableAdapter::hasParameter(), includeParameters(), matchParameters(), setParametersValues(), and testParametersValues().
|
virtual |
Add parameters to the list. If the parameter already exists, only the value is updated, otherwise the new parameter is added at the end of the list.
params | The parameter list containing the new paramters to add to the list. |
Definition at line 251 of file ParameterList.cpp.
References clone(), hasParameter(), parameters_, setParameterValue(), and size().
|
virtual |
Update the parameters from params.
Only common parameters with params will be updated.
params | A list of parameters. |
Definition at line 433 of file ParameterList.cpp.
References getParameter(), hasParameter(), and parameters_.
|
virtual |
Update the parameters from params.
Only common parameters with params will be updated.
params | A list of parameters. |
updatedParameters | An optional pointer toward a vector which will store the indices of parameters for which a value has changed. Indices are relative on the input parameter list "params". |
Definition at line 363 of file ParameterList.cpp.
References bpp::Parameter::getConstraint(), bpp::Parameter::getValue(), bpp::Parameter::hasConstraint(), bpp::Constraint::isCorrect(), and bpp::Parameter::setValue().
Referenced by bpp::SimpleNewtonMultiDimensions::doStep(), bpp::SimpleMultiDimensions::doStep(), bpp::MetaOptimizer::doStep(), bpp::AbstractParameterAliasable::fireParameterChanged(), bpp::AbstractParametrizable::matchParametersValues(), and bpp::AbstractOptimizer::step().
ParameterList & ParameterList::operator= | ( | const ParameterList & | pl | ) |
Assignation operator:
Definition at line 63 of file ParameterList.cpp.
References parameters_, reset(), and size().
|
inlinevirtual |
Definition at line 96 of file ParameterList.h.
References parameters_.
|
inlinevirtual |
Definition at line 97 of file ParameterList.h.
References parameters_.
|
virtual |
Print all parameters.
Definition at line 515 of file ParameterList.cpp.
References bpp::OutputStream::endLine(), parameters_, and size().
Referenced by printParameters().
|
inlinevirtual |
Definition at line 377 of file ParameterList.h.
References printParameters().
|
virtual |
Reset the list: delete all parameters.
Definition at line 529 of file ParameterList.cpp.
References parameters_, and size().
Referenced by operator=(), bpp::AbstractParametrizable::resetParameters_(), bpp::AbstractParameterAliasable::resetParameters_(), and ~ParameterList().
|
virtual |
Set the parameters to be equals to params.
The list must contain exactly the same parameters (ie same names) than the parameters available.
params | A list with all parameters. |
Definition at line 399 of file ParameterList.cpp.
|
virtual |
Set the parameters to be equals to params.
The list must contain exactly the same parameters (ie same names) than the parameters available.
params | A list with all parameters. |
ParameterNotFoundException | If at least one name does not correspond to a parameter in the list. |
ConstraintException | If one value is incorrect (and the two parameter list do not have the same constraints). |
Definition at line 284 of file ParameterList.cpp.
References bpp::Parameter::getValue(), and bpp::Parameter::setValue().
Referenced by bpp::AbstractParametrizable::setAllParametersValues().
|
virtual |
Change given parameter.
index | The position of the parameter to alter. |
param | The parameter to add to the list. |
IndexOutOfBoundsException | if the index is not valid. |
Definition at line 242 of file ParameterList.cpp.
Referenced by bpp::AbstractOptimizer::autoParameter(), and bpp::BppODiscreteDistributionFormat::initialize_().
|
virtual |
Update the parameters from params.
params must be a subset of all parameters available.
params | A list containing all parameters to update. |
Definition at line 410 of file ParameterList.cpp.
Referenced by bpp::TwoPointsNumericalDerivative::updateDerivatives(), bpp::ThreePointsNumericalDerivative::updateDerivatives(), and bpp::FivePointsNumericalDerivative::updateDerivatives().
|
virtual |
Update the parameters from the ones in params that have matching names.
params | A list containing all parameters to update. |
ConstraintException | If one value is incorrect (and the two parameter list do not have the same constraints). |
Definition at line 305 of file ParameterList.cpp.
References bpp::Parameter::getConstraint(), getParameter(), bpp::Parameter::getValue(), bpp::Parameter::hasConstraint(), hasParameter(), bpp::Constraint::isCorrect(), parameters_, and bpp::Parameter::setValue().
Referenced by bpp::AbstractParametrizable::setParametersValues().
|
virtual |
Set the value of parameter with name name to be equal to value.
name | the name of the parameter to set. |
value | The value of the parameter. |
ParameterNotFoundException | If no parameter with the given name is found in the list. |
ConstraintException | If the value is incorrect. |
Definition at line 275 of file ParameterList.cpp.
References bpp::Parameter::setValue().
Referenced by bpp::FunctionTools::computeGrid(), bpp::DirichletDiscreteDistribution::discretize(), includeParameters(), and bpp::AbstractParametrizable::setParameterValue().
|
inline |
Definition at line 90 of file ParameterList.h.
References parameters_.
Referenced by bpp::AbstractParameterAliasable::aliasParameters(), bpp::AbstractOptimizer::autoParameter(), bpp::NumTools::computeHessianMatrix(), bpp::AbstractParametrizable::deleteParameter_(), bpp::ConjugateGradientMultiDimensions::doStep(), bpp::BfgsMultiDimensions::doStep(), bpp::PowellMultiDimensions::doStep(), bpp::FullHmmTransitionMatrix::fireParameterChanged(), bpp::ParametrizableCollection< N >::fireParameterChanged(), bpp::FullHmmTransitionMatrix::FullHmmTransitionMatrix(), getCommonParametersWith(), bpp::ParametersStopCondition::getCurrentTolerance(), bpp::NumCalcApplicationTools::getDefaultValue(), getMatchingParameterNames(), bpp::AbstractParameterAliasable::getNumberOfIndependentParameters(), bpp::DirectionFunction::getNumberOfParameters(), bpp::AbstractParametrizable::getNumberOfParameters(), bpp::AbstractParametrizable::getParameter_(), getParameterNames(), hasParameter(), bpp::AbstractOptimizer::ignoreConstraints(), includeParameters(), bpp::BppODiscreteDistributionFormat::initialize_(), bpp::ParametersStopCondition::isToleranceReached(), bpp::OneDimensionOptimizationTools::lineMinimization(), bpp::OneDimensionOptimizationTools::lineSearch(), operator=(), bpp::BackupListener::optimizationStepPerformed(), ParameterList(), bpp::ParametersStopCondition::ParametersStopCondition(), printParameters(), bpp::AbstractOptimizer::printPoint(), bpp::ParametrizableCollection< N >::removeObject(), reset(), bpp::BfgsMultiDimensions::setDirection(), bpp::AbstractParameterAliasable::setNamespace(), bpp::FullHmmTransitionMatrix::setTransitionProbabilities(), subList(), and bpp::BppOParametrizableFormat::write().
|
virtual |
Get given parameters as a sublist.
names | Name of the parameters to be included in the list. |
ParameterNotFoundException | If at least one name does not correspond to a parameter in the list. |
Definition at line 122 of file ParameterList.cpp.
References addParameter().
Referenced by bpp::FunctionTools::computeGrid(), bpp::ReparametrizationFunctionWrapper::setParameters(), bpp::AbstractParametrizable::setParameterValue(), bpp::AbstractNumericalDerivative::setParameterValue(), bpp::TwoPointsNumericalDerivative::updateDerivatives(), bpp::ThreePointsNumericalDerivative::updateDerivatives(), bpp::FivePointsNumericalDerivative::updateDerivatives(), and bpp::BppOParametrizableFormat::write().
|
virtual |
Get given parameter as a sublist.
name | Name of the parameter to be included in the list. |
ParameterNotFoundException | If no parameter with the given name is found. |
Definition at line 134 of file ParameterList.cpp.
References addParameter().
|
virtual |
Get given parameters as a sublist.
parameters | Positions of the parameters to be included in the list. |
Definition at line 143 of file ParameterList.cpp.
References parameters_, and size().
|
virtual |
Get given parameter as a sublist.
parameter | Position of the parameters to be included in the list. |
Definition at line 154 of file ParameterList.cpp.
References clone(), parameters_, and size().
|
virtual |
Tests the parameters from params.
Only common parameters with params are compared.
params | A list of parameters. |
Definition at line 333 of file ParameterList.cpp.
References bpp::Parameter::getConstraint(), getParameter(), bpp::Parameter::getValue(), bpp::Parameter::hasConstraint(), hasParameter(), bpp::Constraint::isCorrect(), and parameters_.
|
virtual |
Get the position of a given parameter according to its name.
name | The name of the parameter to look for. |
ParameterNotFoundException | If no parameter with the given name is found. |
Definition at line 505 of file ParameterList.cpp.
|
private |
Definition at line 65 of file ParameterList.h.
Referenced by getCommonParametersWith(), getMatchingParameterNames(), getParameterNames(), hasParameter(), includeParameters(), matchParameters(), operator=(), operator[](), ParameterList(), printParameters(), reset(), setParametersValues(), size(), subList(), and testParametersValues().