1 简介
2009?年伊朗的克曼大学教授?Esmat Rashedi?等人提出了引力搜索算法[5(]?Gravitational Search Algorithm),该算法是基于牛顿万有引力定律:“在宇宙间,每一个粒子由于万有引力的作用而彼此相互吸引,这力的大小与粒子的质量成正比,与他们之间的距离成反比”。






2 部分代码
clear?all;clc
% inputs:
% N: Number of agents.
% max_it: Maximum number of iterations (T).
% ElitistCheck: If ElitistCheck=1, algorithm runs with eq.21 and if =0, runs with eq.9.
% Rpower: power of 'R' in eq.7.
% F_index: The index of the test function. See tables 1,2,3 of the mentioned article.
% ? ? ? ? Insert your own objective function with a new F_index in 'test_functions.m'
% ? ? ? ? and 'test_functions_range.m'.
% outputs:
% Fbest: Best result.?
% Lbest: Best solution. The location of Fbest in search space.
% BestChart: The best so far Chart over iterations.?
% MeanChart: The average fitnesses Chart over iterations.
N=50;?
max_it=1000;?
ElitistCheck=1;?Rpower=1;
min_flag=1;?% 1: minimization, 0: maximization
F_index=1
[Fbest,Lbest,BestChart,MeanChart]=GSA(F_index,N,max_it,ElitistCheck,min_flag,Rpower);Fbest,
semilogy(BestChart,'--k');
title(['\fontsize{12}\bf F',num2str(F_index)]);
xlabel('\fontsize{12}\bf Iteration');ylabel('\fontsize{12}\bf Best-so-far');
legend('\fontsize{10}\bf GSA',1);
3 仿真结果


4 参考文献
[1]田昊. 基于引力搜索算法的水火电短期优化调度方法. Diss. 华中科技大学, 2016.

|