|
bpp-core
2.1.0
|
00001 // 00002 // File: DirectionFunction.h 00003 // Created by: Julien Dutheil 00004 // Created on: Wed Apr 11 17:28 2007 00005 // From file PowellMultiDimensions.h 00006 // 00007 00008 /* 00009 Copyright or © or Copr. Bio++ Development Team, (November 17, 2004) 00010 00011 This software is a computer program whose purpose is to provide classes 00012 for phylogenetic data analysis. 00013 00014 This software is governed by the CeCILL license under French law and 00015 abiding by the rules of distribution of free software. You can use, 00016 modify and/ or redistribute the software under the terms of the CeCILL 00017 license as circulated by CEA, CNRS and INRIA at the following URL 00018 "http://www.cecill.info". 00019 00020 As a counterpart to the access to the source code and rights to copy, 00021 modify and redistribute granted by the license, users are provided only 00022 with a limited warranty and the software's author, the holder of the 00023 economic rights, and the successive licensors have only limited 00024 liability. 00025 00026 In this respect, the user's attention is drawn to the risks associated 00027 with loading, using, modifying and/or developing or reproducing the 00028 software by the user in light of its specific status of free software, 00029 that may mean that it is complicated to manipulate, and that also 00030 therefore means that it is reserved for developers and experienced 00031 professionals having in-depth computer knowledge. Users are therefore 00032 encouraged to load and test the software's suitability as regards their 00033 requirements in conditions enabling the security of their systems and/or 00034 data to be ensured and, more generally, to use and operate it in the 00035 same conditions as regards security. 00036 00037 The fact that you are presently reading this means that you have had 00038 knowledge of the CeCILL license and that you accept its terms. 00039 */ 00040 00041 #ifndef _DIRECTIONFUNCTION_H_ 00042 #define _DIRECTIONFUNCTION_H_ 00043 00044 #include "Functions.h" 00045 #include "../Parametrizable.h" 00046 #include "../AutoParameter.h" 00047 #include "../../App/ApplicationTools.h" 00048 #include "../../Io/OutputStream.h" 00049 00050 namespace bpp 00051 { 00052 00053 class DirectionFunction: 00054 public Function, 00055 public ParametrizableAdapter 00056 { 00057 private: 00058 mutable ParameterList params_, p_, xt_; 00059 std::vector<double> xi_; 00060 Function* function_; 00061 std::string constraintPolicy_; 00062 OutputStream* messenger_; 00063 00064 public: 00065 DirectionFunction(Function* function = 0) : 00066 params_(), p_(), xt_(), xi_(), 00067 function_(function), constraintPolicy_(AutoParameter::CONSTRAINTS_KEEP), 00068 messenger_(ApplicationTools::message) {} 00069 00070 DirectionFunction(const DirectionFunction& df) : 00071 ParametrizableAdapter(df), params_(df.params_), p_(df.p_), xt_(df.p_), xi_(df.xi_), 00072 function_(df.function_), constraintPolicy_(df.constraintPolicy_), messenger_(df.messenger_) {} 00073 00074 DirectionFunction& operator=(const DirectionFunction& df) 00075 { 00076 ParametrizableAdapter::operator=(df); 00077 params_ = df.params_; 00078 p_ = df.p_; 00079 xt_ = df.p_; 00080 xi_ = df.xi_; 00081 function_ = df.function_; 00082 constraintPolicy_ = df.constraintPolicy_; 00083 messenger_ = df.messenger_; 00084 return *this; 00085 } 00086 00087 virtual ~DirectionFunction() {} 00088 00089 DirectionFunction* clone() const { return new DirectionFunction(*this); } 00090 00091 public: // Function interface implementation: 00092 void setParameters(const ParameterList& parameters) 00093 throw (ParameterNotFoundException, ConstraintException); 00094 double getValue() const throw (Exception); 00095 const ParameterList & getParameters() const throw (Exception); 00096 00097 public: // Specific methods: 00098 void init(const ParameterList & p, const std::vector<double> & xi); 00099 void autoParameter(); 00100 void ignoreConstraints(); 00101 void setConstraintPolicy(const std::string & constraintPolicy) { constraintPolicy_ = constraintPolicy; } 00102 std::string getConstraintPolicy() const { return constraintPolicy_; } 00103 void setMessageHandler(OutputStream* messenger) { messenger_ = messenger; } 00104 Function * getFunction() const { return function_; } 00108 ParameterList getFunctionParameters() const { return p_; } 00109 size_t getNumberOfParameters() const { return p_.size(); } 00110 00111 }; 00112 00113 } //end of namespace bpp. 00114 00115 #endif //_DIRECTIONFUNCTION_H_ 00116