💥💥💥💥💥💥💥💥💞💞💞💞💞💞💞💞💞Matlab武动乾坤博客之家💞💞💞💞💞💞💞💞💞💥💥💥💥💥💥💥💥
🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚤🚤🚤🚤🚤🚤🚤🚤🚤🚤🚤🚤🚤🚤🚤🚤🚤🚤🚤🚤🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀
🔊博主简介:985研究生,Matlab领域科研开发者;
🚅座右铭:行百里者,半于九十。
🏆代码获取方式:
优快云 Matlab武动乾坤—代码获取方式
更多Matlab优化求解仿真内容点击👇
①Matlab优化求解(进阶版)
⛳️关注优快云 Matlab武动乾坤,更多资源等你来!!
⛄一、Kmean算法简介
kmeans聚类可以说是聚类算法中最为常见的,它是基于划分方法聚类的,原理是先初始化k个簇类中心,基于计算样本与中心点的距离归纳各簇类下的所属样本,迭代实现样本与其归属的簇类中心的距离为最小的目标(如下目标函数)。
其优化算法步骤为:
1.随机选择 k 个样本作为初始簇类中心(k为超参,代表簇类的个数。可以凭先验知识、验证法确定取值);
2.针对数据集中每个样本 计算它到 k 个簇类中心的距离,并将其归属到距离最小的簇类中心所对应的类中;
3.针对每个簇类,重新计算它的簇类中心位置;
4.重复迭代上面 2 、3 两步操作,直到达到某个中止条件(如迭代次数,簇类中心位置不变等)。
⛄二、部分源代码
%*************** personal information *************************************************
%
%
close all
clear all
clc
%***************************** global variables ********************************************
REPerB=842;%resource elements per resourse block
Category=[1,2,3];% 1:urban, 2:suburban,3:rural
F_HATA=1500;%MHz
NoiceFigure=10; %dB
BI=15;
NoisePower= -174 +10log10(180*10^3)+NoiceFigure+BI;
SINRmin=-9.3;%d
Lbody=3;%dB body loss
Lbpl=18;%dB building penetration loss
Lj=2;%jumber loos
Ga=5;% gain
%***************************** end global variables ******************************************
%***************************** configuration of MeNB ******************************************
MeNB(1).x=500;% x coordinate
MeNB(1).y=500;% y coordinate
MeNB(1).ChannelBandwidth=20;%MHz
MeNB(1).carrier=1.8*10^9;%MHz
MeNB(1).takeBitPerMilisec=100000;%MHz
MeNB(1).powerTransmit=45; %dBm
MeNB(1).height=100; %metres
for i=1:20
MeNB(1).UEdata(i)=0;%MHz
end
MaxPathLoss=Calculate_MaxPathLoss(MeNB(1).powerTransmit,NoisePower,SINRmin);%Max Path Loss
%***************************** End configuration of MeNB ******************************************
%***************************** configuration of 20-UEs %*****************************************
% Here we locate the Ues In the Grid
for i=1:50
UE(i).x=400;% x coordinate
UE(i).y=500;% y coordinate
UE(i).height=1.7;
UserLocationX(i)= 0;
UserLocationY(i)= 0;
UserLocationZ(i)= 0;
end
i=1
x=400;% x coordinate
y=500
while i<51
x=randi(1000, 1, 1);
y=randi(1000, 1, 1);
if (x<400 || x>500) && (y<400 || y>500)
UE(i).x=x;% x coordinate
UE(i).y=y;% y coordinate
UserLocationX(i)= UE(i).x;
UserLocationY(i)= UE(i).y;
UserLocationZ(i)= 1.7;
i=i+1;
end
end
%***************************** End configuration of 20-UEs %*****************************************
%***************************** scatter plot of UEs and ENB %*****************************************
figure(‘Color’, ‘white’)
plot(UserLocationX, UserLocationY, ‘^’, ‘MarkerSize’, 5, ‘LineWidth’, 3), hold on
BaseStationX = 500;
BaseStationY = 500;
plot(BaseStationX, BaseStationY, ‘rs’, ‘MarkerSize’, 5, ‘LineWidth’, 4), hold on, grid on, grid minor
hleg = legend(‘User Location’, ‘Base Station’);
set(hleg, ‘Location’, ‘NorthEastOutside’);
xlabel(‘coordinate Χ’);
ylabel(‘coordinate Υ’);
%***************************** End scatter plot of UEs and ENB %*****************************************
%***************************** initialization phase of UEs *****************************************
% Here we calculate some parameters of the UEs before they moving(PL,SINR,CQI,Max throughput, max resurceBlock that the UE xan take )
for i=1:50
UE(i).distancefrom_eNB_m(1)=round(Distance(MeNB(1).x,MeNB(1).y,UE(i).x,UE(i).y));%calculate distance between each UE ad eNB
UE(i).PL_dB(1) =(HATA_Model((UE(i).distancefrom_eNB_m(1)/1000),F_HATA(1),MeNB(1).height, UE(i).height,Category(2)))+Lbody+Lbpl+Lj;%calculate Path Loss for each UE
UE(i).PowerReceive_dBmW(1)= MeNB(1).powerTransmit -UE(i).PL_dB+Ga;%calculate Power receive ( Pr) for each UE
UE(i).SNR_dB(1)=UE(i).PowerReceive_dBmW-NoisePower;%calculate SINR for each UE [dB]
UE(i).SNR(1)= 10^(UE(i).SNR_dB(1)/10);%calculate SINR for each UE
UE(i).CQI(1)=CQI_calculation(UE(i).SNR_dB(1));%calculate CQI for each UE [dB]
UE(i).MODULATION(1)= Modulation_calculation(UE(i).SNR_dB(1));%calculate Modulation scheme for each UE depending on CQI [dB]
UE(i).resurceBlock(1)=setRB(UE(i).SNR_dB(1));%calculate how many resource block can each UE receive [dB]
% UE(i).throughput(1)=throughput_calculation( UE(i).MODULATION,UE(i).resurceBlock(1),UE(i).SNR_dB(1));%calculate throughput each UE receive [dB]
end
%{
Ues request service from provider
calcualation of servise priority
sheduler give as many resources as needed min{ can_decode,service_requires}
%}
for i=1:50
UE(i).QCI(1)=QCI_example_service();
UE(i).ExampleServise(1)=ExampleServise_calculation(UE(i).QCI);
UE(i).Priority=Priority_calculation(UE(i).QCI);
UE(i).Resource_Block_Allocation(1)=Resource_Block_Allocation_calculation( UE(i).QCI(1), UE(i).resurceBlock(1));
UE(i).throughput(1)=throughput_calculation( UE(i).MODULATION(1),UE(i).Resource_Block_Allocation(1), UE(i).SNR_dB(1));
end
%%--------------- Selecting Data of interest ---------------------
% ---------------------------- Code ------------------------------
Table_UE = struct2table(UE);
data = Table_UE(:,1:2);
data = table2array(data);
%________________________________________________________________
%________________________________________________________________
%%------------ Selecting Optimal Number of Clusters ------------
% -------------- Method 1: Using the Elbow Method ---------------
% ---------------------------- Code -----------------------------
WCSS = [];
for k = 1:20
sumd = 0;
[idx,C,sumd] = kmeans(data,k);
WCSS(k) = sum(sumd);
end
⛄三、运行结果
⛄四、matlab版本及参考文献
1 matlab版本
2014a
2 参考文献
[1]刘雅文,蒋妍,潘大志.改进二进制和声搜索算法求解多维背包问题[J].计算机与现代化 2022-08-15
3 备注
简介此部分摘自互联网,仅供参考,若侵权,联系删除
🍅 仿真咨询
1 各类智能优化算法改进及应用
生产调度、经济调度、装配线调度、充电优化、车间调度、发车优化、水库调度、三维装箱、物流选址、货位优化、公交排班优化、充电桩布局优化、车间布局优化、集装箱船配载优化、水泵组合优化、解医疗资源分配优化、设施布局优化、可视域基站和无人机选址优化
2 机器学习和深度学习方面
卷积神经网络(CNN)、LSTM、支持向量机(SVM)、最小二乘支持向量机(LSSVM)、极限学习机(ELM)、核极限学习机(KELM)、BP、RBF、宽度学习、DBN、RF、RBF、DELM、XGBOOST、TCN实现风电预测、光伏预测、电池寿命预测、辐射源识别、交通流预测、负荷预测、股价预测、PM2.5浓度预测、电池健康状态预测、水体光学参数反演、NLOS信号识别、地铁停车精准预测、变压器故障诊断
3 图像处理方面
图像识别、图像分割、图像检测、图像隐藏、图像配准、图像拼接、图像融合、图像增强、图像压缩感知
4 路径规划方面
旅行商问题(TSP)、车辆路径问题(VRP、MVRP、CVRP、VRPTW等)、无人机三维路径规划、无人机协同、无人机编队、机器人路径规划、栅格地图路径规划、多式联运运输问题、车辆协同无人机路径规划、天线线性阵列分布优化、车间布局优化
5 无人机应用方面
无人机路径规划、无人机控制、无人机编队、无人机协同、无人机任务分配
6 无线传感器定位及布局方面
传感器部署优化、通信协议优化、路由优化、目标定位优化、Dv-Hop定位优化、Leach协议优化、WSN覆盖优化、组播优化、RSSI定位优化
7 信号处理方面
信号识别、信号加密、信号去噪、信号增强、雷达信号处理、信号水印嵌入提取、肌电信号、脑电信号、信号配时优化
8 电力系统方面
微电网优化、无功优化、配电网重构、储能配置
9 元胞自动机方面
交通流 人群疏散 病毒扩散 晶体生长
10 雷达方面
卡尔曼滤波跟踪、航迹关联、航迹融合