-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathexample_usage.m
29 lines (24 loc) · 1.23 KB
/
example_usage.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
% Example usage of the functions "nPSO_model" and "create_mixture_gaussian_gamma_pdf".
% The script generates and plots four examples:
% - nPSO model with 4 communities and default Gaussian mixture distribution
% - nPSO model with 4 communities and custom Gaussian mixture distribution
% - nPSO model with 8 communities and custom mixture distribution (Gaussian and Gamma mixture distribution)
% - PSO model
N = 100;
m = 4;
T = 0.1;
gamma = 3;
plot_flag = 1;
% nPSO model with 4 communities and default Gaussian mixture distribution
distr = 4;
[x_nPSO1, coords_nPSO1, comm_nPSO1, d_nPSO1] = nPSO_model(N, m, T, gamma, distr, plot_flag);
% nPSO model with 4 communities and custom Gaussian mixture distribution
C = 4; mu = (0:C-1).*(2*pi/C); sigma = (2*pi/C/6)^2; p = rand(1,C);
distr = gmdistribution(mu', sigma, p);
[x_nPSO2, coords_nPSO2, comm_nPSO2, d_nPSO2] = nPSO_model(N, m, T, gamma, distr, plot_flag);
% nPSO model with 8 communities and custom mixture distribution (Gaussian and Gamma mixture distribution)
distr = create_mixture_gaussian_gamma_pdf(8);
[x_nPSO3, coords_nPSO3, comm_nPSO3, d_nPSO3] = nPSO_model(N, m, T, gamma, distr, plot_flag);
% PSO model
distr = 0;
[x_PSO, coords_PSO, ~, d_PSO] = nPSO_model(N, m, T, gamma, distr, plot_flag);