-
Notifications
You must be signed in to change notification settings - Fork 7
/
demoMotor.m
175 lines (140 loc) · 4.42 KB
/
demoMotor.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
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
clear variables;
global footpath;
%delete(gcp)
%parpool
footpath = cd;
footpath = strcat(footpath,'/fgm');
rng(45678);
rmpath('./HBPMex/');
rmpath(footpath);
rmpath(genpath([footpath '/src']));
rmpath(genpath([footpath '/lib']));
addpath('./HBPMex/');
addpath(footpath);
addpath(genpath([footpath '/src']));
addpath(genpath([footpath '/lib']));
prSet(1);
%% src parameter
tag = 'pas';
MaxInstance = 20;
NofAlgos = 11;
%% src parameter
tag = 'pas';
parKnl = st('alg', 'pas'); % type of affinity: only edge distance
MaxOutliers = 20;
AvgAcc = zeros(MaxOutliers, NofAlgos);
AvgObj = zeros(MaxOutliers, NofAlgos);
StdAcc = zeros(MaxOutliers, NofAlgos);
StdObj = zeros(MaxOutliers, NofAlgos);
AvgTime = zeros(MaxOutliers, NofAlgos);
StdTime = zeros(MaxOutliers, NofAlgos);
for nOut = 0:20
accs = cell(MaxInstance, 1);
objs = cell(MaxInstance, 1);
times = cell(MaxInstance, 1);
bpoptions.outIter = 1;
bpoptions.innerIter = 5;
BaBoptions.MaxIter = 600;
BaBoptions.bpoptions = bpoptions;
parfor kFs=1:MaxInstance
% for kFs=1:MaxInstance
acc = zeros(1, NofAlgos);
obj = zeros(1, NofAlgos);
tm = zeros(1, NofAlgos);
% nOut = 5 ;%-5 ; % randomly remove 2 nodes
parKnl = st('alg', 'pas2'); % type of affinity: only edge distance
%% algorithm parameter
[pars, algs] = gmPar(2);
%% src
wsSrc = motorAsgSrc(kFs, nOut);
asgT = wsSrc.asgT;
parG = st('link', 'del'); % Delaunay triangulation for computing the graphs
parF = st('smp', 'n', 'nBinT', 4, 'nBinR', 3); % not used, ignore it
wsFeat = motorAsgFeat(wsSrc, parG, parF, 'svL', 1);
[gphs, XPs, Fs] = stFld(wsFeat, 'gphs', 'XPs', 'Fs');
[KP, KQ] = conKnlGphPQD(gphs, parKnl);
K = conKnlGphKD(KP, KQ, gphs);
Ct = ones(size(KP));
%BP
tlsm = tic;
asgLsm = gmLSM(K, Ct, asgT, BaBoptions);
tm(10) = toc(tlsm);
acc(10) = asgLsm.acc;
obj(10) = asgLsm.obj;
%BP
tbp = tic;
asgBP = HungarianBP(K, Ct, asgT,BaBoptions);
tm(1) = toc(tbp);
acc(1) = asgBP.acc;
obj(1) = asgBP.obj;
%% GA
tGa = tic;
asgGa = gm(K, Ct, asgT, pars{1}{:});
tm(2) = toc(tGa);
acc(2) = asgGa.acc;
obj(2) = asgGa.obj;
%% PM
tPm = tic;
asgPm = pm(K, KQ, gphs, asgT);
tm( 3) = toc(tPm);
acc(3) = asgPm.acc;
obj(3) = asgPm.obj;
%% SM
tSm = tic;
asgSm = gm(K, Ct, asgT, pars{3}{:});
tm( 4) = toc(tSm);
acc(4) = asgSm.acc;
obj(4) = asgSm.obj;
%% SMAC
tSmac = tic;
asgSmac = gm(K, Ct, asgT, pars{4}{:});
tm(5) = toc(tSmac);
acc(5) = asgSmac.acc;
obj(5) = asgSmac.obj;
%% IPFP-U
tIpfu = tic;
asgIpfpU = gm(K, Ct, asgT, pars{5}{:});
tm(6) = toc(tIpfu);
acc(6) = asgIpfpU.acc;
obj(6) = asgIpfpU.obj;
%% IPFP-S
tIpfp = tic;
asgIpfpS = gm(K, Ct, asgT, pars{6}{:});
tm( 7) = toc(tIpfp);
acc(7) = asgIpfpS.acc;
obj(7) = asgIpfpS.obj;
%% RRWM
tRrwm = tic;
asgRrwm = gm(K, Ct, asgT, pars{7}{:});
tm( 8) = toc(tRrwm);
acc(8) = asgRrwm.acc;
obj(8) = asgRrwm.obj;
% FGM-D
tFgmD = tic;
asgFgmD = fgmD(KP, KQ, Ct, gphs, asgT, pars{9}{:});
tm( 9) = toc(tFgmD);
acc(9) = asgFgmD.acc;
obj(9) = asgFgmD.obj;
% print information
times{kFs} = tm;
accs{kFs} = acc;
objs{kFs} = obj;
end
times = cell2mat(times);
objs = cell2mat(objs);
accs = cell2mat(accs);
maxobjs = max(objs,[], 2);
normalised_objs = zeros(MaxInstance,NofAlgos);
for i=1:NofAlgos
normalised_objs(:,i) = objs(1:1:MaxInstance, i)./maxobjs(1:1:MaxInstance);
end
for i=1:NofAlgos
AvgAcc(nOut+1, i) = mean(accs(:,i));
StdAcc(nOut+1, i) = std(accs(:,i));
AvgObj(nOut+1, i) = mean(normalised_objs(:, i));
StdObj(nOut+1, i) = std(normalised_objs(:,i));
AvgTime(nOut+1, i) = mean(times(:,i));
StdTime(nOut+1, i) = std(times(:,i));
end
save('MotorResult.mat');
end