7 Mixed_qp::add_equality_cons(Vector , double )
13 Mixed_qp::add_fixed_var(int i, Real r)
20 Ineq_constrained_qp::add_inequality_cons(Vector c, double r)
26 Ineq_constrained_qp::Ineq_constrained_qp(int novars):
33 Ineq_constrained_qp::OK() const
36 assert(cons.sz() == consrhs.sz());
37 Matrix Qdif= quad - quad.transposed();
38 assert(Qdif.norm()/quad.norm() < EPS);
44 Ineq_constrained_qp::eval (Vector v)
46 return v * quad * v + lin * v + const_term;
49 eliminate appropriate variables, until we have a Ineq_constrained_qp
53 cons should be ascending
56 Mixed_qp::solve(Vector start) const
59 Ineq_constrained_qp pure(*this);
61 for (int i= eq_cons.sz()-1; i>=0; i--) {
62 pure.eliminate_var(eq_cons[i], eq_consrhs[i]);
63 start.del(eq_cons[i]);
65 Vector sol = pure.solve(start);
66 for (int i= 0; i < eq_cons.sz(); i++) {
67 sol.insert( eq_consrhs[i],eq_cons[i]);
73 assume x(idx) == value, and adjust constraints, lin and quad accordingly
76 Ineq_constrained_qp::eliminate_var(int idx, Real value)
78 Vector row(quad.row(idx));
83 quad.delete_column(idx);
89 for (int i=0; i < cons.sz(); i++) {
90 consrhs[i] -= cons[i](idx) *value;
98 Mixed_qp::Mixed_qp(int n)
99 : Ineq_constrained_qp(n)
107 Ineq_constrained_qp::OK();
108 assert(eq_consrhs.sz() == eq_cons.sz());
112 Ineq_constrained_qp::print() const
115 mtor << "Quad " << quad;
116 mtor << "lin " << lin <<"\n";
117 for (int i=0; i < cons.sz(); i++) {
118 mtor << "constraint["<<i<<"]: " << cons[i] << " >= " << consrhs[i];
124 Mixed_qp::print() const
127 Ineq_constrained_qp::print();
128 for (int i=0; i < eq_cons.sz(); i++) {
129 mtor << "eq cons "<<i<<": x["<<eq_cons[i]<<"] == " << eq_consrhs[i]<<"\n";
136 Ineq_constrained_qp::assert_solution(Vector sol) const
139 for (int i=0; i < cons.sz(); i++) {
140 Real R=cons[i] * sol- consrhs[i];