2 qlpsolve.hh -- declare Active_constraints, Inactive_iter
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
17 This class represents the set of active (binding) constraints
18 which can be active while the QLP algorithm is in a feasible
19 point. The active constraints are numbered.
20 If the constraints are of the form
24 then the binding constraints are those where the >= is equality.
28 class Active_constraints {
29 friend class Inactive_iter;
34 Array<int> inactive; // actually this is a set, not an array.
35 Ineq_constrained_qp const *opt;
39 int degenerate_count_i_;
40 String status() const;
42 Vector vec (int k) const { return opt->cons_[k]; }
43 Real rhs (int k) const { return opt->consrhs_[k]; }
46 /** drop constraint. drop constraint k from the active set. k is the index of the
47 constraint in #active#
50 void drop_constraint (int k);
54 add constraint j to the active set j is the index of the
55 constraint in #inactive#
57 void add_constraint (int j);
59 /// exchange in and out.
60 void exchange (int in, int out) { add_constraint (in); drop_constraint (out); }
63 Vector find_active_optimum (Vector g);
65 /// get lagrange multipliers.
66 Vector get_lagrange (Vector v);
68 Active_constraints (Ineq_constrained_qp const *op);
69 /** construct: no constraints active, n vars. Put the equalities
70 into the constraints. */
78 loop through the inactive constraints.
82 Active_constraints const* ac;
84 Inactive_iter (Active_constraints const &c) { ac=&c; j=0; }
85 int idx() const { return j; }
86 void operator ++(int) { j++; }
87 int constraint_id() const { return ac->inactive[j]; }
88 Vector vec() const { return ac->vec (constraint_id ()); }
89 Real rhs() const { return ac->rhs (constraint_id ()); }
90 bool ok() const { return j < ac->inactive.size (); }