1527
|
1 /* |
|
2 |
7017
|
3 Copyright (C) 1995, 1996, 1997, 2005, 2007 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 |
7016
|
9 Free Software Foundation; either version 3 of the License, or (at your |
|
10 option) any later version. |
1527
|
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 |
7016
|
18 along with Octave; see the file COPYING. If not, see |
|
19 <http://www.gnu.org/licenses/>. |
1527
|
20 |
|
21 */ |
|
22 |
|
23 #if !defined (octave_base_min_h) |
|
24 #define octave_base_min_h 1 |
|
25 |
|
26 #include "dColVector.h" |
|
27 |
1879
|
28 class |
|
29 base_minimizer |
1527
|
30 { |
1837
|
31 public: |
1527
|
32 |
1879
|
33 base_minimizer (void) : x () { } |
1527
|
34 |
1879
|
35 base_minimizer (const ColumnVector& xx) : x (xx) { } |
1527
|
36 |
1879
|
37 base_minimizer (const base_minimizer& a) : x (a.x) { } |
1527
|
38 |
|
39 virtual ~base_minimizer (void) { } |
|
40 |
|
41 base_minimizer& operator = (const base_minimizer& a) |
|
42 { |
1879
|
43 if (this != &a) |
|
44 x = a.x; |
|
45 |
1527
|
46 return *this; |
|
47 } |
|
48 |
|
49 // Derived classes must provide a function to actually do the |
|
50 // minimization. |
|
51 |
5275
|
52 virtual ColumnVector do_minimize (double& objf, octave_idx_type& inform, |
1527
|
53 ColumnVector& lambda) = 0; |
|
54 |
|
55 // Lots of ways to call the single function and optionally set and |
|
56 // get additional information. |
|
57 |
|
58 virtual ColumnVector minimize (void) |
|
59 { |
|
60 double objf; |
5275
|
61 octave_idx_type inform; |
1536
|
62 ColumnVector lambda; |
1527
|
63 return do_minimize (objf, inform, lambda); |
|
64 } |
|
65 |
|
66 virtual ColumnVector minimize (double& objf) |
|
67 { |
5275
|
68 octave_idx_type inform; |
1536
|
69 ColumnVector lambda; |
1527
|
70 return do_minimize (objf, inform, lambda); |
|
71 } |
|
72 |
5275
|
73 virtual ColumnVector minimize (double& objf, octave_idx_type& inform) |
1527
|
74 { |
1536
|
75 ColumnVector lambda; |
1527
|
76 return do_minimize (objf, inform, lambda); |
|
77 } |
|
78 |
5275
|
79 virtual ColumnVector minimize (double& objf, octave_idx_type& inform, |
1527
|
80 ColumnVector& lambda) |
|
81 { |
|
82 return do_minimize (objf, inform, lambda); |
|
83 } |
|
84 |
|
85 virtual ColumnVector minimize (const ColumnVector& x0) |
|
86 { |
|
87 x = x0; |
|
88 double objf; |
5275
|
89 octave_idx_type inform; |
1536
|
90 ColumnVector lambda; |
1527
|
91 return do_minimize (objf, inform, lambda); |
|
92 } |
|
93 |
|
94 virtual ColumnVector minimize (const ColumnVector& x0, double& objf) |
|
95 { |
|
96 x = x0; |
5275
|
97 octave_idx_type inform; |
1536
|
98 ColumnVector lambda; |
1527
|
99 return do_minimize (objf, inform, lambda); |
|
100 } |
|
101 |
|
102 virtual ColumnVector minimize (const ColumnVector& x0, double& objf, |
5275
|
103 octave_idx_type& inform) |
1527
|
104 { |
|
105 x = x0; |
1536
|
106 ColumnVector lambda; |
1527
|
107 return do_minimize (objf, inform, lambda); |
|
108 } |
|
109 |
|
110 virtual ColumnVector minimize (const ColumnVector& x0, double& objf, |
5275
|
111 octave_idx_type& inform, ColumnVector& lambda) |
1527
|
112 { |
|
113 x = x0; |
|
114 return do_minimize (objf, inform, lambda); |
|
115 } |
|
116 |
5275
|
117 octave_idx_type size (void) const { return x.capacity (); } |
1835
|
118 |
1527
|
119 protected: |
|
120 |
|
121 ColumnVector x; |
|
122 }; |
|
123 |
|
124 #endif |
|
125 |
|
126 /* |
|
127 ;;; Local Variables: *** |
|
128 ;;; mode: C++ *** |
|
129 ;;; End: *** |
|
130 */ |