BALL
1.4.1
|
00001 /* fitModel.h 00002 * 00003 * Copyright (C) 2009 Marcel Schumann 00004 * 00005 * This file is part of QuEasy -- A Toolbox for Automated QSAR Model 00006 * Construction and Validation. 00007 * QuEasy is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 3 of the License, or (at 00010 * your option) any later version. 00011 * 00012 * QuEasy is distributed in the hope that it will be useful, but 00013 * WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, see <http://www.gnu.org/licenses/>. 00019 */ 00020 00021 // -*- Mode: C++; tab-width: 2; -*- 00022 // vi: set ts=2: 00023 // 00024 // 00025 00026 #ifndef FMODEL 00027 #define FMODEL 00028 00029 #ifndef NLMODEL 00030 #include <BALL/QSAR/nonlinearModel.h> 00031 #endif 00032 00033 #include <gsl/gsl_multifit_nlin.h> 00034 #include <gsl/gsl_deriv.h> 00035 #include <gsl/gsl_math.h> 00036 #include <BALL/MATHS/parsedFunction.h> 00037 00038 //#include <list> 00039 00040 namespace BALL 00041 { 00042 namespace QSAR 00043 { 00044 class BALL_EXPORT FitModel : public NonLinearModel 00045 { 00046 public: 00050 FitModel(const QSARData& q); 00051 00052 FitModel(const QSARData& q, vector<String>& eq, vector<double>& guess); 00053 00054 FitModel(const QSARData& q, vector<String>& eq, vector<vector<String> >& deq, vector<double>& guess); 00055 00056 //~FitModel(); 00058 00059 00066 void setEquations(vector<String>& eq, vector<vector<String> >& deq); 00067 00069 void setEquations(vector<String>& eq); 00070 00072 void train(); 00073 00074 Vector<double> predict(const vector<double>& substance, bool transform=1); 00075 00076 void setInitialGuess(vector<double>& d); 00078 00079 00080 private: 00085 vector<String> allEquations_; 00086 00088 vector<vector<String> > allDiffEquations_; 00089 00091 //vector<String> allCoefficients; 00092 00093 vector<double> initial_guess_; 00095 00096 }; 00097 00098 00099 00100 const Matrix<double>* fitX; 00101 Matrix<double>* fitY; 00102 String* equation; 00103 vector<String>* diffEquations; 00104 ParsedFunction<double>* f; 00105 unsigned int c; // current column 00106 00107 double getFunctionValue(double X, void* params); 00108 00109 int setF(const gsl_vector* x, void* params, gsl_vector* f); 00110 00111 int setDf(const gsl_vector * x, void* params, gsl_matrix * df); 00112 00113 int setFdf (const gsl_vector * x, void *params, gsl_vector * f, gsl_matrix * df); 00114 00115 gsl_multifit_function_fdf make_fdf (int (* f) (const gsl_vector *, void *, gsl_vector *), 00116 int (* df) (const gsl_vector *, void *, gsl_matrix *), 00117 int (* fdf) (const gsl_vector *, void *, gsl_vector *, gsl_matrix *), 00118 size_t n, 00119 size_t p, void * params ); 00120 00121 } 00122 } 00123 00124 #endif // FMODEL