MPQC  2.3.1
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 
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);
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:
sc::LineOpt::apply_transform
void apply_transform(const Ref< NonlinearTransform > &)
Applies a nonlinear transform.
sc::LineOpt::set_decrease_factor
double set_decrease_factor(double factor)
Sets factor for sufficient decrease test.
Definition: opt.h:159
sc::LineOpt
The LineOpt abstract class is used to perform one dimensional optimizations.
Definition: opt.h:123
sc::Ref
A template class that maintains references counts.
Definition: ref.h:332
sc::Optimize::save_data_state
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
sc::Optimize
The Optimize class is an abstract base class for classes that find the extreme points of Function's.
Definition: opt.h:47
sc::LineOpt::save_data_state
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
sc::Backtrack::update
int update()
Take a step.
sc::StateIn
Restores objects that derive from SavableState.
Definition: statein.h:70
sc::Optimize::set_max_iterations
void set_max_iterations(int)
Set the iteration limit.
sc::Optimize::set_checkpoint
void set_checkpoint()
Set up for checkpointing.
sc::RefSCVector
The RefSCVector class is a smart pointer to an SCVector specialization.
Definition: matrix.h:55
sc::StateOut
Serializes objects that derive from SavableState.
Definition: stateout.h:61
sc::Optimize::update
virtual int update()=0
Take a step.
sc::Optimize::init
virtual void init()
Initialize the optimizer.
sc::Optimize::set_function
void set_function(const Ref< Function > &)
Set the function to be optimized.
sc::LineOpt::decrease_factor
double decrease_factor()
Returns factor for sufficient decrease test.
Definition: opt.h:157
sc::SavableState
Base class for objects that can save/restore state.
Definition: state.h:46
sc::Optimize::optimize
virtual int optimize()
Do the optimization.
sc::Backtrack
Definition: opt.h:163

Generated at Sun Jan 26 2020 23:33:04 for MPQC 2.3.1 using the documentation package Doxygen 1.8.16.