-
Notifications
You must be signed in to change notification settings - Fork 0
/
freeze.m
40 lines (36 loc) · 1.45 KB
/
freeze.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
function [ h ] = freeze(lambda,h,THR);
% freeze stores a Boolean in "h" to prevent the deactivation at the next levels
% of the constraints whose Lagrange multipliers are nonzero at this level.
%% Synopsis:
% h = freeze(lambda,h)
% h = freeze(lambda,h,THR)
%% INPUT:
% lambda: the multipliers for level kl of h.
% h "h" structure storing all the HQP data.
% THR threshold to test the positivity.
%% Output:
% h The function has a side effect: it modifies the "freeze" field of
% the "h" structure. To account for the side effect, h is returned.
%
% Instead of keeping all the multipliers of any levels, the algorithm "freezes"
% the constraint corresponding to nonzero multipliers. These constraints will
% never be lexicographicaly positive for the following steps of the algorithm.
% A freezed constraint cannot be removed from the active set and therefore
% stays, freezed and active, as an equality constraint until the end of the
% active search.
%
% Copyright Nicolas Mansard -- LAAS/CNRS
% -- and Adrien Escande -- JRL/CNRS
% -- cf. LICENSE.txt
%
% --- DEFAULT ARGUMENTS --------------------------------------------------------
if nargin==2
THR=1e-8;
end
% ---------------------------------------------------------------------
kl = length(lambda);
for k=1:kl
positive = find( abs(lambda{k})>THR );
iPositive = h(k).active(positive);
h(k).freeze( iPositive ) = 1;
end