[Data clustering] Matlab source code based on ant colony algorithm clustering

1. Introduction

1 Proposal of
ant colony algorithm Ant colony optimization (ACO), also known as ant algorithm, is a probability algorithm used to find optimized paths. It was proposed by Marco Dorigo in his doctoral dissertation in 1992, and was inspired by the behavior of ants finding paths in the process of searching for food. Genetic algorithms are used in pattern recognition, neural networks, machine learning, industrial optimization control, adaptive control, biological sciences, and social sciences.
2 Basic principles of the algorithm
Insert picture description here
Insert picture description here
Insert picture description here

Second, the source code

clc;
clf;
clear;
 % X = 测试样本矩阵;
%  X = load('data.txt');
X=[
2232.43	3077.87	1298.87;
1580.1	1752.07	2463.04;
1962.4	1594.97	1835.95;
1495.18	1957.44	3498.02;
1125.17	1594.39	2937.73;
24.22	3447.31	2145.01;
1269.07	1910.72	2701.97;
1802.07	1725.81	1966.35;
1817.36	1927.4	2328.79;
1860.45	1782.88	1875.13;
1237.91	2055.13	3405.09;
688.94	2104.72	3198.51;
1675.65	1747.23	1580.39;
1806.02	1810.19	2191.12;
74.56	3288.02	2433.87;
307.35	3363.84	2021.61;
1988.27	1657.51	2069.2;
2173.92	2608.55	1803.57;
372.16	3077.44	2163.46;
576.6	2140.98	3320;
1724.13	1704.49	1798.75;
2501.21	2652.65	984.56;
1656.94	1913.34	2459.07;
362.51	3150.03	2472;
565.74	2284.97	3024.58;
1978.06	1536.13	2375.64;
1661.06	1552.4	2005.05;
790.29	2419.98	3051.16;
1557.27	1746.27	1879.13;
2793.36	3009.26	1073.55;
1766.08	1803.14	1895.18;
1207.88	1600.62	3123.07;
245.75	3373.67	2248.45;
2785.36	3052.81	1035.65;
315.42	3088.29	2187.12;
1243.28	2451.72	3111.99;
829.84	1555.91	3139.21;
1347.07	2364.31	3096.88;
1926.98	1507.34	1626.47;
1808.57	1608.78	1565.95;
1124.1	1840.98	2819.41;
2661	3302.39	1710.32;
1805.55	1899.09	2400.6;
1130.18	1902.42	2753.7;
1355.19	1566.16	2927.81;
1651.14	1774.03	1725.56;
2110.63	3308.04	702.06;
2788.11	3395.23	1684.45;
1807.61	1680.56	2356.65;
1363.58	1729.44	2749.55;
1992.42	1526.9	1581.42;     
]
[N,n]=size(X);      % N =测试样本数;n =测试样本的属性数;
K = 4;              % K = 组数; 
R = 100;            % R = 蚂蚁数;           
% 初始化
c = 10^-2;
tau = ones(N,K) * c;    %信息素矩阵,初始值为0.01的N*K矩阵(样本数*聚类数)
rho = 0.1;              % 蒸发率
best_solution_function_value = inf; % 最佳路径度量值(初值为无穷大,该值越小聚类效果越好)
tic
t = 1; 
%=======程序终止条件(下列两个终止条件任选其一)======
% while ((t<=t_max))                             %达到最大迭代次数而终止
% while ((best_solution_function_value>=19727))  %达到一定的聚类效果而终止
while ((best_solution_function_value>=19727))    
%=========================

Three, running results

Insert picture description here
Insert picture description here

Four, remarks

Complete code or write on behalf of adding QQ1575304183

Past review>>>>>>

[Data analysis] Time-varying parameter stochastic volatility vector autoregressive model (TVP-VAR)

[Signal processing] Matlab source code based on ICA algorithm signal separation

[Data analysis] fuzzy binary decision tree matlab source code

[Data clustering] matlab source code based on genetic algorithm clustering design

Guess you like

Origin blog.csdn.net/qq_34763204/article/details/113617792