2 qlp.cc -- implement Mixed_qp
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
12 #include "choleski.hh"
16 Mixed_qp::add_equality_cons(Vector , double )
22 Mixed_qp::add_fixed_var(int i, Real r)
30 eliminate appropriate variables, until we have a Ineq_constrained_qp
34 cons should be ascending
37 Mixed_qp::solve(Vector start) const
43 Ineq_constrained_qp pure(*this);
45 for (int i= eq_cons.size()-1; i>=0; i--) {
46 pure.eliminate_var(eq_cons[i], eq_consrhs[i]);
47 start.del(eq_cons[i]);
49 Vector sol = pure.solve(start);
50 for (int i= 0; i < eq_cons.size(); i++) {
51 sol.insert( eq_consrhs[i],eq_cons[i]);
58 Ineq_constrained_qp::assert_solution(Vector sol) const
61 for (int i=0; i < cons.size(); i++) {
62 Real R=cons[i] * sol- consrhs[i];
72 Ineq_constrained_qp::print() const
75 mtor << "Quad " << quad;
76 mtor << "lin " << lin <<"\n"
77 << "const " << const_term<<"\n";
78 for (int i=0; i < cons.size(); i++) {
79 mtor << "constraint["<<i<<"]: " << cons[i] << " >= " << consrhs[i];
85 Mixed_qp::Mixed_qp(int n)
86 : Ineq_constrained_qp(n)
94 Ineq_constrained_qp::OK();
95 assert(eq_consrhs.size() == eq_cons.size());
100 Mixed_qp::print() const
103 Ineq_constrained_qp::print();
104 for (int i=0; i < eq_cons.size(); i++) {
105 mtor << "eq cons "<<i<<": x["<<eq_cons[i]<<"] == " << eq_consrhs[i]<<"\n";