1527
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
1527
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
5307
|
19 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
20 02110-1301, USA. |
1527
|
21 |
|
22 */ |
|
23 |
|
24 #if !defined (octave_base_min_h) |
|
25 #define octave_base_min_h 1 |
|
26 |
|
27 #include "dColVector.h" |
|
28 |
1879
|
29 class |
|
30 base_minimizer |
1527
|
31 { |
1837
|
32 public: |
1527
|
33 |
1879
|
34 base_minimizer (void) : x () { } |
1527
|
35 |
1879
|
36 base_minimizer (const ColumnVector& xx) : x (xx) { } |
1527
|
37 |
1879
|
38 base_minimizer (const base_minimizer& a) : x (a.x) { } |
1527
|
39 |
|
40 virtual ~base_minimizer (void) { } |
|
41 |
|
42 base_minimizer& operator = (const base_minimizer& a) |
|
43 { |
1879
|
44 if (this != &a) |
|
45 x = a.x; |
|
46 |
1527
|
47 return *this; |
|
48 } |
|
49 |
|
50 // Derived classes must provide a function to actually do the |
|
51 // minimization. |
|
52 |
5275
|
53 virtual ColumnVector do_minimize (double& objf, octave_idx_type& inform, |
1527
|
54 ColumnVector& lambda) = 0; |
|
55 |
|
56 // Lots of ways to call the single function and optionally set and |
|
57 // get additional information. |
|
58 |
|
59 virtual ColumnVector minimize (void) |
|
60 { |
|
61 double objf; |
5275
|
62 octave_idx_type inform; |
1536
|
63 ColumnVector lambda; |
1527
|
64 return do_minimize (objf, inform, lambda); |
|
65 } |
|
66 |
|
67 virtual ColumnVector minimize (double& objf) |
|
68 { |
5275
|
69 octave_idx_type inform; |
1536
|
70 ColumnVector lambda; |
1527
|
71 return do_minimize (objf, inform, lambda); |
|
72 } |
|
73 |
5275
|
74 virtual ColumnVector minimize (double& objf, octave_idx_type& inform) |
1527
|
75 { |
1536
|
76 ColumnVector lambda; |
1527
|
77 return do_minimize (objf, inform, lambda); |
|
78 } |
|
79 |
5275
|
80 virtual ColumnVector minimize (double& objf, octave_idx_type& inform, |
1527
|
81 ColumnVector& lambda) |
|
82 { |
|
83 return do_minimize (objf, inform, lambda); |
|
84 } |
|
85 |
|
86 virtual ColumnVector minimize (const ColumnVector& x0) |
|
87 { |
|
88 x = x0; |
|
89 double objf; |
5275
|
90 octave_idx_type inform; |
1536
|
91 ColumnVector lambda; |
1527
|
92 return do_minimize (objf, inform, lambda); |
|
93 } |
|
94 |
|
95 virtual ColumnVector minimize (const ColumnVector& x0, double& objf) |
|
96 { |
|
97 x = x0; |
5275
|
98 octave_idx_type inform; |
1536
|
99 ColumnVector lambda; |
1527
|
100 return do_minimize (objf, inform, lambda); |
|
101 } |
|
102 |
|
103 virtual ColumnVector minimize (const ColumnVector& x0, double& objf, |
5275
|
104 octave_idx_type& inform) |
1527
|
105 { |
|
106 x = x0; |
1536
|
107 ColumnVector lambda; |
1527
|
108 return do_minimize (objf, inform, lambda); |
|
109 } |
|
110 |
|
111 virtual ColumnVector minimize (const ColumnVector& x0, double& objf, |
5275
|
112 octave_idx_type& inform, ColumnVector& lambda) |
1527
|
113 { |
|
114 x = x0; |
|
115 return do_minimize (objf, inform, lambda); |
|
116 } |
|
117 |
5275
|
118 octave_idx_type size (void) const { return x.capacity (); } |
1835
|
119 |
1527
|
120 protected: |
|
121 |
|
122 ColumnVector x; |
|
123 }; |
|
124 |
|
125 #endif |
|
126 |
|
127 /* |
|
128 ;;; Local Variables: *** |
|
129 ;;; mode: C++ *** |
|
130 ;;; End: *** |
|
131 */ |