bpp-core3  3.0.0
DirectionFunction.cpp
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: The Bio++ Development Group
2 //
3 // SPDX-License-Identifier: CECILL-2.1
4 
5 #include "DirectionFunction.h"
6 
7 using namespace bpp;
8 using namespace std;
9 
10 /******************************************************************************/
11 
13 {
14  params_ = params;
15  double x = params_[0].getValue();
16  for (unsigned int j = 0; j < p_.size(); j++)
17  {
18  // cout << p_[j].getValue() << " " << x << " " << xi_[j] << endl;
19  xt_[j].setValue((p_[j].getValue()) + x * xi_[j]);
20  }
21  function_->setParameters(xt_);
22 }
23 
24 /******************************************************************************/
25 
27 {
28  return function_->getValue();
29 }
30 
31 /******************************************************************************/
32 
34 {
35  return params_;
36 }
37 
39 {
40  return params_;
41 }
42 
43 /******************************************************************************/
44 
45 void DirectionFunction::init(const ParameterList& p, const vector<double>& xi)
46 {
47  p_ = p;
48  xi_ = xi;
49  if (constraintPolicy_ == AutoParameter::CONSTRAINTS_AUTO)
50  autoParameter();
51  else if (constraintPolicy_ == AutoParameter::CONSTRAINTS_IGNORE)
52  ignoreConstraints();
53  xt_ = p_;
54 }
55 
56 /******************************************************************************/
57 
59 {
60  for (unsigned int i = 0; i < p_.size(); ++i)
61  {
62  AutoParameter ap(p_[i]);
63  ap.setMessageHandler(messenger_);
64  p_.setParameter(i, ap);
65  }
66 }
67 
68 /******************************************************************************/
69 
71 {
72  for (unsigned int i = 0; i < p_.size(); i++)
73  {
74  p_[i].removeConstraint();
75  }
76 }
77 
78 /******************************************************************************/
static std::string CONSTRAINTS_IGNORE
Definition: AutoParameter.h:99
void init(const ParameterList &p, const std::vector< double > &xi)
void setParameters(const ParameterList &parameters) override
Set the point where the function must be computed.
const ParameterList & getParameters() const override
Get all parameters available.
STL namespace.
The parameter list object.
Definition: ParameterList.h:27
virtual void setMessageHandler(std::shared_ptr< OutputStream > mh)
Set the message handler for this AutoParameter.
Definition: AutoParameter.h:95
ParameterList & getParameters_() override
Get all parameters available.
The AutoParameter class.
Definition: AutoParameter.h:23
virtual void setParameters(const ParameterList &params)
Update the parameters from params.
static std::string CONSTRAINTS_AUTO
Definition: AutoParameter.h:98
double getValue() const override
Get the value of the function at the current point.