3
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
3
|
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. |
3
|
21 |
|
22 */ |
|
23 |
382
|
24 #if !defined (octave_QP_h) |
|
25 #define octave_QP_h 1 |
|
26 |
463
|
27 #include "dMatrix.h" |
|
28 #include "dColVector.h" |
3
|
29 #include "Bounds.h" |
|
30 #include "LinConst.h" |
1528
|
31 #include "base-min.h" |
3
|
32 |
1861
|
33 class |
|
34 QP : public base_minimizer |
3
|
35 { |
1861
|
36 public: |
3
|
37 |
1861
|
38 QP (void) |
|
39 : base_minimizer (), H (), c (), bnds (), lc () { } |
1528
|
40 |
|
41 QP (const ColumnVector& x, const Matrix& H_arg) |
1861
|
42 : base_minimizer (x), H (H_arg), c (), bnds (), lc () |
1528
|
43 { make_h_symmetric (); } |
|
44 |
|
45 QP (const ColumnVector& x, const Matrix& H_arg, const ColumnVector& c_arg) |
1861
|
46 : base_minimizer (x), H (H_arg), c (c_arg), bnds (), lc () |
1528
|
47 { make_h_symmetric (); } |
|
48 |
|
49 QP (const ColumnVector& x, const Matrix& H_arg, const Bounds& b) |
1861
|
50 : base_minimizer (x), H (H_arg), c (), bnds (b), lc () |
1528
|
51 { make_h_symmetric (); } |
|
52 |
|
53 QP (const ColumnVector& x, const Matrix& H_arg, const LinConst& l) |
1866
|
54 : base_minimizer (x), H (H_arg), c (), bnds (), lc (l) |
1528
|
55 { make_h_symmetric (); } |
3
|
56 |
1528
|
57 QP (const ColumnVector& x, const Matrix& H_arg, const ColumnVector& c_arg, |
|
58 const Bounds& b) |
1861
|
59 : base_minimizer (x), H (H_arg), c (c_arg), bnds (b), lc () |
1528
|
60 { make_h_symmetric (); } |
|
61 |
|
62 QP (const ColumnVector& x, const Matrix& H_arg, const ColumnVector& c_arg, |
|
63 const LinConst& l) |
1861
|
64 : base_minimizer (x), H (H_arg), c (c_arg), bnds (), lc (l) |
1528
|
65 { make_h_symmetric (); } |
3
|
66 |
1528
|
67 QP (const ColumnVector& x, const Matrix& H_arg, const Bounds& b, |
|
68 const LinConst& l) |
1861
|
69 : base_minimizer (x), H (H_arg), c (), bnds (b), lc (l) |
1528
|
70 { make_h_symmetric (); } |
|
71 |
|
72 QP (const ColumnVector& x, const Matrix& H_arg, const ColumnVector& c_arg, |
|
73 const Bounds& b, const LinConst& l) |
|
74 : base_minimizer (x), H (H_arg), c (c_arg), bnds (b), lc (l) |
|
75 { make_h_symmetric (); } |
|
76 |
1861
|
77 QP (const QP& qp) |
|
78 : base_minimizer (qp), H (qp.H), c (qp.c), bnds (qp.bnds), lc (qp.lc) { } |
|
79 |
|
80 QP& operator = (const QP& qp) |
|
81 { |
|
82 if (this != &qp) |
|
83 { |
|
84 base_minimizer::operator = (qp); |
|
85 |
|
86 H = qp.H; |
|
87 c = qp.c; |
|
88 bnds = qp.bnds; |
|
89 lc = qp.lc; |
|
90 } |
|
91 return *this; |
|
92 } |
|
93 |
1866
|
94 virtual ~QP (void) { } |
1861
|
95 |
|
96 Matrix hessian (void) const { return H; } |
|
97 |
|
98 ColumnVector linear_obj_coeff (void) const { return c; } |
|
99 |
|
100 Bounds bounds (void) const { return bnds; } |
|
101 |
|
102 LinConst linear_constraints (void) const { return lc; } |
|
103 |
|
104 protected: |
3
|
105 |
|
106 Matrix H; |
1528
|
107 ColumnVector c; |
3
|
108 Bounds bnds; |
|
109 LinConst lc; |
|
110 |
1861
|
111 private: |
3
|
112 |
1528
|
113 Matrix make_h_symmetric (void) { return 0.5 * (H + H.transpose ()); } |
3
|
114 }; |
|
115 |
|
116 #endif |
|
117 |
|
118 /* |
|
119 ;;; Local Variables: *** |
|
120 ;;; mode: C++ *** |
|
121 ;;; End: *** |
|
122 */ |