00001 /*************************************************************************** 00002 * @file gnn_lmbfgs.h 00003 * @brief gnn_lmbfgs Header File. 00004 * 00005 * @date : 05-10-03 01:05 00006 * @author : Pedro Ortega C. <peortega@dcc.uchile.cl> 00007 * Copyright 2003 Pedro Ortega C. 00008 ****************************************************************************/ 00009 /* 00010 * This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * This program is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU Library General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU General Public License 00021 * along with this program; if not, write to the Free Software 00022 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00023 */ 00024 00025 #ifndef _GNN_LMBFGS_H_ 00026 #define _GNN_LMBFGS_H_ 00027 00028 00029 00030 /******************************************/ 00031 /* Include Files */ 00032 /******************************************/ 00033 00034 #include "gnn_line_search.h" 00035 #include "gnn_trainer.h" 00036 00037 00038 00039 /******************************************/ 00040 /* Typedefs and Definitions */ 00041 /******************************************/ 00042 00043 /** 00044 * @brief Default precision for line search procedures. 00045 * @ingroup gnn_lmbfgs_doc 00046 * 00047 * This constant defines the tolerance for the line search procedure used by 00048 * the conjugate gradients algorithm. 00049 */ 00050 #define GNN_LMBFGS_TOL 0.0001 00051 00052 /** 00053 * @brief Default bracketing step taken by the line search procedures. 00054 * @ingroup gnn_lmbfgs_doc 00055 * 00056 * This constant defines the initial step taken by the bracketing algorithm 00057 * to search the minimum along the line. 00058 */ 00059 #define GNN_LMBFGS_STEP 0.1 00060 00061 /** 00062 * @brief Default restart. 00063 * @ingroup gnn_lmbfgs_doc 00064 * 00065 * This constant defines the default number of iterations that the conjugate 00066 * gradients algorithm takes before restarting the algorithm. 00067 */ 00068 #define GNN_LMBFGS_RESTART 100 00069 00070 /** 00071 * @brief Default line search procedure. 00072 * @ingroup gnn_lmbfgs_doc 00073 * 00074 * This is the default line search procedure used by the conjugate gradients 00075 * algorithm. 00076 */ 00077 #define GNN_LMBFGS_ALPHA gnn_line_search_brent 00078 00079 /** 00080 * @brief Type for \f$\beta\f$ evaluation procedures. 00081 * @ingroup gnn_lmbfgs_doc 00082 * 00083 * This type defines the form of the procedures for computing the \f$\beta\f$ 00084 * coefficient used by the conjugate gradients method. 00085 */ 00086 typedef double (*gnn_lmbfgs_beta) (gnn_trainer *trainer); 00087 00088 /** 00089 * @brief Conjugate gradients trainer structure. 00090 * @ingroup gnn_lmbfgs_doc 00091 * 00092 * This type extends the basic \ref gnn_trainer structure for the conjugate 00093 * gradients trainer. 00094 */ 00095 typedef struct _gnn_lmbfgs gnn_lmbfgs; 00096 00097 struct _gnn_lmbfgs 00098 { 00099 gnn_trainer trainer; 00100 gsl_vector *wnew; /**< new parameter vector */ 00101 gsl_vector *wold; /**< old parameter vector */ 00102 gsl_vector *gnew; /**< new gradient vector */ 00103 gsl_vector *gold; /**< old gradient vector */ 00104 gsl_vector *v; /**< auxiliary vector */ 00105 gsl_vector *p; /**< auxiliary vector */ 00106 00107 gnn_line *line; /**< line search buffers */ 00108 00109 gnn_line_search_type alpha; /**< line search procedure */ 00110 00111 double step; /**< Initial step taken to bracket search interval */ 00112 double tol; /**< Required precision for line search procedure */ 00113 00114 size_t iteration; /**< Number of the current iteration */ 00115 size_t restart; /**< Number of iterations required to restart */ 00116 }; 00117 00118 00119 00120 /******************************************/ 00121 /* Public Interface */ 00122 /******************************************/ 00123 00124 gnn_trainer * 00125 gnn_lmbfgs_new (gnn_node *node, gnn_criterion *crit, gnn_dataset *data); 00126 00127 int 00128 gnn_lmbfgs_set_tol (gnn_trainer *trainer, double tol); 00129 00130 double 00131 gnn_lmbfgs_get_tol (gnn_trainer *trainer); 00132 00133 int 00134 gnn_lmbfgs_set_step (gnn_trainer *trainer, double step); 00135 00136 double 00137 gnn_lmbfgs_get_step (gnn_trainer *trainer); 00138 00139 int 00140 gnn_lmbfgs_set_restart (gnn_trainer *trainer, size_t restart); 00141 00142 size_t 00143 gnn_lmbfgs_get_restart (gnn_trainer *trainer); 00144 00145 int 00146 gnn_lmbfgs_set_line_search (gnn_trainer *trainer, 00147 gnn_line_search_type lsearch); 00148 00149 gnn_line_search_type 00150 gnn_lmbfgs_get_alpha (gnn_trainer *trainer); 00151 00152 00153 #endif /* _GNN_LMBFGS_H_ */ 00154 00155 00156
1.2.18