2 qlpsolve.hh -- declare Active_constraints, Inactive_iter
4 source file of the LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.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 const Ineq_constrained_qp
*opt
;
40 Vector
vec(int k
) const { return opt
->cons
[k
]; }
41 Real
rhs(int k
) const { return opt
->consrhs
[k
]; }
44 /** drop constraint. drop constraint k from the active set. k is the index of the
45 constraint in #active#
52 add constraint j to the active set j is the index of the
53 constraint in #inactive#
57 /// exchange in and out.
58 void exchange(int in
, int out
) { add(in
); drop (out
); }
61 Vector
find_active_optimum(Vector g
);
63 /// get lagrange multipliers.
64 Vector
get_lagrange(Vector v
);
66 Active_constraints(Ineq_constrained_qp
const *op
);
67 /** construct: no constraints active, n vars. Put the equalities
68 into the constraints. */
76 loop through the inactive constraints.
80 Active_constraints
const* ac
;
82 Inactive_iter(Active_constraints
const &c
) { ac
=&c
; j
=0; }
83 int idx() const { return j
; }
84 void operator ++(int) { j
++; }
85 int constraint_id() const { return ac
->inactive
[j
]; }
86 Vector
vec() const { return ac
->vec(constraint_id()); }
87 Real
rhs() const { return ac
->rhs(constraint_id()); }
88 bool ok() const { return j
< ac
->inactive
.size(); }