bpp-core3
3.0.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 std::shared_ptr< Parameter > & | getSharedParameter (size_t i) const |
virtual std::shared_ptr< Parameter > & | getSharedParameter (size_t i) |
virtual const Parameter & | getParameter (const std::string &name) const |
Get the parameter with name name. More... | |
virtual const std::shared_ptr< Parameter > & | getSharedParameter (const std::string &name) const |
Get the parameter with name name as a shared pointer. More... | |
virtual double | getParameterValue (const std::string &name) const |
Get the value of the parameter with name name. More... | |
virtual Parameter & | getParameter (const std::string &name) |
Get the parameter with name name. More... | |
virtual std::shared_ptr< Parameter > & | getSharedParameter (const std::string &name) |
Get the parameter with name name as a shared pointer. More... | |
virtual ParameterList | createSubList (const std::vector< std::string > &names) const |
Get given parameters as a sublist. More... | |
virtual ParameterList | shareSubList (const std::vector< std::string > &names) const |
Share given parameters as a sublist. More... | |
virtual ParameterList | createSubList (const std::string &name) const |
Get given parameter as a sublist. More... | |
virtual ParameterList | createSubList (const std::vector< size_t > ¶meters) const |
Get given parameters as a sublist. More... | |
virtual ParameterList | shareSubList (const std::vector< size_t > ¶meters) const |
Share given parameters in a sublist. More... | |
virtual ParameterList | createSubList (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) |
Add a new parameter at the end of the list. More... | |
virtual void | addParameter (Parameter *param) |
Add a new parameter at the end of the list. More... | |
virtual void | shareParameter (const std::shared_ptr< Parameter > ¶m) |
Share a parameter at the end of the list. More... | |
virtual void | setParameter (size_t index, const Parameter ¶m) |
Change given parameter. More... | |
virtual void | addParameters (const ParameterList ¶ms) |
Add new parameters at the end of the list. More... | |
virtual void | shareParameters (const ParameterList ¶ms) |
Share parameters with a given list. They are added the end of this 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) |
Set the value of parameter with name name to be equal to value. More... | |
virtual void | setAllParametersValues (const ParameterList ¶ms) |
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) |
Update the parameters from params. More... | |
virtual void | setAllParameters (const ParameterList ¶ms) |
Set the parameters to be equals to params. More... | |
virtual void | setParameters (const ParameterList ¶ms) |
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) |
Delete a parameter from the list. More... | |
virtual void | deleteParameters (const std::vector< std::string > &names, bool mustExist=true) |
Delete several parameters from the list. More... | |
virtual void | deleteParameter (size_t index) |
Delete a parameter from the list. More... | |
virtual void | deleteParameters (const std::vector< size_t > &indices) |
Delete several parameters from the list. More... | |
virtual size_t | whichParameterHasName (const std::string &name) const |
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< std::shared_ptr< Parameter > > | parameters_ |
The parameter list object.
Definition at line 63 of file ParameterList.h.
|
inline |
Build a new ParameterList object.
Definition at line 73 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 53 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 293 of file ParameterList.cpp.
References bpp::Parameter::clone(), bpp::Parameter::getName(), hasParameter(), and parameters_.
Referenced by bpp::AbstractParametrizable::addParameter_(), addParameters(), bpp::AbstractParameterAliasable::aliasParameters(), createSubList(), bpp::DirichletDiscreteDistribution::discretize(), bpp::ParametrizableCollection< N >::fireParameterChanged(), bpp::AbstractParameterAliasable::getAliasedParameters(), bpp::AbstractParameterAliasable::getFromParameters(), bpp::OneDimensionOptimizationTools::lineMinimization(), bpp::OneDimensionOptimizationTools::lineSearch(), bpp::Simplex::setFrequencies(), bpp::FullHmmTransitionMatrix::setTransitionProbabilities(), 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 302 of file ParameterList.cpp.
References bpp::Parameter::getName(), hasParameter(), and parameters_.
|
virtual |
Add new parameters at the end of the list.
params | The parameter list containing the new parameters to add to the list. |
Definition at line 345 of file ParameterList.cpp.
References addParameter(), and size().
Referenced by bpp::AbstractParametrizable::addParameters_().
|
inlinevirtual |
Create a copy of this object and send a pointer to it.
Implements bpp::Clonable.
Definition at line 84 of file ParameterList.h.
References ParameterList().
Referenced by createSubList(), includeParameters(), and bpp::FullHmmTransitionMatrix::setTransitionProbabilities().
|
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 182 of file ParameterList.cpp.
References addParameter(), and getParameter().
|
virtual |
Get given parameters as a sublist.
parameters | Positions of the parameters to be included in the list. |
Definition at line 192 of file ParameterList.cpp.
References clone(), parameters_, and size().
|
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 156 of file ParameterList.cpp.
References addParameter(), and getParameter().
Referenced by bpp::FunctionTools::computeGrid(), bpp::ReparametrizationFunctionWrapper::setParameters(), bpp::AbstractParametrizable::setParameterValue(), bpp::AbstractNumericalDerivative::setParameterValue(), bpp::FivePointsNumericalDerivative::updateDerivatives(), bpp::ThreePointsNumericalDerivative::updateDerivatives(), bpp::TwoPointsNumericalDerivative::updateDerivatives(), and bpp::BppOParametrizableFormat::write().
|
virtual |
Get given parameter as a sublist.
parameter | Position of the parameters to be included in the list. |
Definition at line 219 of file ParameterList.cpp.
References clone(), parameters_, and size().
|
virtual |
Delete a parameter from the list.
name | The name of the parameter to delete from the list. |
Definition at line 532 of file ParameterList.cpp.
References parameters_.
Referenced by bpp::AbstractParameterAliasable::aliasParameters(), bpp::AbstractParameterAliasable::deleteParameter_(), bpp::AbstractParametrizable::deleteParameter_(), and deleteParameters().
|
virtual |
Delete a parameter from the list.
index | The position of the parameter to delete in the list. |
Definition at line 565 of file ParameterList.cpp.
References parameters_, and size().
|
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 573 of file ParameterList.cpp.
References parameters_, and size().
|
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 546 of file ParameterList.cpp.
References deleteParameter().
Referenced by bpp::AbstractParametrizable::deleteParameters_().
|
virtual |
Get the sublist containing all common parameter between this list and pl.
params | The list to compare to. |
Definition at line 229 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 257 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 129 of file ParameterList.cpp.
References bpp::Parameter::getName(), 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(), parameters_, and size().
Referenced by bpp::AbstractParameterAliasable::aliasParameters(), createSubList(), bpp::MetaOptimizer::doInit(), bpp::ParametersStopCondition::getCurrentTolerance(), bpp::AbstractParametrizable::getParameter(), bpp::AbstractParametrizable::getParameter_(), bpp::ParametersStopCondition::isToleranceReached(), matchParameters(), matchParametersValues(), setAllParameters(), setAllParametersValues(), setParameters(), setParametersValues(), setParameterValue(), and testParametersValues().
|
virtual |
Get all parameter names in the list.
Definition at line 245 of file ParameterList.cpp.
References parameters_, and size().
Referenced by bpp::NumTools::computeHessianMatrix(), bpp::ReparametrizationFunctionWrapper::setParameters(), and bpp::BppODiscreteDistributionFormat::writeDiscreteDistribution().
|
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 116 of file ParameterList.cpp.
References bpp::Parameter::getName(), bpp::Parameter::getValue(), parameters_, and size().
Referenced by bpp::AbstractOptimizer::getParameterValue(), bpp::FivePointsNumericalDerivative::updateDerivatives(), bpp::ThreePointsNumericalDerivative::updateDerivatives(), and bpp::TwoPointsNumericalDerivative::updateDerivatives().
|
virtual |
Get the parameter with name name as a shared pointer.
name | The name of the parameter to look for. |
ParameterNotFoundException | If no parameter with the given name is found. |
Definition at line 142 of file ParameterList.cpp.
References parameters_, and size().
|
virtual |
Get the parameter with name name as a shared pointer.
name | The name of the parameter to look for. |
ParameterNotFoundException | If no parameter with the given name is found. |
Definition at line 102 of file ParameterList.cpp.
References parameters_, and size().
|
inlinevirtual |
Definition at line 106 of file ParameterList.h.
References parameters_.
|
inlinevirtual |
Definition at line 105 of file ParameterList.h.
References parameters_.
Referenced by bpp::AbstractParametrizable::getSharedParameter(), shareParameters(), and shareSubList().
|
virtual |
Definition at line 507 of file ParameterList.cpp.
References bpp::Parameter::getName(), parameters_, and size().
Referenced by addParameter(), bpp::AbstractParameterAliasable::aliasParameters(), bpp::AbstractParameterAliasable::deleteParameter_(), bpp::MetaOptimizer::doInit(), bpp::AbstractParameterAliasable::getAliasedParameters(), getCommonParametersWith(), bpp::AbstractParameterAliasable::getFromParameters(), bpp::AbstractParameterAliasable::hasIndependentParameter(), bpp::AbstractParametrizable::hasParameter(), bpp::ParametrizableAdapter::hasParameter(), includeParameters(), matchParameters(), matchParametersValues(), setParametersValues(), shareParameter(), testParametersValues(), bpp::FivePointsNumericalDerivative::updateDerivatives(), bpp::ThreePointsNumericalDerivative::updateDerivatives(), and bpp::TwoPointsNumericalDerivative::updateDerivatives().
|
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 332 of file ParameterList.cpp.
References clone(), hasParameter(), parameters_, setParameterValue(), and size().
Referenced by bpp::AbstractParametrizable::includeParameters_().
|
virtual |
Update the parameters from params.
Only common parameters with params will be updated.
params | A list of parameters. |
Definition at line 519 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 451 of file ParameterList.cpp.
References bpp::Parameter::getConstraint(), getParameter(), bpp::Parameter::getValue(), bpp::Parameter::hasConstraint(), hasParameter(), parameters_, and bpp::Parameter::setValue().
Referenced by bpp::MetaOptimizer::doInit(), bpp::MetaOptimizer::doStep(), bpp::SimpleMultiDimensions::doStep(), bpp::SimpleNewtonMultiDimensions::doStep(), bpp::AbstractParametrizable::matchParametersValues(), and bpp::AbstractOptimizer::step().
ParameterList & ParameterList::operator= | ( | const ParameterList & | pl | ) |
Assignation operator:
Definition at line 65 of file ParameterList.cpp.
References parameters_, and size().
|
inlinevirtual |
Definition at line 99 of file ParameterList.h.
References parameters_.
|
inlinevirtual |
Definition at line 98 of file ParameterList.h.
References parameters_.
|
virtual |
Print all parameters.
Definition at line 600 of file ParameterList.cpp.
References bpp::OutputStream::endLine(), parameters_, and size().
Referenced by printParameters().
|
inlinevirtual |
Definition at line 441 of file ParameterList.h.
References printParameters().
|
virtual |
Reset the list: delete all parameters.
Definition at line 614 of file ParameterList.cpp.
References parameters_.
Referenced by bpp::AbstractParameterAliasable::resetParameters_(), bpp::AbstractParametrizable::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 487 of file ParameterList.cpp.
References getParameter(), and parameters_.
|
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 373 of file ParameterList.cpp.
References getParameter(), bpp::Parameter::getValue(), parameters_, 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 322 of file ParameterList.cpp.
References bpp::Parameter::clone(), parameters_, and size().
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 497 of file ParameterList.cpp.
References getParameter(), and parameters_.
Referenced by bpp::DirectionFunction::setParameters(), bpp::FivePointsNumericalDerivative::updateDerivatives(), bpp::ThreePointsNumericalDerivative::updateDerivatives(), and bpp::TwoPointsNumericalDerivative::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 393 of file ParameterList.cpp.
References bpp::Parameter::getConstraint(), getParameter(), bpp::Parameter::getValue(), bpp::Parameter::hasConstraint(), hasParameter(), 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 365 of file ParameterList.cpp.
References getParameter(), and bpp::Parameter::setValue().
Referenced by bpp::FunctionTools::computeGrid(), bpp::DirichletDiscreteDistribution::discretize(), includeParameters(), bpp::AbstractParametrizable::setParameterValue(), and shareParameter().
|
virtual |
Share a parameter at the end of the list.
param | The shared_ptr parameter to add to the list. |
Definition at line 311 of file ParameterList.cpp.
References hasParameter(), parameters_, and setParameterValue().
Referenced by bpp::AbstractParameterAliasable::AbstractParameterAliasable(), bpp::AbstractParameterAliasable::addParameter_(), bpp::AbstractParameterAliasable::addParameters_(), bpp::AbstractParameterAliasable::includeParameters_(), bpp::AbstractParameterAliasable::operator=(), bpp::AbstractParameterAliasable::shareParameter_(), bpp::AbstractParametrizable::shareParameter_(), shareParameters(), bpp::AbstractParameterAliasable::shareParameters_(), shareSubList(), and bpp::AbstractParameterAliasable::unaliasParameters().
|
virtual |
Share parameters with a given list. They are added the end of this list.
params | The parameter list containing the parameters to share with to the list. |
Definition at line 355 of file ParameterList.cpp.
References getSharedParameter(), shareParameter(), and size().
Referenced by bpp::AbstractParameterAliasable::aliasParameters(), and bpp::AbstractParametrizable::shareParameters_().
|
virtual |
Share given parameters in a sublist.
parameters | Positions of the parameters to be included in the list. |
Definition at line 205 of file ParameterList.cpp.
References parameters_, shareParameter(), and size().
|
virtual |
Share 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 169 of file ParameterList.cpp.
References getSharedParameter(), and shareParameter().
Referenced by bpp::AbstractParametrizable::matchParametersValues().
|
inline |
Definition at line 92 of file ParameterList.h.
References parameters_.
Referenced by bpp::AbstractParameterAliasable::AbstractParameterAliasable(), addParameters(), bpp::AbstractParameterAliasable::addParameters_(), bpp::AbstractParameterAliasable::aliasParameters(), bpp::AbstractOptimizer::autoParameter(), bpp::NumTools::computeHessianMatrix(), createSubList(), deleteParameter(), bpp::AbstractParametrizable::deleteParameter_(), deleteParameters(), bpp::BfgsMultiDimensions::doInit(), bpp::BrentOneDimension::doInit(), bpp::ConjugateGradientMultiDimensions::doInit(), bpp::DownhillSimplexMethod::doInit(), bpp::GoldenSectionSearch::doInit(), bpp::NewtonBacktrackOneDimension::doInit(), bpp::NewtonOneDimension::doInit(), bpp::PowellMultiDimensions::doInit(), bpp::SimpleMultiDimensions::doInit(), bpp::SimpleNewtonMultiDimensions::doInit(), bpp::BfgsMultiDimensions::doStep(), bpp::ConjugateGradientMultiDimensions::doStep(), bpp::PowellMultiDimensions::doStep(), bpp::ParametrizableCollection< N >::fireParameterChanged(), getCommonParametersWith(), bpp::ParametersStopCondition::getCurrentTolerance(), bpp::NumCalcApplicationTools::getDefaultValue(), getMatchingParameterNames(), bpp::AbstractParameterAliasable::getNumberOfIndependentParameters(), bpp::AbstractParametrizable::getNumberOfParameters(), bpp::DirectionFunction::getNumberOfParameters(), getParameter(), bpp::AbstractParametrizable::getParameter_(), getParameterNames(), bpp::ParametrizableCollection< N >::getParametersForObject(), getParameterValue(), getSharedParameter(), hasParameter(), bpp::AbstractOptimizer::ignoreConstraints(), includeParameters(), bpp::AbstractParameterAliasable::includeParameters_(), bpp::AbstractOptimizer::init(), bpp::BppODiscreteDistributionFormat::initialize_(), bpp::ParametersStopCondition::isToleranceReached(), bpp::OneDimensionOptimizationTools::lineMinimization(), bpp::OneDimensionOptimizationTools::lineSearch(), bpp::AbstractParameterAliasable::operator=(), operator=(), bpp::BackupListener::optimizationStepPerformed(), ParameterList(), bpp::ParametersStopCondition::ParametersStopCondition(), printParameters(), bpp::AbstractOptimizer::printPoint(), bpp::ParametrizableCollection< N >::removeObject(), bpp::BfgsMultiDimensions::setDirection(), setParameter(), bpp::FullHmmTransitionMatrix::setTransitionProbabilities(), shareParameters(), bpp::AbstractParameterAliasable::shareParameters_(), shareSubList(), whichParameterHasName(), and bpp::BppOParametrizableFormat::write().
|
virtual |
Tests the parameters from params.
Only common parameters with params are compared.
params | A list of parameters. |
Definition at line 421 of file ParameterList.cpp.
References bpp::Parameter::getConstraint(), getParameter(), bpp::Parameter::getValue(), bpp::Parameter::hasConstraint(), hasParameter(), 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 589 of file ParameterList.cpp.
References parameters_, and size().
|
private |
Definition at line 67 of file ParameterList.h.
Referenced by addParameter(), createSubList(), deleteParameter(), deleteParameters(), getCommonParametersWith(), getMatchingParameterNames(), getParameter(), getParameterNames(), getParameterValue(), getSharedParameter(), hasParameter(), includeParameters(), matchParameters(), matchParametersValues(), operator=(), operator[](), ParameterList(), printParameters(), reset(), setAllParameters(), setAllParametersValues(), setParameter(), setParameters(), setParametersValues(), shareParameter(), shareSubList(), size(), testParametersValues(), and whichParameterHasName().