MPQC 2.3.1

- Main Page
- Related Pages
- Classes
- Files

- File List

opt.h
1 //
2 // opt.h
3 //
4 // Copyright (C) 1996 Limit Point Systems, Inc.
5 //
6 // Author: Curtis Janssen <cljanss@limitpt.com>
7 // Maintainer: LPS
8 //
9 // This file is part of the SC Toolkit.
10 //
11 // The SC Toolkit is free software; you can redistribute it and/or modify
12 // it under the terms of the GNU Library General Public License as published by
13 // the Free Software Foundation; either version 2, or (at your option)
14 // any later version.
15 //
16 // The SC Toolkit is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU Library General Public License for more details.
20 //
21 // You should have received a copy of the GNU Library General Public License
22 // along with the SC Toolkit; see the file COPYING.LIB. If not, write to
23 // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24 //
25 // The U.S. Government is granted a limited license as per AL 91-7.
26 //
27
28 #ifndef _math_optimize_opt_h
29 #define _math_optimize_opt_h
30
31 #ifdef __GNUC__
32 #pragma interface
33 #endif
34
35 #include <util/state/state.h>
36 #include <util/class/class.h>
37 #include <math/scmat/matrix.h>
38 #include <math/optimize/function.h>
39 #include <math/optimize/conv.h>
40
41 namespace sc {
42
43 // //////////////////////////////////////////////////////////////////////
44
47 class Optimize: virtual public SavableState {
48 protected:
49 int max_iterations_;
50 int n_iterations_;
51 int ckpt_;
52 int print_timings_;
53 double max_stepsize_;
54 char *ckpt_file;
55 Ref<Function> function_;
56 Ref<Convergence> conv_;
57 public:
58 Optimize();
60 Optimize(StateIn&);
61
86 Optimize(const Ref<KeyVal>&);
87 virtual ~Optimize();
88
89 void save_data_state(StateOut&);
90
93 virtual int optimize();
94
96 void set_checkpoint();
97 void set_checkpoint_file(const char*);
98
100 void set_function(const Ref<Function>&);
101
103 void set_max_iterations(int);
104
106 virtual void init();
109 virtual int update() = 0;
110
111 virtual void apply_transform(const Ref<NonlinearTransform>&);
112
114 Ref<Function> function() const { return function_; }
115 Ref<SCMatrixKit> matrixkit() const { return function_->matrixkit(); }
116 RefSCDimension dimension() const { return function_->dimension(); }
117
118 };
119
120
123 class LineOpt: public Optimize {
124
125 protected:
126
127 double decrease_factor_;
128 RefSCVector initial_x_;
129 double initial_value_;
130 RefSCVector initial_grad_;
131 RefSCVector search_direction_;
132 Ref<Function> function_;
133
134 int sufficient_decrease(RefSCVector& step);
135
136 public:
137
138 LineOpt();
139 LineOpt(StateIn&);
140 LineOpt(const Ref<KeyVal>&);
141 ~LineOpt();
142 void save_data_state(StateOut&);
143
147 virtual void init(RefSCVector& direction);
152 virtual void init(RefSCVector& direction, Ref<Function> function);
154 void apply_transform(const Ref<NonlinearTransform>&);
155
157 double decrease_factor() { return decrease_factor_; }
159 double set_decrease_factor( double factor )
160 { double temp = decrease_factor_; decrease_factor_ = factor; return temp; }
161 };
162
163 class Backtrack: public LineOpt {
164
165 protected:
166 double backtrack_factor_;
167
168 public:
169 Backtrack(const Ref<KeyVal>&);
170 ~Backtrack(){}
171 int update();
172
173 };
174
175 }
176
177 #endif
178
179 // Local Variables:
180 // mode: c++
181 // c-file-style: "CLJ"
182 // End: