-
Notifications
You must be signed in to change notification settings - Fork 0
/
msaa_optimize.m
77 lines (69 loc) · 2.81 KB
/
msaa_optimize.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
function[check_fdm, check_fitness, N, E, EL, fitness, L_fitness] = msaa_optimize(FDM, N, E, EL, check_i, sharp_i, fitness, L_fitness, scale, alpha, i)
check_fitness = false;
check_fdm = check_i;
% Search in x-direction
[fem_check_x, fdm_check_x, sharp_x, fitness_x, L_x, N_x, E_x, EL_x] = evaluate_update(FDM, N, E, EL, 1, alpha, scale, i);
if fem_check_x
if ((fdm_check_x && check_i) || fdm_check_x) && (length(sharp_x) < length(sharp_i))
sharp_i = sharp_x;
fitness = fitness_x;
N = N_x;
E = E_x;
EL = EL_x;
check_fitness = true;
check_fdm = true;
elseif ((fitness > fitness_x) && (L_fitness >= L_x)) || ((fitness >= fitness_x) && (L_fitness > L_x)) || imsaa_prob(abs(fitness_x-fitness), alpha)
fitness = fitness_x;
L_fitness = L_x;
N = N_x;
E = E_x;
EL = EL_x;
check_i = true;
check_fitness = true;
end
end
% Search in y-direction
[fem_check_y, fdm_check_y, sharp_y, fitness_y, L_y, N_y, E_y, EL_y] = evaluate_update(FDM, N, E, EL, 2, alpha, scale, i);
if fem_check_y
if ((fdm_check_y && check_i) || fdm_check_y) && (length(sharp_y) < length(sharp_i))
sharp_i = sharp_y;
fitness = fitness_y;
N = N_y;
E = E_y;
EL = EL_y;
check_fitness = true;
check_fdm = true;
elseif ((fitness > fitness_y) && (L_fitness >= L_y)) || ((fitness >= fitness_y) && (L_fitness > L_y)) || imsaa_prob(abs(fitness-fitness_y), alpha)
fitness = fitness_y;
L_fitness = L_y;
N = N_y;
E = E_y;
EL = EL_y;
check_i = true;
check_fitness = true;
end
end
if N(i,3) < scale
N(i,3) = scale;
elseif N(i,3) > scale
% Search in z-direction
[fem_check_z, fdm_check_z, sharp_z, fitness_z, L_z, N_z, E_z, EL_z] = evaluate_update(FDM, N, E, EL, 3, alpha, scale, i);
if fem_check_z
if ((fdm_check_z && check_i) || fdm_check_z) && (length(sharp_z) < length(sharp_i))
fitness = fitness_z;
N = N_z;
E = E_z;
EL = EL_z;
check_fitness = true;
check_fdm = true;
elseif ((fitness > fitness_z) && (L_fitness >= L_z)) || ((fitness >= fitness_z) && (L_fitness > L_z)) || imsaa_prob(abs(fitness-fitness_z), alpha)
fitness = fitness_z;
L_fitness = L_z;
N = N_z;
E = E_z;
EL = EL_z;
check_fitness = true;
end
end
end
end