老外编的标准pso算法的matlab工具箱

源代码在线查看: rosenbrock.m

软件大小: 61 K
上传用户: zzxt
关键词: matlab pso 标准 工具箱
下载地址: 免注册下载 普通下载 VIP

相关代码

				%The Rosenbrock function for use with the psotoolbox
				%
				% Function Description:
				% Equation -> sum ( 100 * (x(i+1) - x(i)^2)^2 + (1-x(i))^2 )
				%      xmin  = [1, 1, 1.....1]  (all ones)
				%      fxmin = 0                  (zero)
				function Rosened = Rosenbrock(Swarm)
				[SwarmSize, Dim] = size(Swarm);
				Swarm1 = Swarm(:, 1:(Dim-1));
				Swarm2 = Swarm(:, 2:Dim);
				if Dim == 2
				    Rosened = 100 * (Swarm2 - Swarm1.^2).^2 + (1 - Swarm1).^2;
				else     
				    Rosened = sum((100 * (Swarm2 - Swarm1.^2).^2 + (1 - Swarm1).^2)')'; 
				end   
				
							

相关资源