bpp-core  2.2.0
DirectionFunction.h
Go to the documentation of this file.
1 //
2 // File: DirectionFunction.h
3 // Created by: Julien Dutheil
4 // Created on: Wed Apr 11 17:28 2007
5 // From file PowellMultiDimensions.h
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 _DIRECTIONFUNCTION_H_
42 #define _DIRECTIONFUNCTION_H_
43 
44 #include "Functions.h"
45 #include "../Parametrizable.h"
46 #include "../AutoParameter.h"
47 #include "../../App/ApplicationTools.h"
48 #include "../../Io/OutputStream.h"
49 
50 namespace bpp
51 {
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) {}
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: // Function interface implementation:
92  void setParameters(const ParameterList& parameters)
94  double getValue() const throw (Exception);
95  const ParameterList & getParameters() const throw (Exception);
96 
97  public: // Specific methods:
98  void init(const ParameterList & p, const std::vector<double> & xi);
99  void autoParameter();
100  void ignoreConstraints();
101  void setConstraintPolicy(const std::string & constraintPolicy) { constraintPolicy_ = constraintPolicy; }
102  std::string getConstraintPolicy() const { return constraintPolicy_; }
103  void setMessageHandler(OutputStream* messenger) { messenger_ = messenger; }
104  Function * getFunction() const { return function_; }
109  size_t getNumberOfParameters() const { return p_.size(); }
110 
111 };
112 
113 } //end of namespace bpp.
114 
115 #endif //_DIRECTIONFUNCTION_H_
116 
Exception thrown when a parameter is not found, for instance in a ParameterList.
void setConstraintPolicy(const std::string &constraintPolicy)
void init(const ParameterList &p, const std::vector< double > &xi)
DirectionFunction(const DirectionFunction &df)
size_t getNumberOfParameters() const
Get the number of parameters.
This class allows to perform a correspondence analysis.
This is the function abstract class.
Definition: Functions.h:86
size_t size() const
Definition: ParameterList.h:90
STL namespace.
DirectionFunction & operator=(const DirectionFunction &df)
void setMessageHandler(OutputStream *messenger)
ParameterList getFunctionParameters() const
DirectionFunction(Function *function=0)
A low-level implementation of the Parametrizable interface with void functions.
The parameter list object.
Definition: ParameterList.h:61
std::string getConstraintPolicy() const
This class provides some common tools for developping applications.
std::vector< double > xi_
double getValue() const
Get the value of the function at the current point.
The AutoParameter class.
Definition: AutoParameter.h:58
OutputStream interface.
Definition: OutputStream.h:64
Exception base class.
Definition: Exceptions.h:57
Function * getFunction() const
const ParameterList & getParameters() const
Get all parameters available.
Exception thrown when a value do not match a given constraint.
DirectionFunction * clone() const
Create a copy of this object and send a pointer to it.
void setParameters(const ParameterList &parameters)
Set the point where the function must be computed.