bpp-core3  3.0.0
DirectionFunction.h
Go to the documentation of this file.
1 //
2 // File: DirectionFunction.h
3 // Authors:
4 // Julien Dutheil
5 // Created: 2007-04-11 17:28:00
6 //
7 
8 /*
9  Copyright or © or Copr. Bio++ Development Team, (November 17, 2004)
10 
11  This software is a computer program whose purpose is to provide classes
12  for phylogenetic data analysis.
13 
14  This software is governed by the CeCILL license under French law and
15  abiding by the rules of distribution of free software. You can use,
16  modify and/ or redistribute the software under the terms of the CeCILL
17  license as circulated by CEA, CNRS and INRIA at the following URL
18  "http://www.cecill.info".
19 
20  As a counterpart to the access to the source code and rights to copy,
21  modify and redistribute granted by the license, users are provided only
22  with a limited warranty and the software's author, the holder of the
23  economic rights, and the successive licensors have only limited
24  liability.
25 
26  In this respect, the user's attention is drawn to the risks associated
27  with loading, using, modifying and/or developing or reproducing the
28  software by the user in light of its specific status of free software,
29  that may mean that it is complicated to manipulate, and that also
30  therefore means that it is reserved for developers and experienced
31  professionals having in-depth computer knowledge. Users are therefore
32  encouraged to load and test the software's suitability as regards their
33  requirements in conditions enabling the security of their systems and/or
34  data to be ensured and, more generally, to use and operate it in the
35  same conditions as regards security.
36 
37  The fact that you are presently reading this means that you have had
38  knowledge of the CeCILL license and that you accept its terms.
39 */
40 
41 #ifndef BPP_NUMERIC_FUNCTION_DIRECTIONFUNCTION_H
42 #define BPP_NUMERIC_FUNCTION_DIRECTIONFUNCTION_H
43 
44 
45 #include "../../App/ApplicationTools.h"
46 #include "../../Io/OutputStream.h"
47 #include "../AutoParameter.h"
48 #include "../Parametrizable.h"
49 #include "Functions.h"
50 
51 namespace bpp
52 {
54  public Function,
56 {
57 private:
59  std::vector<double> xi_;
61  std::string constraintPolicy_;
63 
64 public:
65  DirectionFunction(Function* function = 0) :
66  params_(), p_(), xt_(), xi_(),
67  function_(function), constraintPolicy_(AutoParameter::CONSTRAINTS_KEEP),
68  messenger_(ApplicationTools::message.get()) {}
69 
71  ParametrizableAdapter(df), params_(df.params_), p_(df.p_), xt_(df.p_), xi_(df.xi_),
73 
75  {
76  ParametrizableAdapter::operator=(df);
77  params_ = df.params_;
78  p_ = df.p_;
79  xt_ = df.p_;
80  xi_ = df.xi_;
81  function_ = df.function_;
84  return *this;
85  }
86 
87  virtual ~DirectionFunction() {}
88 
89  DirectionFunction* clone() const { return new DirectionFunction(*this); }
90 
91 public:
92  // Function interface implementation:
93  void setParameters(const ParameterList& parameters);
94  double getValue() const;
95  const ParameterList& getParameters() const;
96 
97 public:
98  // Specific methods:
99  void init(const ParameterList& p, const std::vector<double>& xi);
100  void autoParameter();
101  void ignoreConstraints();
102  void setConstraintPolicy(const std::string& constraintPolicy) { constraintPolicy_ = constraintPolicy; }
103  std::string getConstraintPolicy() const { return constraintPolicy_; }
104  void setMessageHandler(OutputStream* messenger) { messenger_ = messenger; }
105  Function* getFunction() const { return function_; }
110  size_t getNumberOfParameters() const { return p_.size(); }
111 
112 protected:
114 };
115 } // end of namespace bpp.
116 #endif // BPP_NUMERIC_FUNCTION_DIRECTIONFUNCTION_H
This class provides some common tools for developping applications.
The AutoParameter class.
Definition: AutoParameter.h:61
void setConstraintPolicy(const std::string &constraintPolicy)
void init(const ParameterList &p, const std::vector< double > &xi)
void setMessageHandler(OutputStream *messenger)
DirectionFunction(Function *function=0)
const ParameterList & getParameters() const
Get all parameters available.
std::string getConstraintPolicy() const
ParameterList & getParameters_()
Get all parameters available.
std::vector< double > xi_
size_t getNumberOfParameters() const
Get the number of parameters.
DirectionFunction(const DirectionFunction &df)
Function * getFunction() const
DirectionFunction & operator=(const DirectionFunction &df)
double getValue() const
Get the value of the function at the current point.
ParameterList getFunctionParameters() const
void setParameters(const ParameterList &parameters)
Set the point where the function must be computed.
DirectionFunction * clone() const
Create a copy of this object and send a pointer to it.
This is the function abstract class.
Definition: Functions.h:89
OutputStream interface.
Definition: OutputStream.h:67
The parameter list object.
Definition: ParameterList.h:65
size_t size() const
Definition: ParameterList.h:92
A low-level implementation of the Parametrizable interface with void functions.