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):
34 Ineq_constrained_qp::OK() const
37 assert(cons.size() == consrhs.size());
38 Matrix Qdif= quad - quad.transposed();
39 assert(Qdif.norm()/quad.norm() < EPS);
45 Ineq_constrained_qp::eval (Vector v)
47 return v * quad * v + lin * v + const_term;
51 eliminate appropriate variables, until we have a Ineq_constrained_qp
55 cons should be ascending
58 Mixed_qp::solve(Vector start) const
61 Ineq_constrained_qp pure(*this);
63 for (int i= eq_cons.size()-1; i>=0; i--) {
64 pure.eliminate_var(eq_cons[i], eq_consrhs[i]);
65 start.del(eq_cons[i]);
67 Vector sol = pure.solve(start);
68 for (int i= 0; i < eq_cons.size(); i++) {
69 sol.insert( eq_consrhs[i],eq_cons[i]);
75 assume x(idx) == value, and adjust constraints, lin and quad accordingly
80 Ineq_constrained_qp::eliminate_var(int idx, Real value)
82 Vector row(quad.row(idx));
87 quad.delete_column(idx);
93 for (int i=0; i < cons.size(); i++) {
94 consrhs[i] -= cons[i](idx) *value;
102 Ineq_constrained_qp::assert_solution(Vector sol) const
105 for (int i=0; i < cons.size(); i++) {
106 Real R=cons[i] * sol- consrhs[i];
116 Ineq_constrained_qp::print() const
119 mtor << "Quad " << quad;
120 mtor << "lin " << lin <<"\n"
121 << "const " << const_term<<"\n";
122 for (int i=0; i < cons.size(); i++) {
123 mtor << "constraint["<<i<<"]: " << cons[i] << " >= " << consrhs[i];
129 /* *************** */
131 Mixed_qp::Mixed_qp(int n)
132 : Ineq_constrained_qp(n)
140 Ineq_constrained_qp::OK();
141 assert(eq_consrhs.size() == eq_cons.size());
146 Mixed_qp::print() const
149 Ineq_constrained_qp::print();
150 for (int i=0; i < eq_cons.size(); i++) {
151 mtor << "eq cons "<<i<<": x["<<eq_cons[i]<<"] == " << eq_consrhs[i]<<"\n";