00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef _SCSOLVER_NUMERIC_FUNCOBJ_HXX_
00029 #define _SCSOLVER_NUMERIC_FUNCOBJ_HXX_
00030
00031 #include <vector>
00032 #include <string>
00033 #include <memory>
00034 #include <exception>
00035
00036 namespace scsolver { namespace numeric {
00037
00038 class SingleVarFuncObj;
00039
00040 class VarSizeException : public ::std::exception
00041 {
00042 public:
00043 virtual const char* what() const throw();
00044 };
00045
00049 class BaseFuncObj
00050 {
00051 public:
00052 BaseFuncObj();
00053 BaseFuncObj(size_t varCount);
00054 BaseFuncObj(const BaseFuncObj& r);
00055 virtual ~BaseFuncObj() = 0;
00056
00057 const ::std::vector<double>& getVars() const;
00058 double getVar(size_t index) const;
00059 void setVars(const ::std::vector<double>& vars) const;
00060 void setVar(size_t index, double var) const;
00061 size_t getVarCount() const;
00062
00063 virtual double eval() const = 0;
00064
00068 virtual const ::std::string getFuncString() const = 0;
00069
00070 double operator()(const ::std::vector<double>& vars) const;
00071
00072 SingleVarFuncObj& getSingleVarFuncObj(size_t varIndex);
00073
00074 SingleVarFuncObj& getSingleVarFuncObjByRatio(const ::std::vector<double>& ratios);
00075
00076 private:
00077 mutable ::std::vector<double> m_vars;
00078 ::std::auto_ptr<SingleVarFuncObj> m_pSVFuncObj;
00079 };
00080
00081
00082
00087 class SingleVarFuncObj
00088 {
00089 public:
00090 SingleVarFuncObj();
00091 virtual ~SingleVarFuncObj() = 0;
00092
00093 virtual void setVar(double var) = 0;
00094 virtual double getVar() const = 0;
00095 virtual double eval() const = 0;
00096
00100 virtual const ::std::string getFuncString() const = 0;
00101
00102 double operator()(double var);
00103 };
00104
00105
00106 }}
00107
00108 #endif
00109