function [Best_Planet , best,Bestss] = TransitSearch (ns,maxcycle,Vmin,Vmax,nvar,CostFunction)
SN=10;
%% Initialization
Empty.Location = [];
Empty.Cost = inf;
Galaxy_Center = repmat (Empty, 1, 1);
region = repmat (Empty, ns*SN, 1);
selested_regions = repmat (Empty, ns, 1);
Stars = repmat (Empty, ns, 1);
Stars_sorted = zeros(ns,1);
Ranks = 1:1:ns;
Stars_Ranks = zeros(ns,1);
Luminosity = zeros(ns,1);
Star_RanksNormal = zeros(ns,1);
Distance = zeros(ns,1);
Transit0 = zeros(ns,1);
SN_P = repmat (Empty, SN, 1);
Bests=region;
if length(Vmin) >1
Vmin=Vmin;
Vmax=Vmax;
else
Vmin=Vmin*ones(1,nvar);
Vmax=Vmax*ones(1,nvar);
end
%% Galaxy Phase
% Initial Location of The Center of the Galaxy
Galaxy_Center.Location = unifrnd(Vmin,Vmax,1,nvar);
% Galaxy_Center.Location=initialization(ns,nvar,Vmax,Vmin);
Galaxy_Center.Cost = CostFunction(Galaxy_Center.Location);
% Galactic Habitate Zone of the Galaxy
for l = 1:ns*SN
zone = randi(2);
if zone ==1
difference = rand().*(Galaxy_Center.Location)-(unifrnd(Vmin,Vmax,1,nvar));
else
difference = rand().*(Galaxy_Center.Location)+(unifrnd(Vmin,Vmax,1,nvar));
end
Noise = ((rand(1,nvar)).^3).*(unifrnd(Vmin,Vmax,1,nvar));
region(l).Location = Galaxy_Center.Location + difference - Noise;
region(l).Location = max(region(l).Location, Vmin);
region(l).Location = min(region(l).Location, Vmax);
region(l).Cost = CostFunction(region(l).Location);
end
% Selection of Stars from the Galactic Habitate Zone of the Galaxy
[Sort,index]=sort([region.Cost]);
for i = 1:ns
selested_regions(i) = region(i);
for k = 1:SN
zone = randi(2);
if zone ==1
difference = rand().*(selested_regions(i).Location)-rand().*(unifrnd(Vmin,Vmax,1,nvar));
else
difference = rand().*(selested_regions(i).Location)+rand().*(unifrnd(Vmin,Vmax,1,nvar));
end
Noise = ((rand(1,nvar)).^3).*(unifrnd(Vmin,Vmax,1,nvar));
new.Location = selested_regions(i).Location + difference - Noise;
new.Location = max(new.Location, Vmin);
new.Location = min(new.Location, Vmax);
new.Cost = CostFunction(new.Location);
if new.Cost < Stars(i).Cost
Stars(i) = new;
end
end
end
% Initial Location of the Best Planets (Start Point: Its Star)
Best_Planets = Stars;
% Specification of the Best Planet
[Sort,index]=sort([Best_Planets(1).Cost]);
Best_Planet = Best_Planets(index(1,1));
% Telescope Location
Telescope.Location = unifrnd(Vmin,Vmax,1,nvar);
% Determination of the Luminosity of the Stars
for i = 1:ns
Stars_sorted(i,1) = Stars(i).Cost;
end
Stars_sorted = sort (Stars_sorted);
for i = 1:ns
for ii = 1:ns
if Stars(i).Cost == Stars_sorted(ii,1)
Stars_Ranks(i,1) = Ranks(1,ii);
Star_RanksNormal(i,1) = (Stars_Ranks(i,1))./ns;
end
end
Distance(i,1) = sum((Stars(i).Location-Telescope.Location).^2).^0.5;
Luminosity(i,1) = Star_RanksNormal(i,1)/((Distance(i,1))^2);
end
Luminosity_new = Luminosity;
Stars2 = Stars;
%% Loops of the TS Algorithm
for it = 1:maxcycle
%% Transit Phase
Transit = Transit0;
Luminosity = Luminosity_new;
for i = 1:ns
difference = (2*rand()-1).*(Stars(i).Location);
Noise = ((rand(1,nvar)).^3).*(unifrnd(Vmin,Vmax,1,nvar));
Stars2(i).Location = Stars(i).Location + difference - Noise;
Stars2(i).Location = max(Stars2(i).Location, Vmin);
Stars2(i).Location = min(Stars2(i).Location, Vmax);
Stars2(i).Cost = CostFunction(Stars2(i).Location);
end
for i = 1:ns
Stars_sorted(i,1) = Stars2(i).Cost;
end
Stars_sorted = sort (Stars_sorted);
for i = 1:ns
for ii = 1:ns
if Stars2(i).Cost == Stars_sorted(ii,1)
Stars_Ranks(i,1) = Ranks(1,ii);
Star_RanksNormal(i,1) = (Stars_Ranks(i,1))./ns;
end
end
Distance(i,1) = sum((Stars2(i).Location-Telescope.Location).^2).^0.5;
Luminosity_new(i,1) = Star_RanksNormal(i,1)/((Distance(i,1))^2);
if Luminosity_new(i,1) < Luminosity(i,1)
Transit (i,1) = 1; % Has transit been observed? 0 = No; 1 = Yes
end
end
Stars = Stars2;
%% Location Phase (Exploration)
for i = 1:ns
if Transit (i,1) == 1
% Determination of the Location of the Planet
Luminosity_Ratio = Luminosity_new(i,1)/Luminosity(i,1);
Planet.Location = (rand().*Telescope.Location + Luminosity_Ratio.*Stars(i).Location)./2;
for k = 1:SN
zone = randi(3);
if zone ==1
new.Location = Planet.Location - (2*rand()-1).*(unifrnd(Vmin,Vmax,1,nvar));
elseif zone ==2
new.Location = Planet.Location + (2*rand()-1).*(unifrnd(Vmin,Vmax,1,nvar));
else
new.Location = Planet.Location + (2.*rand(1,nvar)-1).*(unifrnd(Vmin,Vmax,1,nvar));
end
new.Location = max(new.Location, Vmin);
new.Location = min(new.Location, Vmax);
% new.Cost = CostFunction(new.Location);
SN_P(k) = new;
end
SUM = 0;
for k = 1:SN
SUM = SUM+SN_P(k).Location;
end
new.Location = SUM./SN;
new.Cost = CostFunction(new.Location);
if new.Cost < Best_Planets(i).Cost
Best_Planets(i) = new;
end
else % No Transit observed: Neighbouring planets
Neighbor.Location = (rand().*Stars(i).Location + rand().*(unifrnd(Vmin,Vmax,1,nvar)))./2;
for k = 1:SN
zone = randi(3);
if zone ==1
Neighbor.Location = Neighbor.Location - (2*rand()-1).*(unifrnd(Vmin,Vmax,1,nvar));
elseif zone ==2
Neighbor.Location = Neighbor.Location + (2*rand()-1).*(unifrnd(Vmin,Vmax,1,nvar));
else
Neighbor.Location = Neighbor.Location + (2.*rand(1,nvar)-1).*(unifrnd(Vmin,Vmax,1,nvar));
end
Neighbor.Location = max(Neighbor.Location, Vmin);
Neighbor.Location = min(Neighbor.Location, Vmax);
Neighbor.Cost = CostFunction (Neighbor.Location);
SN_P(k) = Neighbor;
end
SUM = 0;
for k = 1:SN
SUM = SUM+SN_P(k).Location;
end
Neighbor.Location = SUM./SN;
Neighbor.Cost = CostFunction (Neighbor.Location);
if Neighbor.Cost < Best_Planets(i).Cost
Best_Planets(i) = Neighbor;
end
end
end
%% Signal Amplification of the Best Planets (Exploitation)
for i = 1:ns
for k = 1:SN
RAND = randi(2 );
if RAND ==1
Power = randi(SN*ns);
Coefficient = 2*rand();
Noise = ((rand(1,nvar)).^Power).*(unifrnd(Vmin,Vmax,1,nvar));
else
Power = randi(SN*ns);
Coefficient = 2*rand();
Noise = -((rand(1,nvar)).^Power).*(unifrnd(Vmin,Vmax,1,nvar));
end
% new.Location = (rand().*Best_Planets(i).Location) - Coefficient.*Noise;
chance = randi(2);
if chance ==1
new.Location = Best_Planets(i).Location - Coefficient.*Noise;
else
new.Location = (rand().*Best_Planets(i).Location) - Coefficient.*Noise;
end
天天Matlab科研工作室
- 粉丝: 4w+
- 资源: 1万+
最新资源
- 校园车辆管理系统 免费JAVA毕业设计 2024成品源码+论文+录屏+启动教程.zip
- 电力系统可靠性评估中的自适应重要抽样法:减小方差、逼近最优概率分布,电力系统可靠性评估-自适应重要抽样法 自适应重要抽样方法是在可靠性指标不变的情况下,以减小抽样方差为目标,根据元件的故障
- 小区车辆管理系统 免费JAVA毕业设计 2024成品源码+论文+录屏+启动教程.zip
- 无线充电仿真与LLC谐振器恒压输出实现:无线电能传输技术及其参考文献解析,无线充电仿真 simulink llc谐振器实现恒压输出 WPT 无线电能传输 附带参考文献 ,核心关键词:无线充电仿真
- 直线与永磁同步电机矢量控制及模型研究:涵盖恒转差控制与Svpwm输出模型参考,1、直线感应电机矢量控制,直线感应电机模型,以及直线感应电机恒转差控制并提供参考资料 2、永磁同步直线电机矢量控制、直接转
- 基于STC89C51单片机的智能温控风扇系统:自动读取DS18B20温度数据,红外人体感应智能调节PWM输出,无人时自动关闭并显示当前温度于数码管上 ,基于stc89c51单片机的温控风扇(程序代码+
- 永磁同步电机PMSM无感FOC驱动与位置估算源码分享:高性能观测器,跨平台兼容,动态响应优越,永磁同步电机pmsm无感foc驱动代码 位置估算源码 无刷直流电机无感foc源码,无感foc算法源码 若需
- AjServer,用于启动AutojsPro
- HB-LLC半桥LLC谐振变换器仿真模型:340-400VDC输入,24V 200W输出,MATLAB Simulink R2015b环境,HB-LLC:基于MATLAB Simulink的半桥LLC
- STC USB驱动安装步骤及注意事项
- "18650圆柱锂电池模组液冷技术参数化研究及电化学生热模拟分析-基于Comsol5.6模型的研究成果展示",18650圆柱锂电池模组液冷模型 comsol5.6模型 参数已配置,电化学生热研究
- 基于TCP协议的在线聊天室系统 免费JAVA毕业设计 2024成品源码+论文+录屏+启动教程.zip
- 西门子S7-1500堆垛机S型曲线速度控制程序详解:博途V15.1 SCL编程语言下的通信、算法与运动控制综合应用,堆垛机西门子S7-1500 S型曲线速度控制部分程序 涵盖通信,算法,运动控制,屏
- mybatis专栏 003 mapper代理开发方式-注解方式
- 宠物饲养系统 免费JAVA毕业设计 2024成品源码+论文+录屏+启动教程.zip
- 高校就业管理系统 免费JAVA毕业设计 2024成品源码+论文+录屏+启动教程.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈