/
Experimento2_2outliersNaoCont_ClasVL1.m
141 lines (121 loc) · 2.68 KB
/
Experimento2_2outliersNaoCont_ClasVL1.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
VC=29.2
if 1
mem=[1 1 4
2 1 5
3 1 7
4 1 8
5 4 5
6 4 6
7 4 8
8 5 6
9 5 7
10 6 7
11 6 8
12 7 8
13 12 16
14 12 17
15 13 14
16 13 20
17 14 15
18 14 18
19 14 20
20 15 16
21 15 18
22 15 19
23 16 17
24 16 19];
end
for s=1:4
#rand("state",[3]);randn("state",[3]);
if s==1
ini_int_erro=3; fim_int_erro=6;
elseif s==2
ini_int_erro=6; fim_int_erro=12;
elseif s==3
ini_int_erro=12; fim_int_erro=25;
elseif s==4
ini_int_erro=25; fim_int_erro=100;end
m=20; n=10;
qtd_itr=2000;
cont_acerto=0;
A=[1 0 0 0 0 0 0 0 0 0;
-1 0 0 0 0 0 0 0 0 1;
0 0 0 0 0 1 0 0 0 -1;
0 0 0 0 0 1 -1 0 0 0;
0 0 0 0 0 0 1 0 0 0;
0 0 0 0 0 0 -1 1 0 0;
0 0 0 0 0 0 0 1 0 0;
0 0 0 0 0 0 0 1 -1 0;
-1 0 0 0 0 0 0 0 1 0;
0 0 0 0 0 0 0 0 1 -1;
0 0 0 0 0 -1 0 0 1 0;
0 0 0 0 1 0 0 0 0 -1;
-1 1 0 0 0 0 0 0 0 0;
0 -1 1 0 0 0 0 0 0 0;
0 0 -1 1 0 0 0 0 0 0;
0 0 0 -1 1 0 0 0 0 0;
0 0 0 0 1 -1 0 0 0 0;
-1 0 1 0 0 0 0 0 0 0;
0 0 0 1 0 0 0 0 0 -1;
0 1 0 0 0 0 0 0 0 -1];
I = eye(m);
A1 = [A -A -I I];
d=[49 41 38 34 22 13 23 48 15 24 62 49 35 43 20 28 19 39 27 21];
dp=1.*sqrt(d);
c1=zeros(1,2*n);
p=ones(1,m);
c = cat(2,c1,p,p);
ctype=[];
for i=1:m
ctype = [ctype, "S"];
end
vartype=[];
for i=1:(2*(n+m))
vartype = [vartype, "C"];
end
param.dual=1;
param.lpsolver=1;
for q=1:qtd_itr
#Entrada L (rede perfeita) e simulaçoes em L
L=[163854.9;6446.2;57037.0;126209.5;101128.6;296885.8;398014.4;60449.1;173710.4;167264.2;
110227.2;155928.2;52875.0;62904.2;3889.5;42705.7;98891.2;115779.2;113222.5;46428.8];
for z=1:m
do a=randn(1);
until (a<=3)
Laleat(z,1)=L(z)+dp(z)*a;
end
for k=1:100
Lgross=Laleat;outidt=[0;0];
f=randi([1 24]);
j=mem(f,2); t=mem(f,3);
choice=randi([-1 0]);
if choice==0
choice=1;end
Lgross(j)=L(j)+choice*dp(j)*(ini_int_erro+(fim_int_erro-ini_int_erro)*rand(1));
choice=randi([-1 0]);
if choice==0
choice=1;end
Lgross(t)=L(t)+choice*dp(t)*(ini_int_erro+(fim_int_erro-ini_int_erro)*rand(1));
[xopt, fopt, erro, extra] = glpk (c, A1, Lgross, lb=[], ub=[], ctype, vartype, s=1, param);
for i=1:m
v(i)=abs(xopt(2*n+i)-xopt(2*n+i+m));
end
for i=1:m
Y(i)=v(i);
if Y(i)>VC
if outidt(1,1)==0
outidt(1,1)=i;
outidt;
elseif outidt(2,1)==0;
outidt(2,1)=i;
else outidt(2,1)=500;
end end
end
if outidt==[j; t] | outidt==[t; j]
cont_acerto=cont_acerto+1; end
end
end
ini_int_erro
cont_acerto
TS=(cont_acerto/200000)*100
end