00001 /******************************************************************************/ 00002 /* */ 00003 /* N E W T O N M E T H O D C L A S S H E A D E R */ 00004 /* */ 00005 /* Roberto Lopez */ 00006 /* International Center for Numerical Methods in Engineering (CIMNE) */ 00007 /* Technical University of Catalonia (UPC) */ 00008 /* Barcelona, Spain */ 00009 /* E-mail: rlopez@cimne.upc.edu */ 00010 /* */ 00011 /******************************************************************************/ 00012 00013 #ifndef __NEWTONMETHOD_H__ 00014 #define __NEWTONMETHOD_H__ 00015 00016 #include "OptimizationAlgorithm.h" 00017 #include "../ObjectiveFunction/ObjectiveFunction.h" 00018 00019 00020 namespace Purple 00021 { 00022 00023 /// This concrete class represents the Newton's method optimization algorithm 00024 /// for an objective function. 00025 /// 00026 /// @see ObjectiveFunction. 00027 /// @see OptimizationAlgorithm. 00028 00029 class NewtonMethod : public OptimizationAlgorithm 00030 { 00031 00032 private: 00033 00034 /// Initial argument 00035 00036 Vector<double> initialArgument; 00037 00038 /// Objective function gradient norm goal. 00039 /// It is used as a stopping criterion. 00040 00041 double gradientNormGoal; 00042 00043 /// Maximum number of iterations. 00044 /// It is used as a stopping criterion. 00045 00046 int maximumNumberOfIterations; 00047 00048 /// Number of iterations between the training showing progress. 00049 00050 int showPeriod; 00051 00052 /// Evaluation of objective function optimization history. 00053 00054 Vector<double> evaluationHistory; 00055 00056 /// Gradient norm of objective function optimization history. 00057 00058 Vector<double> gradientNormHistory; 00059 00060 00061 public: 00062 00063 // GENERAL CONSTRUCTOR 00064 00065 NewtonMethod(ObjectiveFunction*); 00066 00067 00068 // DEFAULT CONSTRUCTOR 00069 00070 NewtonMethod(void); 00071 00072 00073 // DESTRUCTOR 00074 00075 virtual ~NewtonMethod(void); 00076 00077 00078 // METHODS 00079 00080 // Get methods 00081 00082 Vector<double> getInitialArgument(void); 00083 00084 double getGradientNormGoal(void); 00085 int getMaximumNumberOfIterations(void); 00086 00087 int getShowPeriod(void); 00088 00089 // Set methods 00090 00091 void setInitialArgument(Vector<double>); 00092 00093 void setGradientNormGoal(double); 00094 void setMaximumNumberOfIterations(int); 00095 00096 void setShowPeriod(int); 00097 00098 // Optimization methods 00099 00100 Vector<double> getMinimalArgument(void); 00101 00102 // Utility methods 00103 00104 void print(void); 00105 00106 void load(char*); 00107 void save(char*); 00108 00109 void saveOptimizationHistory(char*); 00110 }; 00111 00112 } 00113 00114 #endif 00115 00116 00117 // Purple: An Open Source Numerical Optimization C++ Library. 00118 // Copyright (C) 2005 Roberto Lopez 00119 // 00120 // This library is free software; you can redistribute it and/or 00121 // modify it under the terms of the GNU Lesser General Public 00122 // License as published by the Free Software Foundation; either 00123 // version 2.1 of the License, or any later version. 00124 // 00125 // This library is distributed in the hope that it will be useful, 00126 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00127 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00128 // Lesser General Public License for more details. 00129 // 00130 // You should have received a copy of the GNU Lesser General Public 00131 // License along with this library; if not, write to the Free Software 00132 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA