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