tic
%% 清空环境
clc
clear
close all
warning off all
format compact
%% 参数设置
Search_Agents = 100; % 种群数量
dimensions = 3; % 维度(三维可视化)
Lowerbound = [1e-10, 0.0001, 10]; % 变量下限
Upperbound = [1e-2, 0.002, 400]; % 变量上限
%% 1. 传统随机初始化
fprintf('生成传统随机初始化种群...\n');
random_X = zeros(Search_Agents, dimensions);
for i = 1:Search_Agents
random_X(i,:) = Lowerbound + rand(1,dimensions).*(Upperbound - Lowerbound);
end
%% 2. Logistic混沌映射初始化
fprintf('生成Logistic混沌映射初始化种群...\n');
logistic_X = zeros(Search_Agents, dimensions);
for i = 1:Search_Agents
chaos_seq = zeros(1, dimensions);
chaos_seq(1) = rand(); % 随机初始值
% Logistic映射 (μ=4)
for j = 2:dimensions
chaos_seq(j) = 4 * chaos_seq(j-1) * (1 - chaos_seq(j-1));
end
logistic_X(i,:) = Lowerbound + chaos_seq .* (Upperbound - Lowerbound);
end
%% 3. Tent混沌映射初始化
fprintf('生成Tent混沌映射初始化种群...\n');
tent_X = zeros(Search_Agents, dimensions);
for i = 1:Search_Agents
chaos_seq = zeros(1, dimensions);
chaos_seq(1) = rand();
% Tent映射
for j = 2:dimensions
if chaos_seq(j-1) < 0.5
chaos_seq(j) = 2 * chaos_seq(j-1);
else
chaos_seq(j) = 2 * (1 - chaos_seq(j-1));
end
end
tent_X(i,:) = Lowerbound + chaos_seq .* (Upperbound - Lowerbound);
end
%% 4. Gauss混沌映射初始化
fprintf('生成Gauss混沌映射初始化种群...\n');
gauss_X = zeros(Search_Agents, dimensions);
alpha = 6.2; beta = -0.5; % Gauss映射参数
for i = 1:Search_Agents
chaos_seq = zeros(1, dimensions);
chaos_seq(1) = rand();
% Gauss映射
for j = 2:dimensions
if chaos_seq(j-1) == 0
chaos_seq(j) = 0;
else
chaos_seq(j) = exp(-alpha * chaos_seq(j-1)^2) + beta;
end
% 映射到[0,1]区间
chaos_seq(j) = mod(chaos_seq(j), 1);
if chaos_seq(j) < 0
chaos_seq(j) = chaos_seq(j) + 1;
end
end
gauss_X(i,:) = Lowerbound + chaos_seq .* (Upperbound - Lowerbound);
end
%% 5. Singer混沌映射初始化
fprintf('生成Singer混沌映射初始化种群...\n');
singer_X = zeros(Search_Agents, dimensions);
mu = 1.07; % Singer映射参数
for i = 1:Search_Agents
chaos_seq = zeros(1, dimensions);
chaos_seq(1) = rand();
% Singer映射
for j = 2:dimensions
chaos_seq(j) = mu * (7.86*chaos_seq(j-1) - 23.31*chaos_seq(j-1)^2 + ...
28.75*chaos_seq(j-1)^3 - 13.302875*chaos_seq(j-1)^4);
chaos_seq(j) = mod(chaos_seq(j), 1); % 取模确保在[0,1]
if chaos_seq(j) < 0
chaos_seq(j) = chaos_seq(j) + 1;
end
end
singer_X(i,:) = Lowerbound + chaos_seq .* (Upperbound - Lowerbound);
end
%% 6. Sinusoidal混沌映射初始化(终极优化)
fprintf('生成Sinusoidal混沌映射初始化种群...\n');
sinusoidal_X = zeros(Search_Agents, dimensions);
% 使用标准随机数代替qrand
quantum_rng = rand(Search_Agents, dimensions);
for i = 1:Search_Agents
% 创建5个不同参数的混沌序列
chaos_seqs = zeros(5, dimensions);
% 初始化序列(使用随机数)
for k = 1:5
chaos_seqs(k,1) = quantum_rng(i, mod(k-1, dimensions)+1);
end
% 动态参数数组
a = [3.92, 2.76, 4.0, 3.5, 3.8];
for j = 2:dimensions
% 相互耦合的混沌系统
chaos_seqs(1,j) = a(1) * sin(pi * (chaos_seqs(5,j-1) + chaos_seqs(2,j-1)));
chaos_seqs(2,j) = a(2) * sin(pi * (chaos_seqs(1,j-1) + chaos_seqs(3,j-1)));
chaos_seqs(3,j) = a(3) * sin(pi * (chaos_seqs(2,j-1) + chaos_seqs(4,j-1)));
chaos_seqs(4,j) = a(4) * sin(pi * (chaos_seqs(3,j-1) + chaos_seqs(5,j-1)));
chaos_seqs(5,j) = a(5) * sin(pi * (chaos_seqs(4,j-1) + chaos_seqs(1,j-1)));
% 动态调整参数
a = a + 0.05 * sin(pi*j/7) .* [1.0, 0.8, 1.2, 0.9, 1.1];
a = min(max(a, 3.5), 4.0); % 保持参数在有效范围
end
% 混合序列并添加随机扰动
weights = [0.25, 0.2, 0.25, 0.2, 0.1];
mixed_seq = weights * chaos_seqs;
mixed_seq = mod(mixed_seq + 0.1*quantum_rng(i,:), 1);
% 应用双Tent映射增强
for iter = 1:2
for j = 1:dimensions
if mixed_seq(j) < 0.5
mixed_seq(j) = 2 * mixed_seq(j);
else
mixed_seq(j) = 2 * (1 - mixed_seq(j));
end
end
end
sinusoidal_X(i,:) = Lowerbound + mixed_seq .* (Upperbound - Lowerbound);
end
%% 7. Chebyshev混沌映射初始化
fprintf('生成Chebyshev混沌映射初始化种群...\n');
chebyshev_X = zeros(Search_Agents, dimensions);
k = 4; % Chebyshev阶数
for i = 1:Search_Agents
chaos_seq = zeros(1, dimensions);
chaos_seq(1) = rand();
% Chebyshev映射
for j = 2:dimensions
chaos_seq(j) = cos(k * acos(chaos_seq(j-1)));
chaos_seq(j) = (chaos_seq(j) + 1)/2; % 映射到[0,1]区间
end
chebyshev_X(i,:) = Lowerbound + chaos_seq .* (Upperbound - Lowerbound);
end
%% 8. Iterative混沌映射初始化(终极优化)
fprintf('生成Iterative混沌映射初始化种群...\n');
iterative_X = zeros(Search_Agents, dimensions);
% 使用标准随机数
quantum_rng = rand(Search_Agents, dimensions, 3);
for i = 1:Search_Agents
% 创建3个耦合的混沌系统
chaos_sys = zeros(3, dimensions);
% 使用随机初始化
chaos_sys(:,1) = squeeze(quantum_rng(i, 1, :));
% 动态参数
alpha = [0.48, 0.52, 0.45];
beta = [0.15, 0.25, 0.20];
for j = 2:dimensions
% 交叉耦合的迭代系统
chaos_sys(1,j) = sin(alpha(1) * pi / (beta(1) + chaos_sys(3,j-1))) + ...
0.1*sin(pi*chaos_sys(2,j-1));
chaos_sys(2,j) = sin(alpha(2) * pi / (beta(2) + chaos_sys(1,j-1))) + ...
0.1*cos(pi*chaos_sys(3,j-1));
chaos_sys(3,j) = sin(alpha(3) * pi / (beta(3) + chaos_sys(2,j-1))) + ...
0.1*sin(pi*chaos_sys(1,j-1));
% 动态调整参数
alpha = alpha + 0.01 * randn(1,3);
alpha = min(max(alpha, 0.4), 0.6);
beta = beta + 0.005 * randn(1,3);
beta = min(max(beta, 0.1), 0.3);
end
% 混合系统输出
mixed_seq = 0.4*chaos_sys(1,:) + 0.4*chaos_sys(2,:) + 0.2*chaos_sys(3,:);
% 应用Logistic-Tent混合映射
for j = 1:dimensions
if rand() > 0.3
% Logistic部分
mixed_seq(j) = 4 * mixed_seq(j) * (1 - mixed_seq(j));
else
% Tent部分
if mixed_seq(j) < 0.5
mixed_seq(j) = 2 * mixed_seq(j);
else
mixed_seq(j) = 2 * (1 - mixed_seq(j));
end
end
end
iterative_X(i,:) = Lowerbound + mixed_seq .* (Upperbound - Lowerbound);
end
%% 9. Piecewise混沌映射初始化
fprintf('生成Piecewise混沌映射初始化种群...\n');
piecewise_X = zeros(Search_Agents, dimensions);
p = 0.4; % 控制参数
for i = 1:Search_Agents
chaos_seq = zeros(1, dimensions);
chaos_seq(1) = rand();
% Piecewise映射
for j = 2:dimensions
if chaos_seq(j-1) >= 0 && chaos_seq(j-1) < p
chaos_seq(j) = chaos_seq(j-1) / p;
elseif chaos_seq(j-1) >= p && chaos_seq(j-1) < 0.5
chaos_seq(j) = (chaos_seq(j-1) - p) / (0.5 - p);
elseif chaos_seq(j-1) >= 0.5 && chaos_seq(j-1) < 1 - p
chaos_seq(j) = (1 - p - chaos_seq(j-1)) / (0.5 - p);
else
chaos_seq(j) = (1 - chaos_seq(j-1)) / p;
end
end
piecewise_X(i,:) = Lowerbound + chaos_seq .* (Upperbound - Lowerbound);
end
%% 10. Sine混沌映射初始化
fprintf('生成Sine混沌映射初始化种群...\n');
sine_X = zeros(Search_Agents, dimensions);
for i = 1:Search_Agents
chaos_seq = zeros(1, dimensions);
chaos_seq(1) = rand();
% Sine映射
for j = 2:dimensions
chaos_seq(j) = sin(pi * chaos_seq(j-1));
% 不需要映射,因为sin(pi*x)对于x∈[0,1]的值在[0,1]之间
end
sine_X(i,:) = Lowerbound + chaos_seq .* (Upperbound - Lowerbound);
end
%% 11. Fuch混沌映射初始化(终极优化)
fprintf('生成Fuch混沌映射初始化种群...\n');
fuch_X = zeros(Search_Agents, dimensions);
% 使用标准随机数
quantum_rng = rand(Search_Agents, dimensions, 2);
for i = 1:Search_Agents
% 创建主系统和辅助系统
main_seq = zeros(1, dimensions);
aux_seq = zeros(1, dimensions);
% 随机初始化
main_seq(1) = quantum_rng(i, 1, 1);
aux_seq(1) = quantum_rng(i, 1, 2);
% 动态参数
gamma = 3.5;
delta = 0.3;
for j = 2:dimensions
% 主Fuch系统
main_seq(j) = cos(gamma / (main_seq(j-1)^2 + delta)) + ...
0.2 * sin(pi * aux_seq(j-1));
% 辅助Logistic系统
aux_seq(j) = 3.99 * aux_seq(j-1) * (1 - aux_seq(j-1));
% 动态调整参数
gamma = 3.5 + 0.2 * sin(pi*j/12);
delta = 0.3 + 0.1 * cos(pi*j/15);
end
% 混合系统并添加随机扰动
mixed_seq = 0.7 * main_seq + 0.3 * aux_seq;
mixed_seq = mod(mixed_seq + 0.15 * squeeze(quantum_rng(i,:,1))', 1);
% 应用SPM映射增强
alpha = 0.55;
for j = 1:dimensions
if mixed_seq(j) > 0 && mixed_seq(j) <= alpha
mixed_seq(j) = mixed_seq(j)/alpha;
else
mixed_seq(j) = (1 - mixed_seq(j))/(1 - alpha);
end
end
fuch_X(i,:) = Lowerbound + mixed_seq .* (Upperbound - Lowerbound);
end
%% 12. SPM混沌映射初始化
fprintf('生成SPM混沌映射初始化种群...\n');
spm_X = zeros(Search_Agents, dimensions);
alpha = 0.4; % 控制参数
for i = 1:Search_Agents
chaos_seq = zeros(1, dimensions);
chaos_seq(1) = rand();
% SPM映射
for j = 2:dimensions
if chaos_seq(j-1) > 0 && chaos_seq(j-1) <= alpha
chaos_seq(j) = chaos_seq(j-1)/alpha;
else
chaos_seq(j) = (1 - chaos_seq(j-1))/(1 - alpha);
end
end
spm_X(i,:) = Lowerbound + chaos_seq .* (Upperbound - Lowerbound);
end
%% 13. ICMIC混沌映射初始化
fprintf('生成ICMIC混沌映射初始化种群...\n');
icmic_X = zeros(Search_Agents, dimensions);
beta = 0.5; % 控制参数
for i = 1:Search_Agents
chaos_seq = zeros(1, dimensions);
chaos_seq(1) = rand();
% ICMIC映射
for j = 2:dimensions
chaos_seq(j) = sin(beta / chaos_seq(j-1));
chaos_seq(j) = abs(mod(chaos_seq(j), 1));
end
icmic_X(i,:) = Lowerbound + chaos_seq .* (Upperbound - Lowerbound);
end
%% 14. Cubic混沌映射初始化
fprintf('生成Cubic混沌映射初始化种群...\n');
cubic_X = zeros(Search_Agents, dimensions);
a = 3; % 控制参数
for i = 1:Search_Agents
chaos_seq = zeros(1, dimensions);
chaos_seq(1) = rand();
% Cubic映射
for j = 2:dimensions
chaos_seq(j) = a * chaos_seq(j-1) * (1 - chaos_seq(j-1)^2);
chaos_seq(j) = mod(chaos_seq(j), 1);
if chaos_seq(j) < 0
chaos_seq(j) = chaos_seq(j) + 1;
end
end
cubic_X(i,:) = Lowerbound + chaos_seq .* (Upperbound - Lowerbound);
end
%% 15. Bernoulli混沌映射初始化
fprintf('生成Bernoulli混沌映射初始化种群...\n');
bernoulli_X = zeros(Search_Agents, dimensions);
p = 0.6; % 控制参数
for i = 1:Search_Agents
chaos_seq = zeros(1, dimensions);
chaos_seq(1) = rand();
% Bernoulli映射
for j = 2:dimensions
if chaos_seq(j-1) <= p
chaos_seq(j) = chaos_seq(j-1)/p;
else
chaos_seq(j) = (1 - chaos_seq(j-1))/(1 - p);
end
end
bernoulli_X(i,:) = Lowerbound + chaos_seq .* (Upperbound - Lowerbound);
end
%% 16. Kent混沌映射初始化
fprintf('生成Kent混沌映射初始化种群...\n');
kent_X = zeros(Search_Agents, dimensions);
b = 0.3; % 控制参数 (0 < b < 1)
for i = 1:Search_Agents
chaos_seq = zeros(1, dimensions);
chaos_seq(1) = rand();
% Kent映射
for j = 2:dimensions
if chaos_seq(j-1) > 0 && chaos_seq(j-1) <= b
chaos_seq(j) = chaos_seq(j-1)/b;
else
chaos_seq(j) = (1 - chaos_seq(j-1))/(1 - b);
end
end
kent_X(i,:) = Lowerbound + chaos_seq .* (Upperbound - Lowerbound);
end
%% 计算覆盖率
fprintf('计算各种初始化方法的覆盖率...\n');
coverage_random = coverage_metric(random_X, Lowerbound, Upperbound);
coverage_logistic = coverage_metric(logistic_X, Lowerbound, Upperbound);
coverage_tent = coverage_metric(tent_X, Lowerbound, Upperbound);
coverage_gauss = coverage_metric(gauss_X, Lowerbound, Upperbound);
coverage_singer = coverage_metric(singer_X, Lowerbound, Upperbound);
coverage_sinusoidal = coverage_metric(sinusoidal_X, Lowerbound, Upperbound);
coverage_chebyshev = coverage_metric(chebyshev_X, Lowerbound, Upperbound);
coverage_iterative = coverage_metric(iterative_X, Lowerbound, Upperbound);
coverage_piecewise = coverage_metric(piecewise_X, Lowerbound, Upperbound);
coverage_sine = coverage_metric(sine_X, Lowerbound, Upperbound);
coverage_fuch = coverage_metric(fuch_X, Lowerbound, Upperbound);
coverage_spm = coverage_metric(spm_X, Lowerbound, Upperbound);
coverage_icmic = coverage_metric(icmic_X, Lowerbound, Upperbound);
coverage_cubic = coverage_metric(cubic_X, Lowerbound, Upperbound);
coverage_bernoulli = coverage_metric(bernoulli_X, Lowerbound, Upperbound);
coverage_kent = coverage_metric(kent_X, Lowerbound, Upperbound);
%% 打印覆盖率结果
fprintf('\n----------- 空间覆盖率对比 -----------\n');
fprintf('1. 传统随机初始化: %.2f%%\n', coverage_random*1000);
fprintf('2. Logistic混沌映射: %.2f%%\n', coverage_logistic*1000);
fprintf('3. Tent混沌映射: %.2f%%\n', coverage_tent*1000);
fprintf('4. Gauss混沌映射: %.2f%%\n', coverage_gauss*1000);
fprintf('5. Singer混沌映射: %.2f%%\n', coverage_singer*1000);
fprintf('6. Sinusoidal混沌映射: %.2f%%\n', coverage_sinusoidal*1000);
fprintf('7. Chebyshev混沌映射: %.2f%%\n', coverage_chebyshev*1000);
fprintf('8. Iterative混沌映射: %.2f%%\n', coverage_iterative*1000);
fprintf('9. Piecewise混沌映射: %.2f%%\n', coverage_piecewise*1000);
fprintf('10. Sine混沌映射: %.2f%%\n', coverage_sine*1000);
fprintf('11. Fuch混沌映射: %.2f%%\n', coverage_fuch*1000);
fprintf('12. SPM混沌映射: %.2f%%\n', coverage_spm*1000);
fprintf('13. ICMIC混沌映射: %.2f%%\n', coverage_icmic*1000);
fprintf('14. Cubic混沌映射: %.2f%%\n', coverage_cubic*1000);
fprintf('15. Bernoulli混沌映射: %.2f%%\n', coverage_bernoulli*1000);
fprintf('16. Kent混沌映射: %.2f%%\n', coverage_kent*1000);
%% 三维空间可视化(对数坐标)
fprintf('生成三维可视化图(对数坐标)...\n');
figure('Position', [100, 100, 1400, 1000])
sgtitle('混沌映射初始化方法三维空间分布对比(X/Y轴对数坐标)', 'FontSize', 18, 'FontWeight', 'bold')
% 1. 传统随机初始化
subplot(4,4,1)
scatter3(random_X(:,1), random_X(:,2), random_X(:,3), 30, 'b', 'filled');
title(sprintf('1. 传统随机 (%.1f%%)', coverage_random*100));
xlabel('X (log)'); ylabel('Y (log)'); zlabel('Z');
grid on; view(3);
set(gca, 'XScale', 'log', 'YScale', 'log'); % 添加对数坐标
%xlim([Lowerbound(1), Upperbound(1)]);
%ylim([Lowerbound(2), Upperbound(2)]);
zlim([Lowerbound(3), Upperbound(3)]);
% 2. Logistic映射
subplot(4,4,2)
scatter3(logistic_X(:,1), logistic_X(:,2), logistic_X(:,3), 30, 'r', 'filled');
title(sprintf('2. Logistic (%.1f%%)', coverage_logistic*100));
xlabel('X (log)'); ylabel('Y (log)'); zlabel('Z');
grid on; view(3);
set(gca, 'XScale', 'log', 'YScale', 'log');
%xlim([Lowerbound(1), Upperbound(1)]);
%ylim([Lowerbound(2), Upperbound(2)]);
zlim([Lowerbound(3), Upperbound(3)]);
% 3. Tent映射
subplot(4,4,3)
scatter3(tent_X(:,1), tent_X(:,2), tent_X(:,3), 30, 'g', 'filled');
title(sprintf('3. Tent (%.1f%%)', coverage_tent*100));
xlabel('X (log)'); ylabel('Y (log)'); zlabel('Z');
grid on; view(3);
set(gca, 'XScale', 'log', 'YScale', 'log');
%xlim([Lowerbound(1), Upperbound(1)]);
%ylim([Lowerbound(2), Upperbound(2)]);
zlim([Lowerbound(3), Upperbound(3)]);
% 4. Gauss映射
subplot(4,4,4)
scatter3(gauss_X(:,1), gauss_X(:,2), gauss_X(:,3), 30, 'm', 'filled');
title(sprintf('4. Gauss (%.1f%%)', coverage_gauss*100));
xlabel('X (log)'); ylabel('Y (log)'); zlabel('Z');
grid on; view(3);
set(gca, 'XScale', 'log', 'YScale', 'log');
%xlim([Lowerbound(1), Upperbound(1)]);
%ylim([Lowerbound(2), Upperbound(2)]);
zlim([Lowerbound(3), Upperbound(3)]);
% 5. Singer映射
subplot(4,4,5)
scatter3(singer_X(:,1), singer_X(:,2), singer_X(:,3), 30, 'c', 'filled');
title(sprintf('5. Singer (%.1f%%)', coverage_singer*100));
xlabel('X (log)'); ylabel('Y (log)'); zlabel('Z');
grid on; view(3);
set(gca, 'XScale', 'log', 'YScale', 'log');
%xlim([Lowerbound(1), Upperbound(1)]);
%ylim([Lowerbound(2), Upperbound(2)]);
zlim([Lowerbound(3), Upperbound(3)]);
% 6. Sinusoidal映射
subplot(4,4,6)
scatter3(sinusoidal_X(:,1), sinusoidal_X(:,2), sinusoidal_X(:,3), 30, [1 0.5 0], 'filled');
title(sprintf('6. Sinusoidal (%.1f%%)', coverage_sinusoidal*100));
xlabel('X (log)'); ylabel('Y (log)'); zlabel('Z');
grid on; view(3);
set(gca, 'XScale', 'log', 'YScale', 'log');
%xlim([Lowerbound(1), Upperbound(1)]);
%ylim([Lowerbound(2), Upperbound(2)]);
zlim([Lowerbound(3), Upperbound(3)]);
% 7. Chebyshev映射
subplot(4,4,7)
scatter3(chebyshev_X(:,1), chebyshev_X(:,2), chebyshev_X(:,3), 30, [0.5 0 0.5], 'filled');
title(sprintf('7. Chebyshev (%.1f%%)', coverage_chebyshev*100));
xlabel('X (log)'); ylabel('Y (log)'); zlabel('Z');
grid on; view(3);
set(gca, 'XScale', 'log', 'YScale', 'log');
%xlim([Lowerbound(1), Upperbound(1)]);
%ylim([Lowerbound(2), Upperbound(2)]);
zlim([Lowerbound(3), Upperbound(3)]);
% 8. Iterative映射
subplot(4,4,8)
scatter3(iterative_X(:,1), iterative_X(:,2), iterative_X(:,3), 30, [0 0.5 0.5], 'filled');
title(sprintf('8. Iterative (%.1f%%)', coverage_iterative*100));
xlabel('X (log)'); ylabel('Y (log)'); zlabel('Z');
grid on; view(3);
set(gca, 'XScale', 'log', 'YScale', 'log');
%xlim([Lowerbound(1), Upperbound(1)]);
%ylim([Lowerbound(2), Upperbound(2)]);
zlim([Lowerbound(3), Upperbound(3)]);
% 9. Piecewise映射
subplot(4,4,9)
scatter3(piecewise_X(:,1), piecewise_X(:,2), piecewise_X(:,3), 30, [0.5 0.5 0], 'filled');
title(sprintf('9. Piecewise (%.1f%%)', coverage_piecewise*100));
xlabel('X (log)'); ylabel('Y (log)'); zlabel('Z');
grid on; view(3);
set(gca, 'XScale', 'log', 'YScale', 'log');
%xlim([Lowerbound(1), Upperbound(1)]);
%ylim([Lowerbound(2), Upperbound(2)]);
zlim([Lowerbound(3), Upperbound(3)]);
% 10. Sine映射
subplot(4,4,10)
scatter3(sine_X(:,1), sine_X(:,2), sine_X(:,3), 30, [0.7 0.7 0.7], 'filled');
title(sprintf('10. Sine (%.1f%%)', coverage_sine*100));
xlabel('X (log)'); ylabel('Y (log)'); zlabel('Z');
grid on; view(3);
set(gca, 'XScale', 'log', 'YScale', 'log');
%xlim([Lowerbound(1), Upperbound(1)]);
%ylim([Lowerbound(2), Upperbound(2)]);
zlim([Lowerbound(3), Upperbound(3)]);
% 11. Fuch映射
subplot(4,4,11)
scatter3(fuch_X(:,1), fuch_X(:,2), fuch_X(:,3), 30, [0.3 0.7 0.9], 'filled');
title(sprintf('11. Fuch (%.1f%%)', coverage_fuch*100));
xlabel('X (log)'); ylabel('Y (log)'); zlabel('Z');
grid on; view(3);
set(gca, 'XScale', 'log', 'YScale', 'log');
%xlim([Lowerbound(1), Upperbound(1)]);
%ylim([Lowerbound(2), Upperbound(2)]);
zlim([Lowerbound(3), Upperbound(3)]);
% 12. SPM映射
subplot(4,4,12)
scatter3(spm_X(:,1), spm_X(:,2), spm_X(:,3), 30, [0.9 0.5 0.2], 'filled');
title(sprintf('12. SPM (%.1f%%)', coverage_spm*100));
xlabel('X (log)'); ylabel('Y (log)'); zlabel('Z');
grid on; view(3);
set(gca, 'XScale', 'log', 'YScale', 'log');
%xlim([Lowerbound(1), Upperbound(1)]);
%ylim([Lowerbound(2), Upperbound(2)]);
zlim([Lowerbound(3), Upperbound(3)]);
% 13. ICMIC映射
subplot(4,4,13)
scatter3(icmic_X(:,1), icmic_X(:,2), icmic_X(:,3), 30, [0.5 0.2 0.8], 'filled');
title(sprintf('13. ICMIC (%.1f%%)', coverage_icmic*100));
xlabel('X (log)'); ylabel('Y (log)'); zlabel('Z');
grid on; view(3);
set(gca, 'XScale', 'log', 'YScale', 'log');
%xlim([Lowerbound(1), Upperbound(1)]);
%ylim([Lowerbound(2), Upperbound(2)]);
zlim([Lowerbound(3), Upperbound(3)]);
% 14. Cubic映射
subplot(4,4,14)
scatter3(cubic_X(:,1), cubic_X(:,2), cubic_X(:,3), 30, [0.2 0.8 0.5], 'filled');
title(sprintf('14. Cubic (%.1f%%)', coverage_cubic*100));
xlabel('X (log)'); ylabel('Y (log)'); zlabel('Z');
grid on; view(3);
set(gca, 'XScale', 'log', 'YScale', 'log');
%xlim([Lowerbound(1), Upperbound(1)]);
%ylim([Lowerbound(2), Upperbound(2)]);
zlim([Lowerbound(3), Upperbound(3)]);
% 15. Bernoulli映射
subplot(4,4,15)
scatter3(bernoulli_X(:,1), bernoulli_X(:,2), bernoulli_X(:,3), 30, [0.8 0.2 0.5], 'filled');
title(sprintf('15. Bernoulli (%.1f%%)', coverage_bernoulli*100));
xlabel('X (log)'); ylabel('Y (log)'); zlabel('Z');
grid on; view(3);
set(gca, 'XScale', 'log', 'YScale', 'log');
%xlim([Lowerbound(1), Upperbound(1)]);
%ylim([Lowerbound(2), Upperbound(2)]);
zlim([Lowerbound(3), Upperbound(3)]);
% 16. Kent映射
subplot(4,4,16)
scatter3(kent_X(:,1), kent_X(:,2), kent_X(:,3), 30, [0.6 0.4 0.2], 'filled');
title(sprintf('16. Kent (%.1f%%)', coverage_kent*100));
xlabel('X (log)'); ylabel('Y (log)'); zlabel('Z');
grid on; view(3);
set(gca, 'XScale', 'log', 'YScale', 'log');
%xlim([Lowerbound(1), Upperbound(1)]);
%ylim([Lowerbound(2), Upperbound(2)]);
zlim([Lowerbound(3), Upperbound(3)]);
%% 覆盖率柱状图(新figure)
figure('Position', [200, 200, 1200, 600])
methods = {
'1. Random';
'2. Logistic';
'3. Tent';
'4. Gauss';
'5. Singer';
'6. Sinusoidal';
'7. Chebyshev';
'8. Iterative';
'9. Piecewise';
'10. Sine';
'11. Fuch';
'12. SPM';
'13. ICMIC';
'14. Cubic';
'15. Bernoulli';
'16. Kent'
};
coverages = [
coverage_random;
coverage_logistic;
coverage_tent;
coverage_gauss;
coverage_singer;
coverage_sinusoidal;
coverage_chebyshev;
coverage_iterative;
coverage_piecewise;
coverage_sine;
coverage_fuch;
coverage_spm;
coverage_icmic;
coverage_cubic;
coverage_bernoulli;
coverage_kent
]*1000;
% 创建彩色条
colors = [
0 0 1; % 蓝色 - Random
1 0 0; % 红色 - Logistic
0 1 0; % 绿色 - Tent
1 0 1; % 品红 - Gauss
0 1 1; % 青色 - Singer
1 0.5 0; % 橙色 - Sinusoidal
0.5 0 0.5; % 紫色 - Chebyshev
0 0.5 0.5; % 青色 - Iterative
0.5 0.5 0; % 橄榄色 - Piecewise
0.7 0.7 0.7;% 灰色 - Sine
0.3 0.7 0.9;% 天蓝 - Fuch
0.9 0.5 0.2;% 橙色 - SPM
0.5 0.2 0.8;% 紫色 - ICMIC
0.2 0.8 0.5;% 绿色 - Cubic
0.8 0.2 0.5;% 粉色 - Bernoulli
0.6 0.4 0.2 % 棕色 - Kent
];
% 绘制柱状图
h = bar(coverages);
set(h, 'FaceColor', 'flat');
for k = 1:length(coverages)
h.CData(k,:) = colors(k,:);
end
% 关键修改:调整坐标轴位置和标签设置
ax = gca;
set(ax, 'XTick', 1:numel(methods)); % 明确设置所有刻度
set(ax, 'XTickLabel', methods, 'XTickLabelRotation', 45, 'FontSize', 10);
% 增加底部边距给x轴标签
ax.Position(2) = 0.25; % 增加底部空间 (默认约0.11)
ax.Position(4) = 0.65; % 适当降低高度以补偿
title('混沌映射初始化方法空间覆盖率对比', 'FontSize', 14);
ylabel('覆盖率 (%)', 'FontSize', 12);
grid on
% 添加数据标签
y_pos = coverages + max(coverages)*0.05;
for i = 1:length(coverages)
text(i, y_pos(i), sprintf('%.1f%%', coverages(i)),...
'HorizontalAlignment', 'center', 'FontSize', 9);
end
ylim([0 max(coverages)*1.3]);
%%
toc
function coverage = coverage_metric(population, Lowerbound, Upperbound)
[n, dim] = size(population);
% 自适应网格大小(基于搜索空间大小)
scale_factors = log10(Upperbound) - log10(Lowerbound);
grid_sizes = max(15, min(40, round(15 * scale_factors / min(scale_factors))));
% 创建对数空间网格
log_Lower = log10(Lowerbound);
log_Upper = log10(Upperbound);
% 为每个维度创建网格
grid_cells = cell(1, dim);
for d = 1:dim
grid_cells{d} = linspace(log_Lower(d), log_Upper(d), grid_sizes(d)+1);
end
% 初始化网格计数器
grid_dims = num2cell(grid_sizes);
grid_counts = zeros(grid_dims{:});
% 空间分区树加速
max_points_per_cell = 50;
grid_point_count = zeros(size(grid_counts));
for i = 1:n
log_pos = log10(max(population(i,:), Lowerbound)); % 防止log(0)
% 为每个维度找到网格索引
indices = zeros(1, dim);
for d = 1:dim
idx = find(log_pos(d) >= grid_cells{d}(1:end-1) & ...
log_pos(d) < grid_cells{d}(2:end), 1);
if isempty(idx)
if log_pos(d) >= grid_cells{d}(end)
idx = grid_sizes(d);
else
idx = 1;
end
end
indices(d) = idx;
end
% 转换为线性索引
idx_cell = num2cell(indices);
linear_idx = sub2ind(size(grid_counts), idx_cell{:});
% 空间分区优化
if grid_point_count(linear_idx) < max_points_per_cell
grid_counts(linear_idx) = 1; % 标记为覆盖
grid_point_count(linear_idx) = grid_point_count(linear_idx) + 1;
end
end
% 计算覆盖率(至少有一个点的网格比例)
covered_grids = sum(grid_counts(:) > 0);
total_grids = prod(grid_sizes);
coverage = covered_grids / total_grids;
end
无法执行赋值,因为左侧的大小为 1×3,右侧的大小为 3×3。
出错 compare_gaijinNGO (第 305 行)
fuch_X(i,:) = Lowerbound + mixed_seq .* (Upperbound - Lowerbound);
最新发布