# 用帝国主义竞争算法（ICA）求解旅行商问题（TSP）（Matlab代码实现）

## 💂♨️👨‍🎓Matlab代码👨‍🎓♨️💂

clc;
clear;
close all;
%% Problem Definition
model=CreateModel();
CostFunction=@(s) MyCost(s,model);        % Cost Function
nVar=model.n;             % Number of Decision Variables
VarSize=[1 nVar];   % Decision Variables Matrix Size
VarMin=0;         % Lower Bound of Variables
VarMax=1;         % Upper Bound of Variables
%% ICA Parameters
MaxIt=500;          % Maximum Number of Iterations
nPop=80;            % Population Size
nEmp=10;            % Number of Empires/Imperialists
alpha=1;            % Selection Pressure
beta=2;             % Assimilation Coefficient
pRevolution=0.2;    % Revolution Probability
mu=0.05;            % Revolution Rate
zeta=0.1;           % Colonies Mean Cost Coefficient
ShareSettings;
%% Initialization
% Initialize Empires
emp=CreateInitialEmpires();
% Array to Hold Best Cost Values
BestCost=zeros(MaxIt,1);
%% ICA Main Loop
for it=1:MaxIt
% Assimilation
emp=AssimilateColonies(emp);
% Revolution
emp=DoRevolution(emp);
% Intra-Empire Competition
emp=IntraEmpireCompetition(emp);
% Update Total Cost of Empires
emp=UpdateTotalCost(emp);
% Inter-Empire Competition
emp=InterEmpireCompetition(emp);
% Update Best Solution Ever Found
imp=[emp.Imp];
[~, BestImpIndex]=min([imp.Cost]);
BestSol=imp(BestImpIndex);
% Update Best Cost
BestCost(it)=BestSol.Cost;
% Show Iteration Information
disp(['Iteration ' num2str(it) ': Best Cost = ' num2str(BestCost(it))]);
% Plot Best Solution
figure(1);
PlotSolution(BestSol.Sol.tour,model);
end
%% Results
figure;
plot(BestCost,'LineWidth',2);
xlabel('Iteration');
ylabel('Best Cost');

## 📜📢🌈参考文献🌈📢📜

[1]秘向伟. 帝国主义竞争算法的改进与应用[D].燕山大学,2014.

|
3天前
|

53 29
|
4天前
|

36 20
|
4天前
|

36 19
|
5天前
|

18 2
|
7天前
|

19 3
|
7天前
|

26 1
|
22天前
|

37 1
|
12天前
|

37 0
|
1月前
|

【2023高教社杯】D题 圈养湖羊的空间利用率 问题分析、数学模型及MATLAB代码

102 6
|
1月前
|

【2022年华为杯数学建模】B题 方形件组批优化问题 方案及MATLAB代码实现

68 3

DDNS