bpp-core  2.1.0
bpp::ParameterList Class Reference

The parameter list object. More...

#include <Bpp/Numeric/ParameterList.h>

+ Inheritance diagram for bpp::ParameterList:
+ Collaboration diagram for bpp::ParameterList:

List of all members.

Public Member Functions

 ParameterList ()
 Build a new ParameterList object.
 ParameterList (const ParameterList &pl)
 Copy constructor.
ParameterListoperator= (const ParameterList &pl)
ParameterListclone () const
 Create a copy of this object and send a pointer to it.
virtual ~ParameterList ()
size_t size () const
virtual const Parameteroperator[] (size_t i) const
virtual Parameteroperator[] (size_t i)
virtual const ParametergetParameter (const std::string &name) const throw (ParameterNotFoundException)
 Get the parameter with name name.
virtual double getParameterValue (const std::string &name) const throw (ParameterNotFoundException)
 Get the value of the parameter with name name.
virtual ParametergetParameter (const std::string &name) throw (ParameterNotFoundException)
 Get the parameter with name name.
virtual ParameterList subList (const std::vector< std::string > &names) const throw (ParameterNotFoundException)
 Get given parameters as a sublist.
virtual ParameterList subList (const std::string &name) const throw (ParameterNotFoundException)
 Get given parameter as a sublist.
virtual ParameterList subList (const std::vector< size_t > &parameters) const
 Get given parameters as a sublist.
virtual ParameterList subList (size_t parameter) const
 Get given parameter as a sublist.
virtual ParameterList getCommonParametersWith (const ParameterList &params) const
 Get the sublist containing all common parameter between this list and pl.
virtual std::vector< std::string > getParameterNames () const
 Get all parameter names in the list.
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.
virtual void addParameter (const Parameter &param) throw (ParameterException)
 Add a new parameter at the end of the list.
virtual void addParameter (Parameter *param) throw (ParameterException)
 Add a new parameter at the end of the list.
virtual void setParameter (size_t index, const Parameter &param) throw (IndexOutOfBoundsException)
 Change given parameter.
virtual void addParameters (const ParameterList &params) throw (ParameterException)
 Add new parameters at the end of the list.
virtual void includeParameters (const ParameterList &params)
 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.
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.
virtual void setAllParametersValues (const ParameterList &params) throw (ParameterNotFoundException, ConstraintException)
 Set the parameters to be equals to params.
virtual void setParametersValues (const ParameterList &params)
 Update the parameters from the ones in params that have matching names.
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 &params) const
 Tests the parameters from params.
virtual bool matchParametersValues (const ParameterList &params) throw (ConstraintException)
 Update the parameters from params.
virtual void setAllParameters (const ParameterList &params) throw (ParameterNotFoundException)
 Set the parameters to be equals to params.
virtual void setParameters (const ParameterList &params) throw (ParameterNotFoundException)
 Update the parameters from params.
virtual void matchParameters (const ParameterList &params)
 Update the parameters from params.
virtual void deleteParameter (const std::string &name) throw (ParameterNotFoundException)
 Delete a parameter from the list.
virtual void deleteParameters (const std::vector< std::string > &names) throw (ParameterNotFoundException)
 Delete several parameters from the list.
virtual void deleteParameter (size_t index) throw (IndexOutOfBoundsException)
 Delete a parameter from the list.
virtual void deleteParameters (const std::vector< size_t > &indices) throw (IndexOutOfBoundsException)
 Delete several parameters from the list.
virtual size_t whichParameterHasName (const std::string &name) const throw (ParameterNotFoundException)
 Get the position of a given parameter according to its name.
virtual void printParameters (OutputStream &out) const
 Print all parameters.
virtual void printParameters (std::ostream &out) const
virtual void reset ()
 Reset the list: delete all parameters.

Private Attributes

std::vector< Parameter * > parameters_

Detailed Description

The parameter list object.

Author:
Julien Dutheil, Laurent Gueguen This is a vector of Parameter with a few additional methods, mainly for giving name access.

Definition at line 61 of file ParameterList.h.


Constructor & Destructor Documentation

Build a new ParameterList object.

Definition at line 71 of file ParameterList.h.

Referenced by clone().

Copy constructor.

All parameters in the list will be cloned.

Copy constructor:

Definition at line 51 of file ParameterList.cpp.

References parameters_, and size().

Destructor:

Definition at line 82 of file ParameterList.cpp.

References reset().


Member Function Documentation

void ParameterList::addParameter ( Parameter param) throw (ParameterException) [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.

Parameters:
paramA ppointer toward the parameter to add to the list.

Definition at line 233 of file ParameterList.cpp.

void ParameterList::addParameters ( const ParameterList params) throw (ParameterException) [virtual]

Add new parameters at the end of the list.

Parameters:
paramsThe 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_().

ParameterList* bpp::ParameterList::clone ( ) const [inline, virtual]

Create a copy of this object and send a pointer to it.

Returns:
A pointer toward the copy object.

Implements bpp::Clonable.

Definition at line 82 of file ParameterList.h.

References ParameterList().

Referenced by includeParameters(), and subList().

void ParameterList::deleteParameter ( const std::string &  name) throw (ParameterNotFoundException) [virtual]

Delete a parameter from the list.

Parameters:
nameThe name of the parameter to delete from the list.

Definition at line 441 of file ParameterList.cpp.

References bpp::Parameter::getName().

Referenced by bpp::AbstractParametrizable::deleteParameter_(), and bpp::AbstractParameterAliasable::deleteParameter_().

void ParameterList::deleteParameter ( size_t  index) throw (IndexOutOfBoundsException) [virtual]

Delete a parameter from the list.

Parameters:
indexThe position of the parameter to delete in the list.

Definition at line 466 of file ParameterList.cpp.

void ParameterList::deleteParameters ( const std::vector< std::string > &  names) throw (ParameterNotFoundException) [virtual]

Delete several parameters from the list.

Parameters:
namesThe names of the parameters to delete from the list.

Definition at line 457 of file ParameterList.cpp.

void ParameterList::deleteParameters ( const std::vector< size_t > &  indices) throw (IndexOutOfBoundsException) [virtual]

Delete several parameters from the list.

Parameters:
indicesThe positions of the parameters to delete in the list. Duplicated positions will be considered only one time.

Definition at line 475 of file ParameterList.cpp.

Get the sublist containing all common parameter between this list and pl.

Parameters:
paramsThe list to compare to.
Returns:
A list with all common parameters.

Definition at line 162 of file ParameterList.cpp.

References bpp::Parameter::clone(), bpp::Parameter::getName(), hasParameter(), parameters_, and size().

vector< string > ParameterList::getMatchingParameterNames ( const std::string &  pattern) const [virtual]

Get all parameter names matching with the given name. Up to now, only "*" jokers are available.

Parameters:
patterna pattern of name
Returns:
A vector of matching names

Definition at line 190 of file ParameterList.cpp.

References bpp::StringTokenizer::hasMoreToken(), bpp::StringTokenizer::nextToken(), parameters_, and size().

const Parameter & ParameterList::getParameter ( const std::string &  name) const throw (ParameterNotFoundException) [virtual]

Get the parameter with name name.

Parameters:
nameThe name of the parameter to look for.
Returns:
A const reference toward the parameter with name name.
Exceptions:
ParameterNotFoundExceptionIf no parameter with the given name is found.

Definition at line 89 of file ParameterList.cpp.

References bpp::Parameter::getName().

Referenced by bpp::ParametersStopCondition::getCurrentTolerance(), bpp::AbstractParametrizable::getParameter(), bpp::AbstractParametrizable::getParameter_(), bpp::ParametersStopCondition::isToleranceReached(), matchParameters(), setParametersValues(), and testParametersValues().

Parameter & ParameterList::getParameter ( const std::string &  name) throw (ParameterNotFoundException) [virtual]

Get the parameter with name name.

Parameters:
nameThe name of the parameter to look for.
Returns:
A reference toward the parameter with name name.
Exceptions:
ParameterNotFoundExceptionIf no parameter with the given name is found.

Definition at line 111 of file ParameterList.cpp.

References bpp::Parameter::getName().

std::vector< std::string > ParameterList::getParameterNames ( ) const [virtual]

Get all parameter names in the list.

Returns:
A vector with all names in the same order as the parameters 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().

double ParameterList::getParameterValue ( const std::string &  name) const throw (ParameterNotFoundException) [virtual]

Get the value of the parameter with name name.

Parameters:
nameThe name of the parameter to look for.
Returns:
A value of the parameter with name name.
Exceptions:
ParameterNotFoundExceptionIf 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::ThreePointsNumericalDerivative::updateDerivatives(), bpp::TwoPointsNumericalDerivative::updateDerivatives(), and bpp::FivePointsNumericalDerivative::updateDerivatives().

void ParameterList::includeParameters ( const ParameterList params) [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.

Parameters:
paramsThe 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().

void ParameterList::matchParameters ( const ParameterList params) [virtual]

Update the parameters from params.

Only common parameters with params will be updated.

Parameters:
paramsA list of parameters.
See also:
setParameters(), setAllParameters()

Definition at line 428 of file ParameterList.cpp.

References getParameter(), hasParameter(), and parameters_.

ParameterList & ParameterList::operator= ( const ParameterList pl)

Assignation operator:

Definition at line 63 of file ParameterList.cpp.

References parameters_, reset(), and size().

virtual const Parameter& bpp::ParameterList::operator[] ( size_t  i) const [inline, virtual]
Returns:
The parameter at a given position.
Warning:
No check is performed on the validity of the index given as input!

Definition at line 96 of file ParameterList.h.

References parameters_.

virtual Parameter& bpp::ParameterList::operator[] ( size_t  i) [inline, virtual]

Definition at line 97 of file ParameterList.h.

References parameters_.

void ParameterList::printParameters ( OutputStream out) const [virtual]

Print all parameters.

Definition at line 500 of file ParameterList.cpp.

References bpp::OutputStream::endLine(), parameters_, and size().

Referenced by printParameters().

virtual void bpp::ParameterList::printParameters ( std::ostream &  out) const [inline, virtual]

Definition at line 370 of file ParameterList.h.

References printParameters().

void ParameterList::reset ( ) [virtual]

Reset the list: delete all parameters.

Definition at line 514 of file ParameterList.cpp.

References parameters_, and size().

Referenced by operator=(), bpp::AbstractParametrizable::resetParameters_(), bpp::AbstractParameterAliasable::resetParameters_(), and ~ParameterList().

void ParameterList::setAllParameters ( const ParameterList params) throw (ParameterNotFoundException) [virtual]

Set the parameters to be equals to params.

The list must contain exactly the same parameters (ie same names) than the parameters available.

Parameters:
paramsA list with all parameters.
See also:
setParameters(), matchParameters();

Definition at line 394 of file ParameterList.cpp.

Set the parameters to be equals to params.

The list must contain exactly the same parameters (ie same names) than the parameters available.

Parameters:
paramsA list with all parameters.
See also:
setParameters(), matchParameters();
Exceptions:
ParameterNotFoundExceptionIf at least one name does not correspond to a parameter in the list.
ConstraintExceptionIf 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().

void ParameterList::setParameter ( size_t  index,
const Parameter param 
) throw (IndexOutOfBoundsException) [virtual]

Change given parameter.

Parameters:
indexThe position of the parameter to alter.
paramThe parameter to add to the list.
Exceptions:
IndexOutOfBoundsExceptionif the index is not valid.

Definition at line 242 of file ParameterList.cpp.

Referenced by bpp::AbstractOptimizer::autoParameter(), and bpp::BppODiscreteDistributionFormat::initialize_().

void ParameterList::setParameters ( const ParameterList params) throw (ParameterNotFoundException) [virtual]

Update the parameters from params.

params must be a subset of all parameters available.

Parameters:
paramsA list containing all parameters to update.
See also:
setAllParameters(), matchParameters()

Definition at line 405 of file ParameterList.cpp.

Referenced by bpp::ThreePointsNumericalDerivative::updateDerivatives(), bpp::TwoPointsNumericalDerivative::updateDerivatives(), and bpp::FivePointsNumericalDerivative::updateDerivatives().

void ParameterList::setParametersValues ( const ParameterList params) [virtual]

Update the parameters from the ones in params that have matching names.

Parameters:
paramsA list containing all parameters to update.
See also:
setAllParameters(), matchParameters()
Exceptions:
ConstraintExceptionIf 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().

void ParameterList::setParameterValue ( const std::string &  name,
double  value 
) throw (ParameterNotFoundException, ConstraintException) [virtual]

Set the value of parameter with name name to be equal to value.

Parameters:
namethe name of the parameter to set.
valueThe value of the parameter.
Exceptions:
ParameterNotFoundExceptionIf no parameter with the given name is found in the list.
ConstraintExceptionIf 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().

ParameterList ParameterList::subList ( const std::vector< std::string > &  names) const throw (ParameterNotFoundException) [virtual]

Get given parameters as a sublist.

Parameters:
namesName of the parameters to be included in the list.
Returns:
A list with all parameters specified.
Exceptions:
ParameterNotFoundExceptionIf 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::ThreePointsNumericalDerivative::updateDerivatives(), bpp::TwoPointsNumericalDerivative::updateDerivatives(), bpp::FivePointsNumericalDerivative::updateDerivatives(), and bpp::BppOParametrizableFormat::write().

ParameterList ParameterList::subList ( const std::string &  name) const throw (ParameterNotFoundException) [virtual]

Get given parameter as a sublist.

Parameters:
nameName of the parameter to be included in the list.
Returns:
A list with the parameter specified.
Exceptions:
ParameterNotFoundExceptionIf no parameter with the given name is found.

Definition at line 134 of file ParameterList.cpp.

References addParameter().

ParameterList ParameterList::subList ( const std::vector< size_t > &  parameters) const [virtual]

Get given parameters as a sublist.

Parameters:
parametersPositions of the parameters to be included in the list.
Returns:
A list with all parameters specified.

Definition at line 143 of file ParameterList.cpp.

References parameters_, and size().

ParameterList ParameterList::subList ( size_t  parameter) const [virtual]

Get given parameter as a sublist.

Parameters:
parameterPosition of the parameters to be included in the list.
Returns:
A list with the parameter specified.

Definition at line 154 of file ParameterList.cpp.

References clone(), parameters_, and size().

bool ParameterList::testParametersValues ( const ParameterList params) const [virtual]

Tests the parameters from params.

Only common parameters with params are compared.

Parameters:
paramsA list of parameters.
Returns:
true iff a least one parameter value is different.

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_.

size_t ParameterList::whichParameterHasName ( const std::string &  name) const throw (ParameterNotFoundException) [virtual]

Get the position of a given parameter according to its name.

Parameters:
nameThe name of the parameter to look for.
Returns:
The position of the parameter if found. If several parameters exist with the given name, the position of the first one is returned.
Exceptions:
ParameterNotFoundExceptionIf no parameter with the given name is found.

Definition at line 490 of file ParameterList.cpp.


Member Data Documentation


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Friends