|
bpp-core
2.1.0
|
The AutoParameter class. More...
#include <Bpp/Numeric/AutoParameter.h>
Inheritance diagram for bpp::AutoParameter:
Collaboration diagram for bpp::AutoParameter:Public Member Functions | |
| AutoParameter (const std::string &name="", double value=0, Constraint *constraint=0, bool attachConstraint=false) throw (ConstraintException) | |
| Build a new AutoParameter. | |
| AutoParameter (const Parameter ¶m) | |
| Copy constructor. | |
| AutoParameter (const AutoParameter ¶m) | |
| Copy constructor. | |
| AutoParameter & | operator= (const AutoParameter ¶m) |
| Assignment operator. | |
| virtual | ~AutoParameter () |
| AutoParameter * | clone () const |
| Create a copy of this object and send a pointer to it. | |
| virtual void | setValue (double value) throw (ConstraintException) |
| Set the value of this parameter. | |
| virtual void | setMessageHandler (OutputStream *mh) |
| Set the message handler for this AutoParameter. | |
| virtual void | setName (const std::string &name) |
| Set the name of this parameter. | |
| void | setPrecision (double precision) |
| Set the precision of this parameter. | |
| virtual const std::string & | getName () const |
| Get the name of this parameter. | |
| virtual double | getValue () const |
| Get the value of this parameter. | |
| virtual double | getPrecision () const |
| Get the precision of this parameter. | |
| virtual const Constraint * | getConstraint () const |
| Return the constraint associated to this parameter if there is one. | |
| virtual Constraint * | getConstraint () |
| Return the constraint associated to this parameter if there is one. | |
| virtual bool | hasConstraint () const |
| Tells if this parameter has a constraint. | |
| virtual const Constraint * | removeConstraint () |
| Remove the constraint associated to this parameter. | |
| virtual void | setConstraint (Constraint *constraint, bool attach=false) |
| Set a constraint to this parameter. | |
| virtual void | addParameterListener (ParameterListener *listener, bool attachListener=true) |
| Add a new listener to this parameter. | |
| virtual void | removeParameterListener (const std::string &listenerId) |
| Remove all listeners with a given id from this parameter. | |
| virtual bool | hasParameterListener (const std::string &listenerId) |
| Tell is there is a listener with a given id from this parameter. | |
Static Public Attributes | |
| static std::string | CONSTRAINTS_AUTO = "auto" |
| static std::string | CONSTRAINTS_IGNORE = "ignore" |
| static std::string | CONSTRAINTS_KEEP = "keep" |
| static const IntervalConstraint | R_PLUS |
| static const IntervalConstraint | R_PLUS_STAR |
| static const IntervalConstraint | R_MINUS |
| static const IntervalConstraint | R_MINUS_STAR |
| static const IntervalConstraint | PROP_CONSTRAINT_IN |
| static const IntervalConstraint | PROP_CONSTRAINT_EX |
Protected Member Functions | |
| void | fireParameterNameChanged (ParameterEvent &event) |
| void | fireParameterValueChanged (ParameterEvent &event) |
Protected Attributes | |
| std::string | name_ |
| double | value_ |
| double | precision_ |
| Constraint * | constraint_ |
| bool | attach_ |
| std::vector< ParameterListener * > | listeners_ |
| std::vector< bool > | listenerAttach_ |
Private Attributes | |
| OutputStream * | messageHandler_ |
The AutoParameter class.
This class overides the setValue() method of class Parameter so that no Exception is thrown. This allows to perform optimization under constraint.
Definition at line 58 of file AutoParameter.h.
| AutoParameter::AutoParameter | ( | const std::string & | name = "", |
| double | value = 0, |
||
| Constraint * | constraint = 0, |
||
| bool | attachConstraint = false |
||
| ) | throw (ConstraintException) |
Build a new AutoParameter.
| name | The parameter name. |
| value | The parameter value. |
| constraint | An optional pointer toward a Constraint object. |
| attachConstraint | Tell if the constraint must be attached to this parameter, or shared between different objects. See Parameter. |
| ConstraintException | If the parameter value does not match the contraint. |
Constructors:
Definition at line 61 of file AutoParameter.cpp.
Referenced by clone().
| AutoParameter::AutoParameter | ( | const Parameter & | param | ) |
Copy constructor.
| param | The parameter to copy. |
Definition at line 64 of file AutoParameter.cpp.
| AutoParameter::AutoParameter | ( | const AutoParameter & | param | ) |
Copy constructor.
| param | The parameter to copy. |
Definition at line 66 of file AutoParameter.cpp.
| virtual bpp::AutoParameter::~AutoParameter | ( | ) | [inline, virtual] |
Definition at line 99 of file AutoParameter.h.
| virtual void bpp::Parameter::addParameterListener | ( | ParameterListener * | listener, |
| bool | attachListener = true |
||
| ) | [inline, virtual, inherited] |
Add a new listener to this parameter.
| listener | The listener to add. |
| attachListener | Tell if the parameter will own this listener. If so, deep copies will be made when cloning the parameter, and the listener will be destroyed upon destruction of the parameter or upon removal. Alternatively, only superficial copies will be made, and the listener will persist if the parameter is destroyed. |
Definition at line 299 of file Parameter.h.
References bpp::Parameter::listenerAttach_, and bpp::Parameter::listeners_.
Referenced by bpp::AbstractParameterAliasable::aliasParameters().
| AutoParameter* bpp::AutoParameter::clone | ( | ) | const [inline, virtual] |
Create a copy of this object and send a pointer to it.
Reimplemented from bpp::Parameter.
Definition at line 101 of file AutoParameter.h.
References AutoParameter().
| void bpp::Parameter::fireParameterNameChanged | ( | ParameterEvent & | event | ) | [inline, protected, inherited] |
Definition at line 321 of file Parameter.h.
References bpp::Parameter::listeners_.
Referenced by bpp::Parameter::setName().
| void bpp::Parameter::fireParameterValueChanged | ( | ParameterEvent & | event | ) | [inline, protected, inherited] |
Definition at line 326 of file Parameter.h.
References bpp::Parameter::listeners_.
| virtual const Constraint* bpp::Parameter::getConstraint | ( | ) | const [inline, virtual, inherited] |
Return the constraint associated to this parameter if there is one.
Definition at line 255 of file Parameter.h.
References bpp::Parameter::constraint_.
Referenced by bpp::AbstractParameterAliasable::aliasParameters(), bpp::ReparametrizationFunctionWrapper::init_(), bpp::ParameterList::matchParametersValues(), bpp::ParameterList::setParametersValues(), and bpp::ParameterList::testParametersValues().
| virtual Constraint* bpp::Parameter::getConstraint | ( | ) | [inline, virtual, inherited] |
Return the constraint associated to this parameter if there is one.
Definition at line 262 of file Parameter.h.
References bpp::Parameter::constraint_.
| virtual const std::string& bpp::Parameter::getName | ( | ) | const [inline, virtual, inherited] |
Get the name of this parameter.
Definition at line 234 of file Parameter.h.
References bpp::Parameter::name_.
Referenced by bpp::ParameterList::deleteParameter(), bpp::AbstractParameterAliasable::deleteParameter_(), bpp::ParameterList::getCommonParametersWith(), bpp::ParametersStopCondition::getCurrentTolerance(), bpp::NumCalcApplicationTools::getDefaultValue(), bpp::ParameterList::getParameter(), bpp::ParameterList::getParameterValue(), bpp::ParameterList::hasParameter(), bpp::ReparametrizationFunctionWrapper::init_(), bpp::ParametersStopCondition::isToleranceReached(), and bpp::AliasParameterListener::parameterValueChanged().
| virtual double bpp::Parameter::getPrecision | ( | ) | const [inline, virtual, inherited] |
Get the precision of this parameter.
Definition at line 248 of file Parameter.h.
References bpp::Parameter::precision_.
| virtual double bpp::Parameter::getValue | ( | ) | const [inline, virtual, inherited] |
Get the value of this parameter.
Definition at line 241 of file Parameter.h.
References bpp::Parameter::value_.
Referenced by bpp::ParametersStopCondition::getCurrentTolerance(), bpp::NumCalcApplicationTools::getDefaultValue(), bpp::RTransformedParameter::getFirstOrderDerivative(), bpp::IntervalTransformedParameter::getFirstOrderDerivative(), bpp::RTransformedParameter::getOriginalValue(), bpp::IntervalTransformedParameter::getOriginalValue(), bpp::PlaceboTransformedParameter::getOriginalValue(), bpp::AbstractParametrizable::getParameterValue(), bpp::ParameterList::getParameterValue(), bpp::RTransformedParameter::getSecondOrderDerivative(), bpp::IntervalTransformedParameter::getSecondOrderDerivative(), bpp::TestFunction::getValue(), bpp::ReparametrizationFunctionWrapper::init_(), bpp::ParametersStopCondition::isToleranceReached(), bpp::ParameterList::matchParametersValues(), bpp::ParameterList::setAllParametersValues(), bpp::ParameterList::setParametersValues(), and bpp::ParameterList::testParametersValues().
| virtual bool bpp::Parameter::hasConstraint | ( | ) | const [inline, virtual, inherited] |
Tells if this parameter has a constraint.
Definition at line 269 of file Parameter.h.
References bpp::Parameter::constraint_.
Referenced by bpp::AbstractParameterAliasable::aliasParameters(), bpp::ParameterList::matchParametersValues(), bpp::ParameterList::setParametersValues(), and bpp::ParameterList::testParametersValues().
| bool Parameter::hasParameterListener | ( | const std::string & | listenerId | ) | [virtual, inherited] |
Tell is there is a listener with a given id from this parameter.
| listenerId | The id of listener to remove. |
Definition at line 187 of file Parameter.cpp.
References bpp::Parameter::listeners_.
| AutoParameter & AutoParameter::operator= | ( | const AutoParameter & | param | ) |
Assignment operator.
| param | The parameter to copy. |
Definition at line 68 of file AutoParameter.cpp.
References messageHandler_.
| const Constraint * Parameter::removeConstraint | ( | ) | [virtual, inherited] |
Remove the constraint associated to this parameter.
Warning! The contraint objet is not deleted.
Definition at line 163 of file Parameter.cpp.
References bpp::Parameter::constraint_.
Referenced by bpp::SimpleDiscreteDistribution::restrictToConstraint().
| void Parameter::removeParameterListener | ( | const std::string & | listenerId | ) | [virtual, inherited] |
Remove all listeners with a given id from this parameter.
| listenerId | The id of listener to remove. |
Definition at line 172 of file Parameter.cpp.
References bpp::Parameter::listenerAttach_, and bpp::Parameter::listeners_.
| void Parameter::setConstraint | ( | Constraint * | constraint, |
| bool | attach = false |
||
| ) | [virtual, inherited] |
Set a constraint to this parameter.
| constraint | a pointer to the constraint (may be null) |
| attach | says if the constraint is attached to the Parameter (default: false). |
Definition at line 143 of file Parameter.cpp.
References bpp::Parameter::attach_, bpp::Parameter::constraint_, bpp::Constraint::isCorrect(), and bpp::Parameter::value_.
Referenced by bpp::ConstantDistribution::restrictToConstraint(), bpp::TruncatedExponentialDiscreteDistribution::restrictToConstraint(), and bpp::SimpleDiscreteDistribution::restrictToConstraint().
| virtual void bpp::AutoParameter::setMessageHandler | ( | OutputStream * | mh | ) | [inline, virtual] |
Set the message handler for this AutoParameter.
The message handler keeps all messages that the parameter may send. The default handler is set to standard output, but you can pass any ostream object (cerr, ofstream, etc.).
A NULL pointer disable message output.
| mh | The message handler to use. |
Definition at line 134 of file AutoParameter.h.
References messageHandler_.
Referenced by bpp::DirectionFunction::autoParameter(), bpp::AbstractOptimizer::autoParameter(), and bpp::BppODiscreteDistributionFormat::initialize_().
| virtual void bpp::Parameter::setName | ( | const std::string & | name | ) | [inline, virtual, inherited] |
Set the name of this parameter.
| name | the new parameter name. |
Definition at line 208 of file Parameter.h.
References bpp::Parameter::fireParameterNameChanged(), and bpp::Parameter::name_.
| void Parameter::setPrecision | ( | double | precision | ) | [inherited] |
Set the precision of this parameter.
| precision | the new parameter precision. |
Precision:
Definition at line 136 of file Parameter.cpp.
References bpp::Parameter::precision_.
| void AutoParameter::setValue | ( | double | value | ) | throw (ConstraintException) [virtual] |
Set the value of this parameter.
This method is redefined so that no constraintException is thrown! When a Constraint is match, we automatically apply a correct value instead. This correct value is the nearest limit reached by the value, or a value next to the limit if the limit is not reachable.
This allow to perform optimization under constraint whith algorithms that are not initially built for this.
| value | the new parameter value. |
| ConstraintException | Never thrown! |
Reimplemented from bpp::Parameter.
Definition at line 77 of file AutoParameter.cpp.
References bpp::ConstraintException::getBadValue(), bpp::Parameter::setValue(), and bpp::NumConstants::TINY().
bool bpp::Parameter::attach_ [protected, inherited] |
Definition at line 143 of file Parameter.h.
Referenced by bpp::Parameter::operator=(), bpp::Parameter::Parameter(), bpp::Parameter::setConstraint(), and bpp::Parameter::~Parameter().
Constraint* bpp::Parameter::constraint_ [protected, inherited] |
Definition at line 142 of file Parameter.h.
Referenced by bpp::Parameter::getConstraint(), bpp::Parameter::hasConstraint(), bpp::Parameter::operator=(), bpp::Parameter::Parameter(), bpp::Parameter::removeConstraint(), bpp::Parameter::setConstraint(), and bpp::Parameter::~Parameter().
string AutoParameter::CONSTRAINTS_AUTO = "auto" [static] |
Definition at line 138 of file AutoParameter.h.
Referenced by bpp::AbstractOptimizer::AbstractOptimizer(), bpp::DirectionFunction::init(), bpp::AbstractOptimizer::init(), bpp::OneDimensionOptimizationTools::lineMinimization(), bpp::OneDimensionOptimizationTools::lineSearch(), and bpp::AbstractOptimizer::operator=().
string AutoParameter::CONSTRAINTS_IGNORE = "ignore" [static] |
Definition at line 139 of file AutoParameter.h.
Referenced by bpp::AbstractOptimizer::AbstractOptimizer(), bpp::DirectionFunction::init(), bpp::AbstractOptimizer::init(), and bpp::AbstractOptimizer::operator=().
string AutoParameter::CONSTRAINTS_KEEP = "keep" [static] |
Definition at line 140 of file AutoParameter.h.
Referenced by bpp::OneDimensionOptimizationTools::lineMinimization(), and bpp::OneDimensionOptimizationTools::lineSearch().
std::vector<bool> bpp::Parameter::listenerAttach_ [protected, inherited] |
Definition at line 145 of file Parameter.h.
Referenced by bpp::Parameter::addParameterListener(), bpp::Parameter::operator=(), bpp::Parameter::Parameter(), bpp::Parameter::removeParameterListener(), and bpp::Parameter::~Parameter().
std::vector<ParameterListener*> bpp::Parameter::listeners_ [protected, inherited] |
Definition at line 144 of file Parameter.h.
Referenced by bpp::Parameter::addParameterListener(), bpp::Parameter::fireParameterNameChanged(), bpp::Parameter::fireParameterValueChanged(), bpp::Parameter::hasParameterListener(), bpp::Parameter::operator=(), bpp::Parameter::Parameter(), bpp::Parameter::removeParameterListener(), and bpp::Parameter::~Parameter().
OutputStream* bpp::AutoParameter::messageHandler_ [private] |
Definition at line 62 of file AutoParameter.h.
Referenced by operator=(), and setMessageHandler().
std::string bpp::Parameter::name_ [protected, inherited] |
Definition at line 139 of file Parameter.h.
Referenced by bpp::Parameter::getName(), bpp::Parameter::operator=(), and bpp::Parameter::setName().
double bpp::Parameter::precision_ [protected, inherited] |
Definition at line 141 of file Parameter.h.
Referenced by bpp::Parameter::getPrecision(), bpp::Parameter::operator=(), and bpp::Parameter::setPrecision().
const IntervalConstraint Parameter::PROP_CONSTRAINT_EX [static, inherited] |
Definition at line 338 of file Parameter.h.
const IntervalConstraint Parameter::PROP_CONSTRAINT_IN [static, inherited] |
const IntervalConstraint Parameter::R_MINUS [static, inherited] |
Definition at line 335 of file Parameter.h.
const IntervalConstraint Parameter::R_MINUS_STAR [static, inherited] |
Definition at line 336 of file Parameter.h.
const IntervalConstraint Parameter::R_PLUS [static, inherited] |
Definition at line 333 of file Parameter.h.
Referenced by bpp::ExponentialDiscreteDistribution::ExponentialDiscreteDistribution(), and bpp::TruncatedExponentialDiscreteDistribution::TruncatedExponentialDiscreteDistribution().
const IntervalConstraint Parameter::R_PLUS_STAR [static, inherited] |
Definition at line 334 of file Parameter.h.
Referenced by bpp::GaussianDiscreteDistribution::GaussianDiscreteDistribution().
double bpp::Parameter::value_ [protected, inherited] |
Definition at line 140 of file Parameter.h.
Referenced by bpp::Parameter::getValue(), bpp::Parameter::operator=(), and bpp::Parameter::setConstraint().