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
41namespace sc {
42
43// //////////////////////////////////////////////////////////////////////
44
47class 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();
61
87 virtual ~Optimize();
88
90
93 virtual int optimize();
94
97 void set_checkpoint_file(const char*);
98
101
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
123class 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();
140 LineOpt(const Ref<KeyVal>&);
141 ~LineOpt();
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
163class 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:
Definition opt.h:163
int update()
Take a step.
The LineOpt abstract class is used to perform one dimensional optimizations.
Definition opt.h:123
double set_decrease_factor(double factor)
Sets factor for sufficient decrease test.
Definition opt.h:159
virtual void init(RefSCVector &direction)
Initializes the line search object.
double decrease_factor()
Returns factor for sufficient decrease test.
Definition opt.h:157
void apply_transform(const Ref< NonlinearTransform > &)
Applies a nonlinear transform.
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
virtual void init(RefSCVector &direction, Ref< Function > function)
Initializes the line search object.
The Optimize class is an abstract base class for classes that find the extreme points of Function's.
Definition opt.h:47
void set_max_iterations(int)
Set the iteration limit.
void set_checkpoint()
Set up for checkpointing.
Optimize(StateIn &)
Restore the state of a Function object.
Ref< Function > function() const
Returns information about the Function being optimized.
Definition opt.h:114
void set_function(const Ref< Function > &)
Set the function to be optimized.
virtual int optimize()
Do the optimization.
virtual void init()
Initialize the optimizer.
virtual int update()=0
Take a step.
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
Optimize(const Ref< KeyVal > &)
The KeyVal constructor reads the following information:
The RefSCVector class is a smart pointer to an SCVector specialization.
Definition matrix.h:55
A template class that maintains references counts.
Definition ref.h:332
Base class for objects that can save/restore state.
Definition state.h:46
Restores objects that derive from SavableState.
Definition statein.h:70
Serializes objects that derive from SavableState.
Definition stateout.h:61

Generated at Thu Jan 25 2024 00:00:00 for MPQC 2.3.1 using the documentation package Doxygen 1.10.0.