-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathSDPT3soln_SEDUMIsoln.m
More file actions
executable file
·114 lines (112 loc) · 2.69 KB
/
SDPT3soln_SEDUMIsoln.m
File metadata and controls
executable file
·114 lines (112 loc) · 2.69 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
%%**********************************************************
%% SDPT3soln_SEDUMIsoln: convert SQLP solution in SDPT3 format to
%% SeDuMi format
%%
%% [xx,yy,zz] = SDPT3soln_SEDUMIsoln(blk,X,y,Z,perm);
%%
%% usage: load SEDUMI_data_file (containing say, A,b,c,K)
%% [blk,At,C,b,perm] = read_sedumi(A,b,c,K);
%% [obj,X,y,Z] = sdpt3(blk,At,C,b);
%% [xx,yy,zz] = SDPT3soln_SEDUMIsoln(blk,X,y,Z,perm);
%%
%% SDPT3: version 3.1
%% Copyright (c) 1997 by
%% K.C. Toh, M.J. Todd, R.H. Tutuncu
%% Last Modified: 16 Sep 2004
%%**********************************************************
function [xx,yy,zz] = SDPT3soln_SEDUMIsoln(blk,X,y,Z,perm)
yy = y;
xx = []; zz = [];
%%
%% extract unrestricted blk
%%
for p = 1:size(blk,1)
pblk = blk(p,:);
if strcmp(pblk{1},'u')
xx = [xx; X{p,1}]; %#ok
zz = [zz; Z{p,1}]; %#ok
end
end
%%
%% extract linear blk
%%
for p = 1:size(blk,1)
pblk = blk(p,:);
if strcmp(pblk{1},'l')
xx = [xx; X{p,1}]; %#ok
zz = [zz; Z{p,1}]; %#ok
end
end
%%
%% extract second order cone blk
%%
for p = 1:size(blk,1)
pblk = blk(p,:);
if strcmp(pblk{1},'q')
xx = [xx; X{p,1}]; %#ok
zz = [zz; Z{p,1}]; %#ok
end
end
%%
%% extract rotated cone blk
%%
for p = 1:size(blk,1)
pblk = blk(p,:);
if strcmp(pblk{1},'r')
xx = [xx; X{p,1}]; %#ok
zz = [zz; Z{p,1}]; %#ok
end
end
%%
%% extract semidefinite cone blk
%%
per = [];
sblk = [];
len = 0;
for p = 1:size(blk,1)
pblk = blk(p,:);
if strcmp(pblk{1},'s')
sblk(p) = length(pblk{2}); %#ok
per = [per, perm{p}]; %#ok
len = len + sum(pblk{2}.*pblk{2});
end
end
sblk = sum(sblk);
cnt = 1;
Xsblk = cell(sblk,1); Zsblk = cell(sblk,1);
for p = 1:size(blk,1)
pblk = blk(p,:);
if strcmp(pblk{1},'s')
ss = [0,cumsum(pblk{2})];
numblk = length(pblk{2});
Xp = X{p,1};
Zp = Z{p,1};
for tt = 1:numblk
if (numblk > 1)
idx = ss(tt)+1: ss(tt+1);
Xsblk{cnt} = full(Xp(idx,idx));
Zsblk{cnt} = full(Zp(idx,idx));
else
Xsblk{cnt} = Xp;
Zsblk{cnt} = Zp;
end
cnt = cnt + 1;
end
end
end
if ~isempty(per)
Xsblk(per) = Xsblk; Zsblk(per) = Zsblk;
xtmp = zeros(len,1); ztmp = zeros(len,1);
cnt = 0;
for p = 1:sblk
if strcmp(pblk{1},'s')
idx = 1:length(Xsblk{p})^2;
xtmp(cnt+idx) = Xsblk{p}(:);
ztmp(cnt+idx) = Zsblk{p}(:);
cnt = cnt + length(idx);
end
end
xx = [xx; xtmp];
zz = [zz; ztmp];
end
%%**********************************************************