lilypond-0.0.5
[lilypond.git] / qlp.hh
blobb539fe6b865798de9a309e9a10c961ec75d72360
1 #ifndef QLP_HH
2 #define QLP_HH
4 #include "matrix.hh"
6 /// inequality constrained quadratic program
7 class Ineq_constrained_qp {
8 friend class Active_constraints;
10 svec<Vector> cons;
11 svec<Real> consrhs;
12 public:
13 Matrix quad;
14 Vector lin;
15 Real const_term;
17 ///
18 void assert_solution(Vector sol) const;
19 /**
20 use a KKT method to assert optimality of sol
22 /// solve the problem using a projected gradient method
23 Vector solve(Vector start) const;
25 int dim() const{
26 return lin.dim();
28 /** return the number of variables in the problem */
29 ///
30 void add_inequality_cons(Vector c, double r);
31 /**
32 add a constraint
35 c*vars >= r
37 PRE
38 c.dim() == dim();
41 ///
42 Ineq_constrained_qp(int novars);
43 /** set up matrices to go with the problem. */
45 Real eval(Vector v);
46 /**
47 evaluate the quadratic function for input #v#
50 void eliminate_var(int idx, Real value);
51 void OK()const;
52 void print() const;
56 /// Quadratic programming with mixed linear constraints
57 class Mixed_qp :public Ineq_constrained_qp {
58 svec<int> eq_cons;
59 svec<Real> eq_consrhs;
60 public:
61 Mixed_qp(int n);
62 void OK() const;
63 void print() const;
65 Vector solve(Vector start) const;
66 void add_fixed_var(int i , Real value);
68 ///
69 void add_equality_cons(Vector c, double r);
70 /**
71 add a constraint,
73 c*vars == r
75 PRE
76 c.dim()==dim();
80 /**
81 problem definition of a quadratic optimisation problem with linear
82 inequality and equality constraints
85 x^T QUAD x /2 + b^T x
89 #endif