Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages

OptimizePick.h (Maintainer: Eva Lange)

Go to the documentation of this file.
00001 // -*- Mode: C++; tab-width: 2; -*-
00002 // vi: set ts=2:
00003 //
00004 // --------------------------------------------------------------------------
00005 //                   OpenMS Mass Spectrometry Framework
00006 // --------------------------------------------------------------------------
00007 //  Copyright (C) 2003-2008 -- Oliver Kohlbacher, Knut Reinert
00008 //
00009 //  This library is free software; you can redistribute it and/or
00010 //  modify it under the terms of the GNU Lesser General Public
00011 //  License as published by the Free Software Foundation; either
00012 //  version 2.1 of the License, or (at your option) any later version.
00013 //
00014 //  This library is distributed in the hope that it will be useful,
00015 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017 //  Lesser General Public License for more details.
00018 //
00019 //  You should have received a copy of the GNU Lesser General Public
00020 //  License along with this library; if not, write to the Free Software
00021 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022 //
00023 // --------------------------------------------------------------------------
00024 // $Maintainer: Eva Lange $
00025 // --------------------------------------------------------------------------
00026 
00027 #ifndef OPENMS_TRANSFORMATIONS_RAW2PEAK_OPTIMIZEPICK_H
00028 #define OPENMS_TRANSFORMATIONS_RAW2PEAK_OPTIMIZEPICK_H
00029 
00030 #include <OpenMS/TRANSFORMATIONS/RAW2PEAK/PeakShape.h>
00031 #include <OpenMS/KERNEL/DRawDataPoint.h>
00032 
00033 #include <gsl/gsl_vector.h>
00034 #include <gsl/gsl_multifit_nlin.h>
00035 #include <gsl/gsl_blas.h>
00036 
00037 #include <iostream>
00038 #include <fstream>
00039 #include <vector>
00040 
00041 namespace OpenMS
00042 {
00048   namespace OptimizationFunctions
00049   {
00051     typedef std::vector<DRawDataPoint<1> > RawDataVector;
00053     typedef RawDataVector::iterator RawDataPointIterator;
00054 
00063     struct PenaltyFactors
00064     {
00065       PenaltyFactors() : pos(0), lWidth(0), rWidth(0) {}
00066       PenaltyFactors(const PenaltyFactors& p) : pos(p.pos), lWidth(p.lWidth), rWidth(p.rWidth) {}
00067       inline PenaltyFactors& operator=(const PenaltyFactors& p)
00068       {
00069         pos=p.pos;
00070         lWidth=p.lWidth;
00071         rWidth=p.rWidth;
00072 
00073         return *this;
00074       }
00075       ~PenaltyFactors(){}
00076 
00078       double pos;
00080       double lWidth;
00082       double rWidth;
00083     };
00084 
00086     extern std::vector<double> positions_;
00087     extern std::vector<double> signal_;
00089     extern std::vector<PeakShape> peaks_;
00090 
00092     int residual(const gsl_vector* x, void* /* params */, gsl_vector* f);
00093 
00095     int jacobian(const gsl_vector* x, void* /* params */, gsl_matrix* J);
00096 
00098     int evaluate(const gsl_vector* x, void* params, gsl_vector* f, gsl_matrix* J);
00099     
00101     void printSignal(const gsl_vector* x, float resolution = 0.25);
00102   }
00103 
00104 
00113   class OptimizePick
00114   {
00115   public:
00117     typedef std::vector<DRawDataPoint<1> > RawDataVector;
00119     typedef RawDataVector::iterator RawDataPointIterator;
00121 
00122 
00124     OptimizePick( )
00125         : max_iteration_(0),
00126         eps_abs_(0),
00127     eps_rel_(0) {}
00128     
00130     OptimizePick(const struct OptimizationFunctions::PenaltyFactors& penalties_,
00131                  const int max_iteration_,
00132                  const double eps_abs_,
00133                  const double eps_rel_ );
00134     
00136     ~OptimizePick();
00137         
00139     inline const struct OptimizationFunctions::PenaltyFactors& getPenalties() const { return penalties_; }
00141     inline struct OptimizationFunctions::PenaltyFactors& getPenalties() { return penalties_; }
00143     inline void setPenalties(const struct OptimizationFunctions::PenaltyFactors& penalties) { penalties_ = penalties; }
00144 
00146     inline UInt getNumberIterations() const { return max_iteration_; }
00148     inline unsigned int& getNumberIterations() { return max_iteration_; }
00150     inline void setNumberIterations(const int max_iteration) { max_iteration_ = max_iteration; }
00151 
00153     inline DoubleReal getMaxAbsError() const { return eps_abs_; }
00155     inline double& getMaxAbsError() { return eps_abs_; }
00157     inline void setMaxAbsError(double eps_abs) { eps_abs_ = eps_abs; }
00158 
00160     inline DoubleReal getMaxRelError() const { return eps_rel_; }
00162     inline double& getMaxRelError() { return eps_rel_; }
00164     inline void setMaxRelError(double eps_rel) { eps_rel_ = eps_rel; }
00166 
00167 
00169     void optimize(std::vector<PeakShape>& peaks);
00170 
00171   
00172   protected:
00174     struct OptimizationFunctions::PenaltyFactors penalties_;
00175 
00177     unsigned int max_iteration_;
00178 
00180     double eps_abs_;
00181     double eps_rel_;
00182 
00188     double correlate_(const PeakShape& peak,
00189                       double left_endpoint,
00190                       double right_endpoint);
00191     
00192   };
00193 }
00194 
00195 #endif

Generated Tue Apr 1 15:36:36 2008 -- using doxygen 1.5.4 OpenMS / TOPP 1.1