demoant.m

来自「遗传规划的matlab工具箱」· M 代码 · 共 30 行

M
30
字号
function [v,b]=demoant
%DEMOANT    Demonstration function of the GPLAB toolbox.
%
%   See also DEMO,DEMOPARITY
%
%   Copyright (C) 2003-2004 Sara Silva (sara@dei.uc.pt)
%   This file is part of the GPLAB Toolbox

fprintf('Running artificial ant demo...');

p=resetparams;
p.sampling='roulette';
p.survival='keepbest';
p=setoperators(p,'crossover',2,2);
p=setfunctions(p,'antif',2,'antprogn2',2,'antprogn3',3);
p=setterminals(p,'antright','antleft','antmove');
p.calcfitness='antfitness';
p.lowerisbetter=0;
p.files2data='anttrail';
p.autovars='0';
p.datafilex='santafetrail.txt';
p.datafiley='santafepellets.txt';
p.calcdiversity={};
p.calccomplexity='0';
p.depthnodes='1';
p.graphics={'plotfitness','plotcomplexity'};

[v,b]=gplab(10,20,p);

drawtree(v.state.bestsofar.tree);

⌨️ 快捷键说明

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