00001 // 00002 // opt.h 00003 // 00004 // Copyright (C) 1996 Limit Point Systems, Inc. 00005 // 00006 // Author: Curtis Janssen <cljanss@limitpt.com> 00007 // Maintainer: LPS 00008 // 00009 // This file is part of the SC Toolkit. 00010 // 00011 // The SC Toolkit is free software; you can redistribute it and/or modify 00012 // it under the terms of the GNU Library General Public License as published by 00013 // the Free Software Foundation; either version 2, or (at your option) 00014 // any later version. 00015 // 00016 // The SC Toolkit is distributed in the hope that it will be useful, 00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 // GNU Library General Public License for more details. 00020 // 00021 // You should have received a copy of the GNU Library General Public License 00022 // along with the SC Toolkit; see the file COPYING.LIB. If not, write to 00023 // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 00024 // 00025 // The U.S. Government is granted a limited license as per AL 91-7. 00026 // 00027 00028 #ifndef _math_optimize_opt_h 00029 #define _math_optimize_opt_h 00030 00031 #ifdef __GNUC__ 00032 #pragma interface 00033 #endif 00034 00035 #include <util/state/state.h> 00036 #include <util/class/class.h> 00037 #include <math/scmat/matrix.h> 00038 #include <math/optimize/function.h> 00039 #include <math/optimize/conv.h> 00040 00041 // ////////////////////////////////////////////////////////////////////// 00042 00045 class Optimize: virtual public SavableState { 00046 protected: 00047 int max_iterations_; 00048 int n_iterations_; 00049 int ckpt_; 00050 int print_timings_; 00051 double max_stepsize_; 00052 char *ckpt_file; 00053 Ref<Function> function_; 00054 Ref<Convergence> conv_; 00055 public: 00056 Optimize(); 00058 Optimize(StateIn&); 00059 00084 Optimize(const Ref<KeyVal>&); 00085 virtual ~Optimize(); 00086 00087 void save_data_state(StateOut&); 00088 00091 virtual int optimize(); 00092 00094 void set_checkpoint(); 00095 void set_checkpoint_file(const char*); 00096 00098 void set_function(const Ref<Function>&); 00099 00101 void set_max_iterations(int); 00102 00104 virtual void init(); 00107 virtual int update() = 0; 00108 00109 virtual void apply_transform(const Ref<NonlinearTransform>&); 00110 00112 Ref<Function> function() const { return function_; } 00113 Ref<SCMatrixKit> matrixkit() const { return function_->matrixkit(); } 00114 RefSCDimension dimension() const { return function_->dimension(); } 00115 }; 00116 00117 00120 class LineOpt: public Optimize { 00121 protected: 00122 RefSCVector search_direction_; 00123 public: 00124 LineOpt(); 00125 LineOpt(StateIn&); 00126 LineOpt(const Ref<KeyVal>&); 00127 ~LineOpt(); 00128 void save_data_state(StateOut&); 00129 00130 void apply_tranform(const Ref<NonlinearTransform>&); 00131 00132 void set_search_direction(RefSCVector&); 00133 }; 00134 00135 00136 #endif 00137 00138 // Local Variables: 00139 // mode: c++ 00140 // c-file-style: "CLJ" 00141 // End: