source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/opt/yalmip/modules/parametric/mpt_collect_equalities.m @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

File size: 1.2 KB
Line 
1function Matrices = mpt_collect_equalities(Matrices,equalities)
2
3% These were just found
4Aeq_fixed = Matrices.G(equalities,:);
5Beq_fixed = -Matrices.E(equalities,:);
6beq_fixed = Matrices.W(equalities,:);
7
8% For numerical reasons, remove fixed variables in old constraints
9% (This will remove big numbers from big-M)
10if ~isempty(Matrices.Aeq)
11    fixed = find(Matrices.lb(1:Matrices.nu) == Matrices.ub(1:Matrices.nu));
12    if ~isempty(fixed)
13        Matrices.beq = Matrices.beq - Matrices.Aeq(:,fixed)*Matrices.lb(fixed);
14        Matrices.Aeq(:,fixed) = 0;
15    end
16
17    skip = find(~any(full([Matrices.Aeq Matrices.beq Matrices.Beq]),2));
18    if ~isempty(skip)
19        Matrices.Aeq(skip,:) = [];
20        Matrices.Beq(skip,:) = [];
21        Matrices.beq(skip,:) = [];
22    end
23end
24
25% These variables are fixed
26fixed = find(Matrices.lb == Matrices.ub);
27if ~isempty(fixed)
28    fixed = fixed(find(fixed <= Matrices.nu));
29end
30
31Aeq = sparse(1:length(fixed),fixed,ones(length(fixed),1),length(fixed),size(Matrices.G,2));
32
33Beq = zeros(length(fixed),size(Matrices.E,2));
34beq = Matrices.lb(fixed);
35
36% Merge everything with original equalities
37Matrices.Aeq = [Aeq;Matrices.Aeq;Aeq_fixed];
38Matrices.Beq = [Beq;Matrices.Beq;Beq_fixed];
39Matrices.beq = [beq;Matrices.beq;beq_fixed];
Note: See TracBrowser for help on using the repository browser.