⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 selectorderpatterns.m

📁 实现遗传算法对于SFAM网络输入模式的序列优化
💻 M
字号:
echo on
global trainTestData2
global StageOneIris
global traindata
global trainlabel

load trainTestData2
load StageOneIris

traindata=traindata;
trainlabel=trainlabel;
sz=size(traindata,1);

xFns = 'partmapXover orderbasedXover '
xFns =[xFns,'singleptXover linerorderXover'];
% xFns = [xFns,'enhancederXover linerorderXover']
% xFns = [xFns,'linerorderXover singleptXover']
xOpts = [2;2;2;2];%[ 2; 2; 2; 2; 2; 2; 2];

% Order-based Mutation Operators
% inversionMutation
% adjswapMutation.m      
% shiftMutation.m        
% swapMutation.m         
% threeswapMutation.m    

mFns = 'inversionMutation adjswapMutation shiftMutation swapMutation threeswapMutation';
mOpts = [2;2;2;2;2];

% Termination Operators
termFns = 'maxGenTerm';
termOps = [100]; % 100 Generations

% Selection Function
selectFn = 'normGeomSelect';
selectOps = [0.08];

% Evaluation Function
evalFn = 'sfam_demoEval';

evalOps = [];
type sfam_demoEval
%the upper and lower bounds on the variables
bounds = [sz];

% GA Options [epsilon float/binar display]
gaOpts=[1e-6 1 1];

% Generate an intialize population of size 20
startPop = initializeoga(20,bounds,'sfam_demoEval',[1e-6 1]);


%Hit a return to continue
pause
[x endPop bestPop trace]=ga(bounds,evalFn,evalOps,startPop,gaOpts,termFns,termOps,selectFn,selectOps,xFns,xOpts,mFns,mOpts);

% x is the best solution found
x
%Hit a return to continue
pause

% endPop is the ending population
%endPop
%%Hit a return to continue
%pause

% bestPop is the best solution tracked over generations
bestPop
%Hit a return to continue
pause

% trace is a trace of the best value and average value of generations
trace

%Hit a return to continue
pause

% Plot the best over time
clf
plot(trace(:,1),trace(:,2),'r');

hold on
plot(trace(:,1),trace(:,3));


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -