📄 speedyga.m
字号:
% SpeedyGA is a vectorized implementation of a Simple Genetic Algorithm in Matlab
% Version 1.3
% Copyright (C) 2007, 2008, 2009 Keki Burjorjee
% Created and tested under Matlab 7 (R14).
% Licensed under the Apache License, Version 2.0 (the "License"); you may
% not use this file except in compliance with the License. You may obtain
% a copy of the License at
%
% http://www.apache.org/licenses/LICENSE-2.0
%
% Unless required by applicable law or agreed to in writing, software
% distributed under the License is distributed on an "AS IS" BASIS,
% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
% See the License for the specific language governing permissions and
% limitations under the License.
% Acknowledgement of the author (Keki Burjorjee) is requested, but not required,
% in any publication that presents results obtained by using this script
% Without Sigma Scaling, Stochastic Universal Sampling, and the generation of mask
% repositories, SpeedyGA faithfully implements the specification of a simple genetic
% algorithm given on pages 10,11 of M. Mitchell's book An Introduction to
% Genetic Algorithms, MIT Press, 1996). Selection is fitness
% proportionate.
len=640 % The length of the genomes
popSize=500; % The size of the population (must be an even number)
maxGens=1000; % The maximum number of generations allowed in a run
probCrossover=1; % The probability of crossing over.
probMutation=0.003; % The mutation probability (per bit)
sigmaScalingFlag=1; % Sigma Scaling is described on pg 168 of M. Mitchell's
% GA book. It often improves GA performance.
sigmaScalingCoeff=1; % Higher values => less fitness pressure
SUSFlag=1; % 1 => Use Stochastic Universal Sampling (pg 168 of
% M. Mitchell's GA book)
% 0 => Do not use Stochastic Universal Sampling
% Stochastic Universal Sampling almost always
% improves performance
crossoverType=2; % 0 => no crossover
% 1 => 1pt crossover
% 2 => uniform crossover
visualizationFlag=1; % 0 => don't visualize bit frequencies
% 1 => visualize bit frequencies
verboseFlag=1; % 1 => display details of each generation
% 0 => run quietly
useMaskRepositoriesFlag=1; % 1 => draw uniform crossover and mutation masks from
% a pregenerated repository of randomly generated bits.
% Significantly improves the speed of the code with
% no apparent changes in the behavior of
% the SGA
% 0 => generate uniform crossover and mutation
% masks on the fly. Slower.
% crossover masks to use if crossoverType==0.
mutationOnlycrossmasks=false(popSize,len);
% pre-generate two 搑epositories
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -