2 qlp.cc -- implement Mixed_qp
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
13 Mixed_qp::add_equality_cons(Vector , double )
19 Mixed_qp::add_fixed_var(int i, Real r)
27 eliminate appropriate variables, until we have a Ineq_constrained_qp
31 cons should be ascending
34 Mixed_qp::solve(Vector start) const
40 Ineq_constrained_qp pure(*this);
42 for (int i= eq_cons.size()-1; i>=0; i--) {
43 pure.eliminate_var(eq_cons[i], eq_consrhs[i]);
44 start.del(eq_cons[i]);
46 Vector sol = pure.solve(start);
47 for (int i= 0; i < eq_cons.size(); i++) {
48 sol.insert( eq_consrhs[i],eq_cons[i]);
55 Ineq_constrained_qp::assert_solution(Vector sol) const
58 for (int i=0; i < cons.size(); i++) {
59 Real R=cons[i] * sol- consrhs[i];
69 Ineq_constrained_qp::print() const
72 mtor << "Quad " << quad;
73 mtor << "lin " << lin <<"\n"
74 << "const " << const_term<<"\n";
75 for (int i=0; i < cons.size(); i++) {
76 mtor << "constraint["<<i<<"]: " << cons[i] << " >= " << consrhs[i];
82 Mixed_qp::Mixed_qp(int n)
83 : Ineq_constrained_qp(n)
91 Ineq_constrained_qp::OK();
92 assert(eq_consrhs.size() == eq_cons.size());
97 Mixed_qp::print() const
100 Ineq_constrained_qp::print();
101 for (int i=0; i < eq_cons.size(); i++) {
102 mtor << "eq cons "<<i<<": x["<<eq_cons[i]<<"] == " << eq_consrhs[i]<<"\n";