Upload original Matlab程序设计 course files (part 7)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/DOC/GATBXA1.PS
- matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/DOC/GATBXA2.PS
- matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/BS2RV.M+115-3
- matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/CONTENTS.M+54-3
- matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/CRTBASE.M+47-3
- matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/CRTBP.M+72-3
- matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/CRTRP.M+53-3
- matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/MIGRATE.M+149-3
- matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/MPGA.M+119-3
- matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/MUT.M+54-3
- matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/MUTATE.M+82-3
- matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/MUTBGA.M+113-3
- matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/OBJFUN1.M+71-3
- matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/OBJHARV.M+78-3
- matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/RANKING.M+125-3
- matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/RECDIS.M+52-3
- matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/RECINT.M+55-3
- matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/RECLIN.M+57-3
- matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/RECMUT.M+118-3
- matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/RECOMBIN.M+69-3
- matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/REINS.M+123-3
- matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/REP.M+46-3
- matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/RESPLOT.M+56-3
- matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/RWS.M+31-3
- matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/SCALING.M+52-3
- matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/SELECT.M+69-3
- matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/SGA.M+69-3
- matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/SUS.M+41-3
- matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/TEST_FNS/DEMOGA1.M+118-3
- matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/TEST_FNS/MPGA.M+127-3
- matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/TEST_FNS/OBJBRAN.M+69-3
- matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/TEST_FNS/OBJDOPI.M+107-3
- matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/TEST_FNS/OBJEASO.M+69-3
- matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/TEST_FNS/OBJFUN1.M+71-3
- matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/TEST_FNS/OBJFUN1A.M+68-3
- matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/TEST_FNS/OBJFUN1B.M+66-3
- matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/TEST_FNS/OBJFUN2.M+72-3
- matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/TEST_FNS/OBJFUN6.M+73-3
- matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/TEST_FNS/OBJFUN7.M+68-3
- matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/TEST_FNS/OBJFUN8.M+72-3
- matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/TEST_FNS/OBJFUN9.M+67-3
- matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/TEST_FNS/OBJGOLD.M+71-3
- matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/TEST_FNS/OBJHARV.M+78-3
- matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/TEST_FNS/OBJLINQ.M+86-3
- matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/TEST_FNS/OBJLINQ2.M+105-3
- matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/TEST_FNS/OBJPUSH.M+75-3
- matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/TEST_FNS/OBJSIXH.M+68-3
- matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/TEST_FNS/RESPLOT.M+55-3
- matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/TEST_FNS/SGA.M+67-3
- matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/TEST_FNS/SIMDOPI1.M+80-3
123version https://git-lfs.github.com/spec/v1oid sha256:2a42fa20681fe57381f8c961409149366d60da9ffbfcf3efb169d6dcbbc66a28size 3217123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115% BS2RV.m - Binary string to real vector%% This function decodes binary chromosomes into vectors of reals. The% chromosomes are seen as the concatenation of binary strings of given% length, and decoded into real numbers in a specified interval using% either standard binary or Gray decoding.%% Syntax: Phen = bs2rv(Chrom,FieldD)%% Input parameters:%% Chrom - Matrix containing the chromosomes of the current% population. Each line corresponds to one% individual's concatenated binary string% representation. Leftmost bits are MSb and% rightmost are LSb.%% FieldD - Matrix describing the length and how to decode% each substring in the chromosome. It has the% following structure:%% [len; (num)% lb; (num)% ub; (num)% code; (0=binary | 1=gray)% scale; (0=arithmetic | 1=logarithmic)% lbin; (0=excluded | 1=included)% ubin]; (0=excluded | 1=included)%% where% len - row vector containing the length of% each substring in Chrom. sum(len)% should equal the individual length.% lb,% ub - Lower and upper bounds for each% variable.% code - binary row vector indicating how each% substring is to be decoded.% scale - binary row vector indicating where to% use arithmetic and/or logarithmic% scaling.% lbin,% ubin - binary row vectors indicating whether% or not to include each bound in the% representation range%% Output parameter:%% Phen - Real matrix containing the population phenotypes.%% Author: Carlos Fonseca, Updated: Andrew Chipperfield% Date: 08/06/93, Date: 26-Jan-94function Phen = bs2rv(Chrom,FieldD)% Identify the population size (Nind)% and the chromosome length (Lind)[Nind,Lind] = size(Chrom);% Identify the number of decision variables (Nvar)[seven,Nvar] = size(FieldD);if seven ~= 7error('FieldD must have 7 rows.');end% Get substring propertieslen = FieldD(1,:);lb = FieldD(2,:);ub = FieldD(3,:);code = ~(~FieldD(4,:));scale = ~(~FieldD(5,:));lin = ~(~FieldD(6,:));uin = ~(~FieldD(7,:));% Check substring properties for consistencyif sum(len) ~= Lind,error('Data in FieldD must agree with chromosome length');endif ~all(lb(scale).*ub(scale)>0)error('Log-scaled variables must not include 0 in their range');end% Decode chromosomesPhen = zeros(Nind,Nvar);lf = cumsum(len);li = cumsum([1 len]);Prec = .5 .^ len;logsgn = sign(lb(scale));lb(scale) = log( abs(lb(scale)) );ub(scale) = log( abs(ub(scale)) );delta = ub - lb;Prec = .5 .^ len;num = (~lin) .* Prec;den = (lin + uin - 1) .* Prec;for i = 1:Nvar,idx = li(i):lf(i);if code(i) % Gray decodingChrom(:,idx)=rem(cumsum(Chrom(:,idx)')',2);endPhen(:,i) = Chrom(:,idx) * [ (.5).^(1:len(i))' ];Phen(:,i) = lb(i) + delta(i) * (Phen(:,i) + num(i)) ./ (1 - den(i));endexpand = ones(Nind,1);if any(scale)Phen(:,scale) = logsgn(expand,:) .* exp(Phen(:,scale));end
123version https://git-lfs.github.com/spec/v1oid sha256:cd8ddbf0dc11c2eac9a9c1b0dd1dda6ef6ce04f08aca45a11652054507cc54f5size 1835123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354% Genetic Algorithm Toolbox.% Version 1.2 15-Apr-94% Department of Automatic Control and Systems Engineering% University of Sheffield, England%% Creating populations% crtbase - create a base vector% crtbp - create a binary population% crtrp - create a real-valued population%% Fitness assignment% ranking - rank-based fitness assignment% scaling - proportional fitness-scaling%% Selection and reinsertion% reins - uniform random and fitness-based reinsertion% rws - roulette wheel selection% select - high-level selection routine% sues - stochastic universal sampling%% Mutation operators% mut - discrete mutation% mutate - high-level mutation function% mutbga - real-value mutation%% Crossover operators% recdis - discrete recombination% recint - intermediate recombination% reclin - line recombination% recmut - line recombination with mutation features% recombin - high-level recombination function% xovdp - double-point crossover% xovdprs - double-point reduced surrogate crossover% xovmp - general multi-point crossover% xovsh - shuffle crossover% xovshrs - shuffle reduced surrogate crossover% xovsp - single-point crossover% xovsprs - single-point reduced surrogate crossover%% Subpopulation support% migrate - exchange individuals between subpopulations%%% Utility functions% bs2rv - binary string to real-value conversion% rep - matrix replication%% Demonstration and other functions% mpga - multi-population genetic algorithm demonstration% objfun1 - De Jongs first test function (used by sga)% objharv - harvest function (used in mpga)% resplot - result plotting (used in mpga)% sga - simple genetic algorithm demonstration
123version https://git-lfs.github.com/spec/v1oid sha256:e0a5dec9709b6d5c6ebafa3f4a452d455710626114c4add503b1968c4c62a22asize 11681234567891011121314151617181920212223242526272829303132333435363738394041424344454647% CRTBASE.m - Create base vector%% This function creates a vector containing the base of the loci% in a chromosome.%% Syntax: BaseVec = crtbase(Lind, Base)%% Input Parameters:%% Lind - A scalar or vector containing the lengths% of the alleles. Sum(Lind) is the length of% the corresponding chromosome.%% Base - A scalar or vector containing the base of% the loci contained in the Alleles.%% Output Parameters:%% BaseVec - A vector whose elements correspond to the base% of the loci of the associated chromosome structure.% Author: Andrew Chipperfield% Date: 19-Jan-94function BaseVec = crtbase(Lind, Base)[ml LenL] = size(Lind) ;if nargin < 2Base = 2 * ones(LenL,1) ; % default to base 2end[mb LenB] = size(Base) ;% check parameter consistencyif ml > 1 | mb > 1error( 'Lind or Base is not a vector') ;elseif (LenL > 1 & LenB > 1 & LenL ~= LenB) | (LenL == 1 & LenB > 1 )error( 'Vector dimensions must agree' ) ;elseif LenB == 1 & LenL > 1Base = Base * ones(LenL,1) ;endBaseVec = [] ;for i = 1:LenLBaseVec = [BaseVec, Base(i)*ones(Lind(i),1)'];end
123version https://git-lfs.github.com/spec/v1oid sha256:894b8535d97486a598d8143bcf8fef1d72907caff3870db4955f7a996518a5d2size 2187123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172% CRTP.m - Create an initial population%% This function creates a binary population of given size and structure.%% Syntax: [Chrom Lind BaseV] = crtbp(Nind, Lind, Base)%% Input Parameters:%% Nind - Either a scalar containing the number of individuals% in the new population or a row vector of length two% containing the number of individuals and their length.%% Lind - A scalar containing the length of the individual% chromosomes.%% Base - A scalar containing the base of the chromosome% elements or a row vector containing the base(s)% of the loci of the chromosomes.%% Output Parameters:%% Chrom - A matrix containing the random valued chromosomes% row wise.%% Lind - A scalar containing the length of the chromosome.%% BaseV - A row vector containing the base of the% chromosome loci.% Author: Andrew Chipperfield% Date: 19-Jan-94function [Chrom, Lind, BaseV] = crtbp(Nind, Lind, Base)nargs = nargin ;% Check parameter consistencyif nargs >= 1, [mN, nN] = size(Nind) ; endif nargs >= 2, [mL, nL] = size(Lind) ; endif nargs == 3, [mB, nB] = size(Base) ; endif nN == 2if (nargs == 1)Lind = Nind(2) ; Nind = Nind(1) ; BaseV = crtbase(Lind) ;elseif (nargs == 2 & nL == 1)BaseV = crtbase(Nind(2),Lind) ; Lind = Nind(2) ; Nind = Nind(1) ;elseif (nargs == 2 & nL > 1)if Lind ~= length(Lind), error('Lind and Base disagree'); endBaseV = Lind ; Lind = Nind(2) ; Nind = Nind(1) ;endelseif nN == 1if nargs == 2if nL == 1, BaseV = crtbase(Lind) ;else, BaseV = Lind ; Lind = nL ; endelseif nargs == 3if nB == 1, BaseV = crtbase(Lind,Base) ;elseif nB ~= Lind, error('Lind and Base disagree') ;else BaseV = Base ; endendelseerror('Input parameters inconsistent') ;end% Create a structure of random chromosomes in row wise order, dimensions% Nind by Lind. The base of each chromosomes loci is given by the value% of the corresponding element of the row vector base.Chrom = floor(rand(Nind,Lind).*BaseV(ones(Nind,1),:)) ;% End of file
123version https://git-lfs.github.com/spec/v1oid sha256:900cb8e84a5ad67fa6798ce0ae0b4a45b9bef93b5cad9a8119c108ecadfd1b36size 20911234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253% CRTRP.M (CReaTe an initial (Real-value) Population)%% This function creates a population of given size of random real-values.%% Syntax: Chrom = crtrp(Nind,FieldDR);%% Input parameters:% Nind - A scalar containing the number of individuals in the new% population.%% FieldDR - A matrix of size 2 by number of variables describing the% boundaries of each variable. It has the following structure:% [lower_bound; (vector with lower bound for each veriable)% upper_bound] (vector with upper bound for each veriable)% [lower_bound_var_1 lower_bound_var_2 ... lower_bound_var_Nvar;% upper_bound_var_1 upper_bound_var_2 ... upper_bound_var_Nvar]% example - each individuals consists of 4 variables:% FieldDR = [-100 -50 -30 -20; % lower bound% 100 50 30 20] % upper bound%% Output parameter:% Chrom - A matrix containing the random valued individuals of the% new population of size Nind by number of variables.% Author: Hartmut Pohlheim% History: 23.11.93 file created% 25.02.94 clean up, check parameter consistencyfunction Chrom = crtrp(Nind,FieldDR);% Check parameter consistencyif nargin < 2, error('parameter FieldDR missing'); endif nargin > 2, nargin = 2; end[mN, nN] = size(Nind);[mF, Nvar] = size(FieldDR);if (mN ~= 1 & nN ~= 1), error('Nind has to be a scalar'); endif mF ~= 2, error('FieldDR must be a matrix with 2 rows'); end% Compute Matrix with Range of variables and Matrix with Lower valueRange = rep((FieldDR(2,:)-FieldDR(1,:)),[Nind 1]);Lower = rep(FieldDR(1,:), [Nind 1]);% Create initial population% Each row contains one individual, the values of each variable uniformly% distributed between lower and upper bound (given by FieldDR)Chrom = rand(Nind,Nvar) .* Range + Lower;% End of function
123version https://git-lfs.github.com/spec/v1oid sha256:8294ef22c9e4017f0b8f14ca16d39e04ff6a922b813b78f5bb7c3034d2efeeb3size 7205123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149% MIGRATE.M (MIGRATion of individuals between subpopulations)%% This function performs migration of individuals.%% Syntax: [Chrom, ObjV] = migrate(Chrom, SUBPOP, MigOpt, ObjV)%% Input parameters:% Chrom - Matrix containing the individuals of the current% population. Each row corresponds to one individual.% SUBPOP - Number of subpopulations% MigOpt - (optional) Vector containing migration parameters% MigOpt(1): MIGR - Rate of individuals to be migrated per% subpopulation (% of subpopulation)% if omitted or NaN, 0.2 (20%) is assumed% MigOpt(2): Select - number indicating the selection method% of replacing individuals% 0 - uniform selection% 1 - fitness-based selection (replace worst% individuals)% if omitted or NaN, 0 is assumed% MigOpt(3): Structure - number indicating the structure% of the subpopulations for migration% 0 - net structure (unconstrained migration)% 1 - neighbourhood structure% 2 - ring structure% if omitted or NaN, 0 is assumed% ObjV - (optional) Column vector containing the objective values% of the individuals in the current population, needed for% fitness-based migration, this saves the% recalculation of objective values for population.%% Output parameters:% Chrom - Matrix containing the individuals of the current% population after migration.% ObjV - if ObjV is input parameter, than column vector containing% the objective values of the individuals of the current% generation after migration.% Author: Hartmut Pohlheim% History: 16.02.94 file created% 18.02.94 comments at the beginning added% exchange of ObjV too% 25.02.94 clean up% 26.02.94 ObjV optional input parameter% Select and Structure added, parameter reordered% 17.03.94 renamed to migrate.m, more parameter checksfunction [Chrom, ObjV] = migrate(Chrom, SUBPOP, MigOpt, ObjV);% Check parameter consistencyif nargin < 2, error('Input parameter SUBPOP missing'); endif (nargout == 2 & nargin < 4), error('Input parameter ObjV missing'); end[Nind, Nvar] = size(Chrom);if length(SUBPOP) ~= 1, error('SUBPOP must be a scalar'); endif SUBPOP == 1, return; endif (Nind/SUBPOP) ~= fix(Nind/SUBPOP), error('Chrom and SUBPOP disagree'); endNIND = Nind/SUBPOP; % Compute number of individuals per subpopulationif nargin > 3,[mO, nO] = size(ObjV);if nO ~= 1, error('ObjV must be a column vector'); endif Nind ~= mO, error('Chrom and ObjV disagree'); endIsObjV = 1;else IsObjV = 0; ObjV = [];endif nargin < 3, MIGR = 0.2; Select = 0; Structure = 0; endif nargin > 2,if isempty(MigOpt), MIGR = 0.2; Select = 0; Structure = 0;elseif isnan(MigOpt), MIGR = 0.2; Select = 0; Structure = 0;elseMIGR = NaN; Select = NaN; Structure = NaN;if length(MigOpt) > 3, error('Parameter MigOpt is too long'); endif length(MigOpt) >= 1, MIGR = MigOpt(1); endif length(MigOpt) >= 2, Select = MigOpt(2); endif length(MigOpt) >= 3, Structure = MigOpt(3); endif isnan(MIGR), MIGR =0.2; endif isnan(Select), Select = 0; endif isnan(Structure), Structure = 0; endendendif (MIGR < 0 | MIGR > 1), error('Parameter for migration rate must be a scalar in [0 1]'); endif (Select ~= 0 & Select ~= 1), error('Parameter for selection method must be 0 or 1'); endif (Structure < 0 | Structure > 2), error ('Parameter for structure must be 0, 1 or 2'); endif (Select == 1 & IsObjV == 0), error('ObjV for fitness-based migration needed');endif MIGR == 0, return; endMigTeil = max(floor(NIND * MIGR), 1); % Number of individuals to migrate% Perform migration between subpopulations --> create a matrix for migration% in every subpopulation from best individuals of the other subpopulations% Clear storing matricesChromMigAll = [];if IsObjV == 1, ObjVAll = []; end% Create matrix with best/uniform individuals of all subpopulationsfor irun = 1:SUBPOP% sort ObjV of actual subpopulationif Select == 1, % fitness-based selection[Dummy, IndMigSo]=sort(ObjV((irun-1)*NIND+1:irun*NIND));else % if Select == 0 % uniform selection[Dummy, IndMigSo]=sort(rand(NIND, 1));end% take MigTeil (best) individuals, copy individuals and objective valuesIndMigTeil=IndMigSo(1:MigTeil)+(irun-1)*NIND;ChromMigAll = [ChromMigAll; Chrom(IndMigTeil,:)];if IsObjV == 1, ObjVAll = [ObjVAll; ObjV(IndMigTeil,:)]; endend% perform migrationfor irun = 1:SUBPOPChromMig = ChromMigAll;if IsObjV == 1, ObjVMig = ObjVAll; endif Structure == 1, % neighbourhood% select individuals of neighbourhood subpopulations for ChromMig and ObjVMigpopnum = [SUBPOP 1:SUBPOP 1];ins1 = popnum(irun); ins2 = popnum(irun + 2);InsRows = [(ins1-1)*MigTeil+1:ins1*MigTeil (ins2-1)*MigTeil+1:ins2*MigTeil];ChromMig = ChromMig(InsRows,:);if IsObjV == 1, ObjVMig = ObjVMig(InsRows,:); endelseif Structure == 2, % ring% select individuals of actual-1 subpopulation for ChromMig and ObjVMigpopnum = [SUBPOP 1:SUBPOP 1];ins1 = popnum(irun);InsRows = (ins1-1)*MigTeil+1:ins1*MigTeil;ChromMig = ChromMig(InsRows,:);if IsObjV == 1, ObjVMig = ObjVMig(InsRows,:); endelse % if Structure == 0, % complete net% delete individuals of actual subpopulation from ChromMig and ObjVMigDelRows = (irun-1)*MigTeil+1:irun*MigTeil;ChromMig(DelRows,:) = [];if IsObjV == 1, ObjVMig(DelRows,:) = []; endend% Create an index from a sorted vector with random numbers[Dummy,IndMigRa]=sort(rand(size(ChromMig,1),1));% Take MigTeil numbers from the random vectorIndMigN=IndMigRa((1:MigTeil)');% copy MigTeil individuals into Chrom and ObjVChrom((1:MigTeil)+(irun-1)*NIND,:) = ChromMig(IndMigN,:);if IsObjV == 1, ObjV((1:MigTeil)+(irun-1)*NIND,:) = ObjVMig(IndMigN,:); endend% End of function
123version https://git-lfs.github.com/spec/v1oid sha256:3be3ef407462f6d47ada9326340791bb891df5a4e5cecd7e783b01e9b693b195size 4019123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119% mpga multi population genetic algorithm%% This script implements the Multi Population Genetic Algorithm.% A real-valued representation of the individuals is used.%% Author: Andrew Chipperfield% History: 30-Mar-94 file createdNVAR = 20; % No. of decision variables (control steps)RANGE = [0;200]; % Bounds on decision variables% Set field descriptorFieldD = rep(RANGE,[1,NVAR]);% Define GA ParametersGGAP = .8; % Generation gap, how many new individuals are createdXOVR = 1; % Crossover rateMUTR = 1/NVAR; % Mutation rate depending on NVARMAXGEN = 1200; % Maximum number of generationsTERMEXACT = 1e-4; % Value for termination if minimum reachedINSR = .9; % Insertion rate, how many of the offspring are insertedSUBPOP = 8; % Number of subpopulationsMIGR = 0.2; % Migration rate between subpopulationsMIGGEN = 20; % Number of generations between migrationNIND = 20; % Number of individuals per subpopulation% Specify other routines as stringsSEL_F = 'sus'; % Name of selection functionXOV_F = 'recdis'; % Name of recombination function for individualsMUT_F = 'mutbga'; % Name of mutation functionOBJ_F = 'objharv'; % Name of function for objective values% Get value of minimum, defined in objective functionGlobalMin = feval(OBJ_F,[],3);% Get title of objective function, defined in objective functionFigTitle = [feval(OBJ_F,[],2) ' (' int2str(SUBPOP) ':' int2str(MAXGEN) ') '];% Clear Best and storing matrix% Initialise Matrix for storing best resultsBest = NaN * ones(MAXGEN,3);Best(:,3) = zeros(size(Best,1),1);% Matrix for storing best individualsIndAll = [];% Create real populationChrom = crtrp(SUBPOP*NIND,FieldD);% reset count variablesgen = 0;% Calculate objective function for populationObjV = feval(OBJ_F,Chrom);% count number of objective function evaluationsBest(gen+1,3) = Best(gen+1,3) + NIND;% Generational loopwhile gen < MAXGEN,% Save the best and average objective values and the best individual[Best(gen+1,1),ix] = min(ObjV);Best(gen+1,2) = mean(ObjV);IndAll = [IndAll; Chrom(ix,:)];% Fitness assignment to whole populationFitnV = ranking(ObjV,2 ,SUBPOP);% Select individuals from populationSelCh = select(SEL_F, Chrom, FitnV, GGAP, SUBPOP);% Recombine selected individualsSelCh=recombin(XOV_F, SelCh, XOVR, SUBPOP);% Mutate offspringSelCh=mutate(MUT_F, SelCh, FieldD, [MUTR], SUBPOP);% Calculate objective function for offspringsObjVOff = feval(OBJ_F,SelCh);Best(gen+1,3) = Best(gen+1,3) + size(SelCh,1);% Insert best offspring in population replacing worst parents[Chrom, ObjV] = reins(Chrom, SelCh, SUBPOP, [1 INSR], ObjV, ObjVOff);gen=gen+1;% Plot some results, rename title of figure for graphic outputif ((rem(gen,20) == 1) | (rem(gen,MAXGEN) == 0)),set(gcf,'Name',[FigTitle ' in ' int2str(gen)]);resplot(Chrom(1:2:size(Chrom,1),:),...IndAll(max(1,gen-39):size(IndAll,1),:),...[ObjV; GlobalMin], Best(max(1,gen-19):gen,[1 2]), gen);end% migrate individuals between subpopulationsif (rem(gen,MIGGEN) == 0)[Chrom, ObjV] = migrate(Chrom, SUBPOP, [MIGR, 1, 0], ObjV);endend% Results% add number of objective function evaluationsResults = cumsum(Best(1:gen,3));% number of function evaluation, mean and best resultsResults = [Results Best(1:gen,2) Best(1:gen,1)];% Plot Results and show best individuals => optimumfigure('Name',['Results of ' FigTitle]);subplot(2,1,1), plot(Results(:,1),Results(:,2),'-',Results(:,1),Results(:,3),':');subplot(2,1,2), plot(IndAll(gen-4:gen,:)');% End of script
123version https://git-lfs.github.com/spec/v1oid sha256:f5deb82096f3db334fb30159caacc236ae351eeb99cac69a4b214ed2f88d4d80size 1609123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354% MUT.m%% This function takes the representation of the current population,% mutates each element with given probability and returns the resulting% population.%% Syntax: NewChrom = mut(OldChrom,Pm,BaseV)%% Input parameters:%% OldChrom - A matrix containing the chromosomes of the% current population. Each row corresponds to% an individuals string representation.%% Pm - Mutation probability (scalar). Default value% of Pm = 0.7/Lind, where Lind is the chromosome% length is assumed if omitted.%% BaseV - Optional row vector of the same length as the% chromosome structure defining the base of the% individual elements of the chromosome. Binary% representation is assumed if omitted.%% Output parameter:%% NewChrom - A Matrix containing a mutated version of% OldChrom.%% Author: Andrew Chipperfield% Date: 25-Jan-94function NewChrom = mut(OldChrom,Pm,BaseV)% get population size (Nind) and chromosome length (Lind)[Nind, Lind] = size(OldChrom) ;% check input parametersif nargin < 2, Pm = 0.7/Lind ; endif isnan(Pm), Pm = 0.7/Lind; endif (nargin < 3), BaseV = crtbase(Lind); endif (isnan(BaseV)), BaseV = crtbase(Lind); endif (isempty(BaseV)), BaseV = crtbase(Lind); endif (nargin == 3) & (Lind ~= length(BaseV))error('OldChrom and BaseV are incompatible'), end% create mutation mask matrixBaseM = BaseV(ones(Nind,1),:) ;% perform mutation on chromosome structureNewChrom = rem(OldChrom+(rand(Nind,Lind)<Pm).*ceil(rand(Nind,Lind).*(BaseM-1)),BaseM);
123version https://git-lfs.github.com/spec/v1oid sha256:86b6af2d4a9120aee7f8995d4f609b62cd22e5aecd90ea3e7d60a69cf3c19c8bsize 343712345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182% MUTATE.M (MUTATion high-level function)%% This function takes a matrix OldChrom containing the% representation of the individuals in the current population,% mutates the individuals and returns the resulting population.%% The function handles multiple populations and calls the low-level% mutation function for the actual mutation process.%% Syntax: NewChrom = mutate(MUT_F, OldChrom, FieldDR, MutOpt, SUBPOP)%% Input parameter:% MUT_F - String containing the name of the mutation function% OldChrom - Matrix containing the chromosomes of the old% population. Each line corresponds to one individual.% FieldDR - Matrix describing the boundaries of each variable% (real-values) or defining the base of the variables of% each individual (discrete values).% optional for (binary) discrete values% MutOpt - (optional) Vector containing mutation rate and shrink value% if omitted or NaN, MutOpt = NaN is assumed% MutOpt(1): MutR - number containing the mutation rate -% probability for mutation of a variable% MutOpt(2): MutShrink - (optional) number for shrinking the% mutation range in the range [0, 1], possibility to% shrink the range of the mutation depending on,% for instance actual generation (only for% real-values).% SUBPOP - (optional) Number of subpopulations% if omitted or NaN, 1 subpopulation is assumed%% Output parameter:% NewChrom - Matrix containing the chromosomes of the population% after mutation in the same format as OldChrom.% Author: Hartmut Pohlheim% History: 19.03.94 file createdfunction NewChrom = mutate(MUT_F, OldChrom, FieldDR, MutOpt, SUBPOP);% Check parameter consistencyif nargin < 2, error('Not enough input parameter'); end% Identify the population size (Nind) and the number of variables (Nvar)[Nind,Nvar] = size(OldChrom);if nargin < 3, IsDiscret = 1; FieldDR = [];elseif isempty(FieldDR), IsDiscret = 1; FieldDR = [];elseif isnan(FieldDR), IsDiscret = 1; FieldDR = [];else[mF, nF] = size(FieldDR);if nF ~= Nvar, error('FieldDR and OldChrom disagree'); endif mF == 2, IsDiscret = 0;elseif mF == 1, IsDiscret = 1;else error('FieldDR must be a matrix with 1 or 2 rows'); endendif nargin < 4, MutOpt = NaN; endif nargin < 5, SUBPOP = 1;elseif nargin > 4,if isempty(SUBPOP), SUBPOP = 1;elseif isnan(SUBPOP), SUBPOP = 1;elseif length(SUBPOP) ~= 1, error('SUBPOP must be a scalar'); endendif (Nind/SUBPOP) ~= fix(Nind/SUBPOP), error('OldChrom and SUBPOP disagree'); endNind = Nind/SUBPOP; % Compute number of individuals per subpopulation% Select individuals of one subpopulation and call low level functionNewChrom = [];for irun = 1:SUBPOP,ChromSub = OldChrom((irun-1)*Nind+1:irun*Nind,:);if IsDiscret == 1, NewChromSub = feval(MUT_F, ChromSub, MutOpt, FieldDR);elseif IsDiscret == 0, NewChromSub = feval(MUT_F, ChromSub, FieldDR, MutOpt); endNewChrom=[NewChrom; NewChromSub];end% End of function
123version https://git-lfs.github.com/spec/v1oid sha256:b9fe17257bc5a3c5ee901553861c8a13ca51711984d5e24a9dc8d76b391ddf53size 4943123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113% MUTBGA.M (real-value MUTation like Breeder Genetic Algorithm)%% This function takes a matrix OldChrom containing the real% representation of the individuals in the current population,% mutates the individuals with probability MutR and returns% the resulting population.%% This function implements the mutation operator of the Breeder Genetic% Algorithm. (Muehlenbein et. al.)%% Syntax: NewChrom = mutbga(OldChrom, FieldDR, MutOpt)%% Input parameter:% OldChrom - Matrix containing the chromosomes of the old% population. Each line corresponds to one individual.% FieldDR - Matrix describing the boundaries of each variable.% MutOpt - (optional) Vector containing mutation rate and shrink value% MutOpt(1): MutR - number containing the mutation rate -% probability for mutation of a variable% if omitted or NaN, MutR = 1/variables per individual% is assumed% MutOpt(2): MutShrink - (optional) number for shrinking the% mutation range in the range [0 1], possibility to% shrink the range of the mutation depending on,% for instance actual generation.% if omitted or NaN, MutShrink = 1 is assumed%% Output parameter:% NewChrom - Matrix containing the chromosomes of the population% after mutation in the same format as OldChrom.% Author: Hartmut Pohlheim% History: 23.11.93 file created% 24.11.93 function optimised (for,for-loop to for-loop)% mutation rate included% style improved% 06.12.93 change of function name% check of boundaries after mutation out of loop% 16.12.93 NewMutMat and OldMutMat included for compability% 16.02.94 preparation for multi-subpopulations at once% 25.02.94 NewMutMat and OldMutMat removed (now in mutran10.m)% clean up% change of function name in mutbga.m% 03.03.94 Lower and Upper directly used (less memory)% 19.03.94 multipopulation support removed% more parameter checks% 27.03.94 Delta exact calculated, for loop savedfunction NewChrom = mutbga(OldChrom, FieldDR, MutOpt);% Check parameter consistencyif nargin < 2, error('Not enough input parameter'); end% Identify the population size (Nind) and the number of variables (Nvar)[Nind,Nvar] = size(OldChrom);[mF, nF] = size(FieldDR);if mF ~= 2, error('FieldDR must be a matrix with 2 rows'); endif Nvar ~= nF, error('FieldDR and OldChrom disagree'); endif nargin < 3, MutR = 1/Nvar; MutShrink = 1;elseif isempty(MutOpt), MutR = 1/Nvar; MutShrink = 1;elseif isnan(MutOpt), MutR = 1/Nvar; MutShrink = 1;elseif length(MutOpt) == 1, MutR = MutOpt; MutShrink = 1;elseif length(MutOpt) == 2, MutR = MutOpt(1); MutShrink = MutOpt(2);else, error(' Too many parameter in MutOpt'); endendif isempty(MutR), MutR = 1/Nvar;elseif isnan(MutR), MutR = 1/Nvar;elseif length(MutR) ~= 1, error('Parameter for mutation rate must be a scalar');elseif (MutR < 0 | MutR > 1), error('Parameter for mutation rate must be a scalar in [0, 1]'); endif isempty(MutShrink), MutShrink = 1;elseif isnan(MutShrink), MutShrink = 1;elseif length(MutShrink) ~= 1, error('Parameter for shrinking mutation range must be a scalar');elseif (MutShrink < 0 | MutShrink > 1),error('Parameter for shrinking mutation range must be a scalar in [0, 1]');end% the variables are mutated with probability MutR% NewChrom = OldChrom (+ or -) * Range * MutShrink * Delta% Range = 0.5 * (upperbound - lowerbound)% Delta = Sum(Alpha_i * 2^-i) from 0 to ACCUR; Alpha_i = rand(ACCUR,1) < 1/ACCUR% Matrix with range values for every variableRange = rep(0.5 * MutShrink *(FieldDR(2,:)-FieldDR(1,:)),[Nind 1]);% zeros and ones for mutate or not this variable, together with RangeRange = Range .* (rand(Nind,Nvar) < MutR);% compute, if + or - signRange = Range .* (1 - 2 * (rand(Nind,Nvar) < 0.5));% used for later computing, here only ones computedACCUR = 20;Vect = 2 .^ (-(0:(ACCUR-1))');Delta = (rand(Nind,ACCUR) < 1/ACCUR) * Vect;Delta = rep(Delta, [1 Nvar]);% perform mutationNewChrom = OldChrom + Range .* Delta;% Ensure variables boundaries, compare with lower and upper boundariesNewChrom = max(rep(FieldDR(1,:),[Nind 1]), NewChrom);NewChrom = min(rep(FieldDR(2,:),[Nind 1]), NewChrom);% End of function
123version https://git-lfs.github.com/spec/v1oid sha256:95863e65c0113af3f1400e6d4fbb0c3d376e840e9330202a38bf19551bb6ea9esize 26291234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071% OBJFUN1.M (OBJective function for De Jong's FUNction 1)%% This function implements the De Jong function 1.%% Syntax: ObjVal = objfun1(Chrom,switch)%% Input parameters:% Chrom - Matrix containing the chromosomes of the current% population. Each row corresponds to one individual's% string representation.% if Chrom == [], then special values will be returned% switch - if Chrom == [] and% switch == 1 (or []) return boundaries% switch == 2 return title% switch == 3 return value of global minimum%% Output parameters:% ObjVal - Column vector containing the objective values of the% individuals in the current population.% if called with Chrom == [], then ObjVal contains% switch == 1, matrix with the boundaries of the function% switch == 2, text for the title of the graphic output% switch == 3, value of global minimum%% Author: Hartmut Pohlheim% History: 26.11.93 file created% 27.11.93 text of title and switch added% 30.11.93 show Dim in figure title% 16.12.93 switch == 3, return value of global minimum% 01.03.94 name changed in obj*function ObjVal = objfun1(Chrom,switch);% Dimension of objective functionDim = 20;% Compute population parameters[Nind,Nvar] = size(Chrom);% Check size of Chrom and do the appropriate thing% if Chrom is [], then define size of boundary-matrix and valuesif Nind == 0% return text of title for graphic outputif switch == 2ObjVal = ['DE JONG function 1-' int2str(Dim)];% return value of global minimumelseif switch == 3ObjVal = 0;% define size of boundary-matrix and valueselse% lower and upper bound, identical for all n variablesObjVal = 100*[-5.12; 5.12];ObjVal = ObjVal(1:2,ones(Dim,1));end% if Dim variables, compute values of functionelseif Nvar == Dim% function 1, sum of xi^2 for i = 1:Dim (Dim=30)% n = Dim, -5.12 <= xi <= 5.12% global minimum at (xi)=(0) ; fmin=0ObjVal = sum((Chrom .* Chrom)')';% ObjVal = diag(Chrom * Chrom'); % both lines produce the same% otherwise error, wrong format of Chromelseerror('size of matrix Chrom is not correct for function evaluation');end% End of function
123version https://git-lfs.github.com/spec/v1oid sha256:a6208b888f3af5f91cd4717815f2702f3eba5edc0e9ef1fd36a98ae33d1ea36fsize 2559123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778% OBJHARV.M (OBJective function for HARVest problem)%% This function implements the HARVEST PROBLEM.%% Syntax: ObjVal = objharv(Chrom,switch)%% Input parameters:% Chrom - Matrix containing the chromosomes of the current% population. Each row corresponds to one individual's% string representation.% if Chrom == [], then special values will be returned% switch - if Chrom == [] and% switch == 1 (or []) return boundaries% switch == 2 return title% switch == 3 return value of global minimum%% Output parameters:% ObjVal - Column vector containing the objective values of the% individuals in the current population.% if called with Chrom == [], then ObjVal contains% switch == 1, matrix with the boundaries of the function% switch == 2, text for the title of the graphic output% switch == 3, value of global minimum%% Author: Hartmut Pohlheim% History: 18.02.94 file created (copy of vallinq.m)% 01.03.94 name changed in obj*function ObjVal = objharv(Chrom,switch);% global gen;% Dimension of objective functionDim = 20;% values from MICHALEWICZa = 1.1;x0 = 100;xend = x0;XENDWEIGHT = 0.4/(Dim^0.6);% Compute population parameters[Nind,Nvar] = size(Chrom);% Check size of Chrom and do the appropriate thing% if Chrom is [], then define size of boundary-matrix and valuesif Nind == 0% return text of title for graphic outputif switch == 2ObjVal = ['HARVEST PROBLEM-' int2str(Dim)];% return value of global minimumelseif switch == 3ObjVal = -sqrt(x0*(a^Dim-1)^2/(a^(Dim-1)*(a-1)));% define size of boundary-matrix and valueselse% lower and upper bound, identical for all n variablesObjVal1 = [0; 10*Dim];ObjVal = rep(ObjVal1,[1 Dim]);end% if Dim variables, compute values of functionelseif Nvar == DimObjVal = zeros(Nind,1);X = rep(x0,[Nind 1]);for irun = 1:Nvar,X = a*X - Chrom(:,irun);endX;ObjVal = -(sum(sqrt(Chrom)')' - XENDWEIGHT * abs(X-x0));% otherwise error, wrong format of Chromelseerror('size of matrix Chrom is not correct for function evaluation');end% End of function
123version https://git-lfs.github.com/spec/v1oid sha256:90523e59f9863d00812e95c0952b04e2064d7e08ca14dfa3830770cf580bb0bbsize 4709123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125% RANKING.M (RANK-based fitness assignment)%% This function performs ranking of individuals.%% Syntax: FitnV = ranking(ObjV, RFun, SUBPOP)%% This function ranks individuals represented by their associated% cost, to be *minimized*, and returns a column vector FitnV% containing the corresponding individual fitnesses. For multiple% subpopulations the ranking is performed separately for each% subpopulation.%% Input parameters:% ObjV - Column vector containing the objective values of the% individuals in the current population (cost values).% RFun - (optional) If RFun is a scalar in [1, 2] linear ranking is% assumed and the scalar indicates the selective pressure.% If RFun is a 2 element vector:% RFun(1): SP - scalar indicating the selective pressure% RFun(2): RM - ranking method% RM = 0: linear ranking% RM = 1: non-linear ranking% If RFun is a vector with length(Rfun) > 2 it contains% the fitness to be assigned to each rank. It should have% the same length as ObjV. Usually RFun is monotonously% increasing.% If RFun is omitted or NaN, linear ranking% and a selective pressure of 2 are assumed.% SUBPOP - (optional) Number of subpopulations% if omitted or NaN, 1 subpopulation is assumed%% Output parameters:% FitnV - Column vector containing the fitness values of the% individuals in the current population.%% Author: Hartmut Pohlheim (Carlos Fonseca)% History: 01.03.94 non-linear ranking% 10.03.94 multiple populationsfunction FitnV = ranking(ObjV, RFun, SUBPOP);% Identify the vector size (Nind)[Nind,ans] = size(ObjV);if nargin < 2, RFun = []; endif nargin > 1, if isnan(RFun), RFun = []; end, endif prod(size(RFun)) == 2,if RFun(2) == 1, NonLin = 1;elseif RFun(2) == 0, NonLin = 0;else error('Parameter for ranking method must be 0 or 1'); endRFun = RFun(1);if isnan(RFun), RFun = 2; endelseif prod(size(RFun)) > 2,if prod(size(RFun)) ~= Nind, error('ObjV and RFun disagree'); endendif nargin < 3, SUBPOP = 1; endif nargin > 2,if isempty(SUBPOP), SUBPOP = 1;elseif isnan(SUBPOP), SUBPOP = 1;elseif length(SUBPOP) ~= 1, error('SUBPOP must be a scalar'); endendif (Nind/SUBPOP) ~= fix(Nind/SUBPOP), error('ObjV and SUBPOP disagree'); endNind = Nind/SUBPOP; % Compute number of individuals per subpopulation% Check ranking function and use default values if necessaryif isempty(RFun),% linear ranking with selective pressure 2RFun = 2*[0:Nind-1]'/(Nind-1);elseif prod(size(RFun)) == 1if NonLin == 1,% non-linear rankingif RFun(1) < 1, error('Selective pressure must be greater than 1');elseif RFun(1) > Nind-2, error('Selective pressure too big'); endRoot1 = roots([RFun(1)-Nind [RFun(1)*ones(1,Nind-1)]]);RFun = (abs(Root1(1)) * ones(Nind,1)) .^ [(0:Nind-1)'];RFun = RFun / sum(RFun) * Nind;else% linear ranking with SP between 1 and 2if (RFun(1) < 1 | RFun(1) > 2),error('Selective pressure for linear ranking must be between 1 and 2');endRFun = 2-RFun + 2*(RFun-1)*[0:Nind-1]'/(Nind-1);endend;FitnV = [];% loop over all subpopulationsfor irun = 1:SUBPOP,% Copy objective values of actual subpopulationObjVSub = ObjV((irun-1)*Nind+1:irun*Nind);% Sort does not handle NaN values as required. So, find those...NaNix = isnan(ObjVSub);Validix = find(~NaNix);% ... and sort only numeric values (smaller is better).[ans,ix] = sort(-ObjVSub(Validix));% Now build indexing vector assuming NaN are worse than numbers,% (including Inf!)...ix = [find(NaNix) ; Validix(ix)];% ... and obtain a sorted version of ObjVSorted = ObjVSub(ix);% Assign fitness according to RFun.i = 1;FitnVSub = zeros(Nind,1);for j = [find(Sorted(1:Nind-1) ~= Sorted(2:Nind)); Nind]',FitnVSub(i:j) = sum(RFun(i:j)) * ones(j-i+1,1) / (j-i+1);i =j+1;end% Finally, return unsorted vector.[ans,uix] = sort(ix);FitnVSub = FitnVSub(uix);% Add FitnVSub to FitnVFitnV = [FitnV; FitnVSub];end% End of function
123version https://git-lfs.github.com/spec/v1oid sha256:3509a126379548e879abb7f9eec4abb67786958f23516a46bc0ea71a44354d0dsize 182512345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152% RECDIS.M (RECombination DIScrete)%% This function performs discret recombination between pairs of individuals% and returns the new individuals after mating.%% Syntax: NewChrom = recdis(OldChrom, XOVR)%% Input parameters:% OldChrom - Matrix containing the chromosomes of the old% population. Each line corresponds to one individual% (in any form, not necessarily real-values).% XOVR - Probability of recombination occurring between pairs% of individuals. (not used, only for compatibility)%% Output parameter:% NewChrom - Matrix containing the chromosomes of the population% after mating, ready to be mutated and/or evaluated,% in the same format as OldChrom.% Author: Hartmut Pohlheim% History: 23.11.93 file created% 24.11.93 style improved% 06.12.93 change of name of function% 25.02.94 clean up% 19.03.94 multipopulation support removedfunction NewChrom = recdis(OldChrom, XOVR);% Identify the population size (Nind) and the number of variables (Nvar)[Nind,Nvar] = size(OldChrom);% Identify the number of matingsXops = floor(Nind/2);% which parent gives the valueMask1 = (rand(Xops,Nvar)<0.5);Mask2 = (rand(Xops,Nvar)<0.5);% Performs crossoverodd = 1:2:Nind-1;even= 2:2:Nind;NewChrom(odd,:) = (OldChrom(odd,:).* Mask1) + (OldChrom(even,:).*(~Mask1));NewChrom(even,:) = (OldChrom(odd,:).* Mask2) + (OldChrom(even,:).*(~Mask2));% If the number of individuals is odd, the last individual cannot be mated% but must be included in the new populationif rem(Nind,2), NewChrom(Nind,:)=OldChrom(Nind,:); end% End of function
123version https://git-lfs.github.com/spec/v1oid sha256:f28039ff4addb00e9527bb5c81eb6c73fdf542b9ebe15a9b929cca771cf5cd0bsize 189512345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455% RECINT.M (RECombination extended INTermediate)%% This function performs extended intermediate recombination between% pairs of individuals and returns the new individuals after mating.%% Syntax: NewChrom = recint(OldChrom, XOVR)%% Input parameters:% OldChrom - Matrix containing the chromosomes of the old% population. Each line corresponds to one% individual% XOVR - Probability of crossover occurring between pairs% of individuals. (not used, only for compatibility)%% Output parameter:% NewChrom - Matrix containing the chromosomes of the population% after mating, ready to be mutated and/or evaluated,% in the same format as OldChrom.% Author: Hartmut Pohlheim% History: 25.11.93 file created% 06.12.93 change of name of function% 25.02.94 clean up% 19.03.94 multipopulation support removedfunction NewChrom = recint(OldChrom, XOVR);% Identify the population size (Nind) and the number of variables (Nvar)[Nind,Nvar] = size(OldChrom);% Identify the number of matingsXops = floor(Nind/2);% Performs recombinationodd = 1:2:Nind-1;even= 2:2:Nind;% position of value of offspring compared to parentsAlpha = -0.25 + 1.5 * rand(Xops,Nvar);% recombinationNewChrom(odd,:) = OldChrom(odd,:) + Alpha .* (OldChrom(even,:) - OldChrom(odd,:));% the same ones more for second half of offspringAlpha = -0.25 + 1.5 * rand(Xops,Nvar);NewChrom(even,:) = OldChrom(odd,:) + Alpha .* (OldChrom(even,:) - OldChrom(odd,:));% If the number of individuals is odd, the last individual cannot be mated% but must be included in the new populationif rem(Nind,2), NewChrom(Nind,:)=OldChrom(Nind,:); end% End of function
123version https://git-lfs.github.com/spec/v1oid sha256:34f0a46f19e514e77b173b8841a91e686cef0a5f864c3dff6725cb4ab59ff861size 1953123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657% RECLIN.M (RECombination extended LINe)%% This function performs extended line recombination between% pairs of individuals and returns the new individuals after mating.%% Syntax: NewChrom = reclin(OldChrom, XOVR)%% Input parameters:% OldChrom - Matrix containing the chromosomes of the old% population. Each line corresponds to one% individual% XOVR - Probability of crossover occurring between pairs% of individuals. (not used, only for compatibility)%% Output parameter:% NewChrom - Matrix containing the chromosomes of the population% after mating, ready to be mutated and/or evaluated,% in the same format as OldChrom.% Author: Hartmut Pohlheim% History: 26.11.93 file created% 06.12.93 change of name of function% 25.02.94 clean up% 19.03.94 multipopulation support removedfunction NewChrom = reclin(OldChrom, XOVR);% Identify the population size (Nind) and the number of variables (Nvar)[Nind,Nvar] = size(OldChrom);% Identify the number of matingsXops = floor(Nind/2);% Performs recombinationodd = 1:2:Nind-1;even= 2:2:Nind;% position of value of offspring compared to parentsAlpha = -0.25 + 1.5 * rand(Xops,1);Alpha = Alpha(1:Xops,ones(Nvar,1));% recombinationNewChrom(odd,:) = OldChrom(odd,:) + Alpha .* (OldChrom(even,:) - OldChrom(odd,:));% the same ones more for second half of offspringAlpha = -0.25 + 1.5 * rand(Xops,1);Alpha = Alpha(1:Xops,ones(Nvar,1));NewChrom(even,:) = OldChrom(odd,:) + Alpha .* (OldChrom(even,:) - OldChrom(odd,:));% If the number of individuals is odd, the last individual cannot be mated% but must be included in the new populationif rem(Nind,2), NewChrom(Nind,:)=OldChrom(Nind,:); end% End of function
123version https://git-lfs.github.com/spec/v1oid sha256:1dba80855d9d825d038f939d30b7cddb249dc460ae0b449d0cf6cb9f6a4bc738size 4852123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118% RECLIN.M (line RECombination with MUTation features)%% This function performs line recombination with mutation features between% pairs of individuals and returns the new individuals after mating.%% Syntax: NewChrom = recmut(OldChrom, FieldDR, MutOpt)%% Input parameters:% OldChrom - Matrix containing the chromosomes of the old% population. Each line corresponds to one individual% FieldDR - Matrix describing the boundaries of each variable.% MutOpt - (optional) Vector containing recombination rate and shrink value% MutOpt(1): MutR - number containing the recombination rate -% probability for recombine a pair of parents% if omitted or NaN, MutOpt(1) = 1 is assumed% MutOpt(2): MutShrink - (optional) number for shrinking the% recombination range in the range [0 1], possibility to% shrink the range of the recombination depending on,% for instance actual generation.% if omitted or NaN, MutOpt(2) = 1 is assumed%% Output parameter:% NewChrom - Matrix containing the chromosomes of the population% after mating, ready to be mutated and/or evaluated,% in the same format as OldChrom.% Author: Hartmut Pohlheim% History: 27.03.94 file createdfunction NewChrom = recmut(OldChrom, FieldDR, MutOpt);% Check parameter consistencyif nargin < 2, error('Not enough input parameter'); end% Identify the population size (Nind) and the number of variables (Nvar)[Nind,Nvar] = size(OldChrom);[mF, nF] = size(FieldDR);if mF ~= 2, error('FieldDR must be a matrix with 2 rows'); endif Nvar ~= nF, error('FieldDR and OldChrom disagree'); endif nargin < 3, MutR = 1; MutShrink = 1;elseif isempty(MutOpt), MutR = 1; MutShrink = 1;elseif isnan(MutOpt), MutR = 1; MutShrink = 1;elseif length(MutOpt) == 1, MutR = MutOpt; MutShrink = 1;elseif length(MutOpt) == 2, MutR = MutOpt(1); MutShrink = MutOpt(2);else, error(' Too many parameter in MutOpt'); endendif isempty(MutR), MutR = 1;elseif isnan(MutR), MutR = 1;elseif length(MutR) ~= 1, error('Parameter for recombination rate must be a scalar');elseif (MutR < 0 | MutR > 1), error('Parameter for recombination rate must be a scalar in [0, 1]'); endif isempty(MutShrink), MutShrink = 1;elseif isnan(MutShrink), MutShrink = 1;elseif length(MutShrink) ~= 1, error('Parameter for shrinking recombination range must be a scalar');elseif (MutShrink < 0 | MutShrink > 1),error('Parameter for shrinking recombination range must be a scalar in [0, 1]');end% Identify the number of matingsXops = floor(Nind/2);% NewChrom = OldChrom (+ or -) * Range * MutShrink * Delta * ChromDiff% - with probability 0.9, + with probability 0.1% Range = 0.5 * (upperbound - lowerbound), given by FieldDR% Delta = Sum(Alpha_i * 2^-i) from 0 to ACCUR; Alpha_i = rand(ACCUR,1) < 1/ACCUR% ChromDiff = (individual1 - individual2) / Distance between individuals% Matrix with range values for every variableRange = rep(0.5 * MutShrink *(FieldDR(2,:)-FieldDR(1,:)),[Xops 1]);% zeros and ones for recombine or not this variable, together with Rangeif MutR < 1, Range = Range .* rep((rand(Xops,1) < MutR), [1 Nvar]); end% compute, if + or - signRange = Range .* (1 - 2 * (rand(Xops,Nvar) < 0.9));% compute distance between mating pairsNormO = zeros(Xops,1);for irun = 1:Xops,NormO(irun) = max(realmin,abs(norm(OldChrom(2*irun,:)) - norm(OldChrom(2*irun-1,:))));end% compute difference between variables divided by distanceChromDiff = zeros(Xops,Nvar);for irun = 1:XopsChromDiff(irun,:) = diff([OldChrom(2*irun-1,:); OldChrom(2*irun,:)]) / NormO(irun);end% compute delta value for all individualsACCUR = 20;Vect = 2 .^ (-(0:(ACCUR-1))');Delta = (rand(Xops,ACCUR) < 1/ACCUR) * Vect;Delta = rep(Delta, [1 Nvar]);% Performs recombinationodd = 1:2:Nind-1;even= 2:2:Nind;% recombinationNewChrom(odd,:) = OldChrom(odd,:) + Range .* Delta .* (ChromDiff);NewChrom(even,:) = OldChrom(even,:) + Range .* Delta .* (-ChromDiff);% If the number of individuals is odd, the last individual cannot be mated% but must be included in the new populationif rem(Nind,2), NewChrom(Nind,:)=OldChrom(Nind,:); end% Ensure variables boundaries, compare with lower and upper boundariesNewChrom = max(rep(FieldDR(1,:),[Nind 1]), NewChrom);NewChrom = min(rep(FieldDR(2,:),[Nind 1]), NewChrom);% End of function
123version https://git-lfs.github.com/spec/v1oid sha256:1beb08befa03089753f61e6daa8117587823cc59d2e0949e5f78fc4cfa2db767size 2438123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869% RECOMBIN.M (RECOMBINation high-level function)%% This function performs recombination between pairs of individuals% and returns the new individuals after mating. The function handles% multiple populations and calls the low-level recombination function% for the actual recombination process.%% Syntax: NewChrom = recombin(REC_F, OldChrom, RecOpt, SUBPOP)%% Input parameters:% REC_F - String containing the name of the recombination or% crossover function% Chrom - Matrix containing the chromosomes of the old% population. Each line corresponds to one individual% RecOpt - (optional) Scalar containing the probability of% recombination/crossover occurring between pairs% of individuals.% if omitted or NaN, 1 is assumed% SUBPOP - (optional) Number of subpopulations% if omitted or NaN, 1 subpopulation is assumed%% Output parameter:% NewChrom - Matrix containing the chromosomes of the population% after recombination in the same format as OldChrom.% Author: Hartmut Pohlheim% History: 18.03.94 file createdfunction NewChrom = recombin(REC_F, Chrom, RecOpt, SUBPOP);% Check parameter consistencyif nargin < 2, error('Not enough input parameter'); end% Identify the population size (Nind)[Nind,Nvar] = size(Chrom);if nargin < 4, SUBPOP = 1; endif nargin > 3,if isempty(SUBPOP), SUBPOP = 1;elseif isnan(SUBPOP), SUBPOP = 1;elseif length(SUBPOP) ~= 1, error('SUBPOP must be a scalar'); endendif (Nind/SUBPOP) ~= fix(Nind/SUBPOP), error('Chrom and SUBPOP disagree'); endNind = Nind/SUBPOP; % Compute number of individuals per subpopulationif nargin < 3, RecOpt = 0.7; endif nargin > 2,if isempty(RecOpt), RecOpt = 0.7;elseif isnan(RecOpt), RecOpt = 0.7;elseif length(RecOpt) ~= 1, error('RecOpt must be a scalar');elseif (RecOpt < 0 | RecOpt > 1), error('RecOpt must be a scalar in [0, 1]'); endend% Select individuals of one subpopulation and call low level functionNewChrom = [];for irun = 1:SUBPOP,ChromSub = Chrom((irun-1)*Nind+1:irun*Nind,:);NewChromSub = feval(REC_F, ChromSub, RecOpt);NewChrom=[NewChrom; NewChromSub];end% End of function
123version https://git-lfs.github.com/spec/v1oid sha256:3f260e5b26029fd5b658901251e50c7c6c66ec858682f07c14ad986a44fda98dsize 5574123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123% REINS.M (RE-INSertion of offspring in population replacing parents)%% This function reinserts offspring in the population.%% Syntax: [Chrom, ObjVCh] = reins(Chrom, SelCh, SUBPOP, InsOpt, ObjVCh, ObjVSel)%% Input parameters:% Chrom - Matrix containing the individuals (parents) of the current% population. Each row corresponds to one individual.% SelCh - Matrix containing the offspring of the current% population. Each row corresponds to one individual.% SUBPOP - (optional) Number of subpopulations% if omitted or NaN, 1 subpopulation is assumed% InsOpt - (optional) Vector containing the insertion method parameters% ExOpt(1): Select - number indicating kind of insertion% 0 - uniform insertion% 1 - fitness-based insertion% if omitted or NaN, 0 is assumed% ExOpt(2): INSR - Rate of offspring to be inserted per% subpopulation (% of subpopulation)% if omitted or NaN, 1.0 (100%) is assumed% ObjVCh - (optional) Column vector containing the objective values% of the individuals (parents - Chrom) in the current% population, needed for fitness-based insertion% saves recalculation of objective values for population% ObjVSel - (optional) Column vector containing the objective values% of the offspring (SelCh) in the current population, needed for% partial insertion of offspring,% saves recalculation of objective values for population%% Output parameters:% Chrom - Matrix containing the individuals of the current% population after reinsertion.% ObjVCh - if ObjVCh and ObjVSel are input parameter, than column% vector containing the objective values of the individuals% of the current generation after reinsertion.% Author: Hartmut Pohlheim% History: 10.03.94 file created% 19.03.94 parameter checking improvedfunction [Chrom, ObjVCh] = reins(Chrom, SelCh, SUBPOP, InsOpt, ObjVCh, ObjVSel);% Check parameter consistencyif nargin < 2, error('Not enough input parameter'); endif (nargout == 2 & nargin < 6), error('Input parameter missing: ObjVCh and/or ObjVSel'); end[NindP, NvarP] = size(Chrom);[NindO, NvarO] = size(SelCh);if nargin == 2, SUBPOP = 1; endif nargin > 2,if isempty(SUBPOP), SUBPOP = 1;elseif isnan(SUBPOP), SUBPOP = 1;elseif length(SUBPOP) ~= 1, error('SUBPOP must be a scalar'); endendif (NindP/SUBPOP) ~= fix(NindP/SUBPOP), error('Chrom and SUBPOP disagree'); endif (NindO/SUBPOP) ~= fix(NindO/SUBPOP), error('SelCh and SUBPOP disagree'); endNIND = NindP/SUBPOP; % Compute number of individuals per subpopulationNSEL = NindO/SUBPOP; % Compute number of offspring per subpopulationIsObjVCh = 0; IsObjVSel = 0;if nargin > 4,[mO, nO] = size(ObjVCh);if nO ~= 1, error('ObjVCh must be a column vector'); endif NindP ~= mO, error('Chrom and ObjVCh disagree'); endIsObjVCh = 1;endif nargin > 5,[mO, nO] = size(ObjVSel);if nO ~= 1, error('ObjVSel must be a column vector'); endif NindO ~= mO, error('SelCh and ObjVSel disagree'); endIsObjVSel = 1;endif nargin < 4, INSR = 1.0; Select = 0; endif nargin >= 4,if isempty(InsOpt), INSR = 1.0; Select = 0;elseif isnan(InsOpt), INSR = 1.0; Select = 0;elseINSR = NaN; Select = NaN;if (length(InsOpt) > 2), error('Parameter InsOpt too long'); endif (length(InsOpt) >= 1), Select = InsOpt(1); endif (length(InsOpt) >= 2), INSR = InsOpt(2); endif isnan(Select), Select = 0; endif isnan(INSR), INSR =1.0; endendendif (INSR < 0 | INSR > 1), error('Parameter for insertion rate must be a scalar in [0, 1]'); endif (INSR < 1 & IsObjVSel ~= 1), error('For selection of offspring ObjVSel is needed'); endif (Select ~= 0 & Select ~= 1), error('Parameter for selection method must be 0 or 1'); endif (Select == 1 & IsObjVCh == 0), error('ObjVCh for fitness-based exchange needed'); endif INSR == 0, return; endNIns = min(max(floor(INSR*NSEL+.5),1),NIND); % Number of offspring to insert% perform insertion for each subpopulationfor irun = 1:SUBPOP,% Calculate positions in old subpopulation, where offspring are insertedif Select == 1, % fitness-based reinsertion[Dummy, ChIx] = sort(-ObjVCh((irun-1)*NIND+1:irun*NIND));else % uniform reinsertion[Dummy, ChIx] = sort(rand(NIND,1));endPopIx = ChIx((1:NIns)')+ (irun-1)*NIND;% Calculate position of Nins-% best offspringif (NIns < NSEL), % select best offspring[Dummy,OffIx] = sort(ObjVSel((irun-1)*NSEL+1:irun*NSEL));elseOffIx = (1:NIns)';endSelIx = OffIx((1:NIns)')+(irun-1)*NSEL;% Insert offspring in subpopulation -> new subpopulationChrom(PopIx,:) = SelCh(SelIx,:);if (IsObjVCh == 1 & IsObjVSel == 1), ObjVCh(PopIx) = ObjVSel(SelIx); endend% End of function
123version https://git-lfs.github.com/spec/v1oid sha256:78ec47d1d557452415eae600d8b8bfb01621fc1a319e1f8c8e62d45b887ef7c7size 120812345678910111213141516171819202122232425262728293031323334353637383940414243444546% REP.m Replicate a matrix%% This function replicates a matrix in both dimensions.%% Syntax: MatOut = rep(MatIn,REPN);%% Input parameters:% MatIn - Input Matrix (before replicating)%% REPN - Vector of 2 numbers, how many replications in each dimension% REPN(1): replicate vertically% REPN(2): replicate horizontally%% Example:%% MatIn = [1 2 3]% REPN = [1 2]: MatOut = [1 2 3 1 2 3]% REPN = [2 1]: MatOut = [1 2 3;% 1 2 3]% REPN = [3 2]: MatOut = [1 2 3 1 2 3;% 1 2 3 1 2 3;% 1 2 3 1 2 3]%% Output parameter:% MatOut - Output Matrix (after replicating)%% Author: Carlos Fonseca & Hartmut Pohlheim% History: 14.02.94 file createdfunction MatOut = rep(MatIn,REPN)% Get size of input matrix[N_D,N_L] = size(MatIn);% CalculateInd_D = rem(0:REPN(1)*N_D-1,N_D) + 1;Ind_L = rem(0:REPN(2)*N_L-1,N_L) + 1;% Create output matrixMatOut = MatIn(Ind_D,Ind_L);% End of function
123version https://git-lfs.github.com/spec/v1oid sha256:f1c65ba1bd79521d9bd0ce65a2a5381bed89e3e767071ca11c95dd781c637622size 20801234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556% RESPLOT.M (RESult PLOTing)%% This function plots some results during computation.%% Syntax: resplot(Chrom,IndAll,ObjV,Best,gen)%% Input parameters:% Chrom - Matrix containing the chromosomes of the current% population. Each line corresponds to one individual.% IndAll - Matrix containing the best individual (variables) of each% generation. Each line corresponds to one individual.% ObjV - Vector containing objective values of the current% generation% Best - Matrix containing the best and average Objective values of% each generation, [best value per generation,average value% per generation]% gen - Scalar containing the number of the current generation%% Output parameter:% no output parameter% Author: Hartmut Pohlheim% History: 27.11.93 file created% 29.11.93 decision, if plot or not deleted% yscale not log% 15.12.93 MutMatrix as parameter and plot added% 16.03.94 function cleaned, MutMatrix removed, IndAll addedfunction resplot(Chrom,IndAll,ObjV,Best,gen);% plot of best and mean value per generationsubplot(2,2,1), plot(Best);title('Best and mean objective value');xlabel('generation'), ylabel('objective value');% plot of best individuals in all generationssubplot(2,2,2), plot(IndAll);title(['Best individuals']);xlabel('generation'), ylabel('value of variable');% plot of variables of all individuals in current generationsubplot(2,2,3), plot(Chrom');title(['All individuals in gen ',num2str(gen)]);xlabel('number of variable'), ylabel('value of variable');% plot of all objective values in current generationsubplot(2,2,4), plot(ObjV,'y.');title(['All objective values']);xlabel('number of individual'), ylabel('objective value');drawnow;% End of function
123version https://git-lfs.github.com/spec/v1oid sha256:1b6fe643ae24bb2a32e135ec0f2d88a2b0b62fa7261b19b427315020161ce7e2size 109012345678910111213141516171819202122232425262728293031% RWS.m - Roulette Wheel Selection%% Syntax:% NewChrIx = rws(FitnV, Nsel)%% This function selects a given number of individuals Nsel from a% population. FitnV is a column vector containing the fitness% values of the individuals in the population.%% The function returns another column vector containing the% indexes of the new generation of chromosomes relative to the% original population matrix, shuffled. The new population, ready% for mating, can be obtained by calculating% OldChrom(NewChrIx, :).% Author: Carlos Fonseca, Updated: Andrew Chipperfield% Date: 04/10/93, Date: 27-Jan-94function NewChrIx = rws(FitnV,Nsel);% Identify the population size (Nind)[Nind,ans] = size(FitnV);% Perform Stochastic Sampling with Replacementcumfit = cumsum(FitnV);trials = cumfit(Nind) .* rand(Nsel, 1);Mf = cumfit(:, ones(1, Nsel));Mt = trials(:, ones(1, Nind))';[NewChrIx, ans] = find(Mt < Mf & ...[ zeros(1, Nsel); Mf(1:Nind-1, :) ] <= Mt);
123version https://git-lfs.github.com/spec/v1oid sha256:9f95050c5b2cedddd9606d27edcf0515f83f9b2fec85a1090d30180e24b0a09bsize 127012345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152% SCALING.m - linear fitness scaling%% This function implements a linear fitness scaling algorithm as described% by Goldberg in "Genetic Algorithms in Search, Optimization and Machine% Learning", Addison Wesley, 1989. It use is not recommended when fitness% functions produce negative results as the scaling will become unreliable.% It is included in this version of the GA Toolbox only for the sake of% completeness.%% Syntax: FitnV = scaling(ObjV, Smul)%% Input parameters:%% Objv - A vector containing the values of individuals% fitness.%% Smul - Optional scaling parameter (default 2).%% Output parameters:%% FitnV - A vector containing the individual fitnesses% for the current population.%%% Author: Andrew Chipperfield% Date: 24-Feb-94function FitnV = scaling( ObjV, Smul )if nargin == 1Smul = 2 ;end[Nind, Nobj] = size( ObjV ) ;Oave = sum( ObjV ) / Nind ;Omin = min( ObjV ) ;Omax = max( ObjV ) ;if (Omin > ( Smul * Oave - Omax ) / ( Smul - 1.0 ))delta = Omax - Oavea = ( Smul - 1.0 ) * Oave / deltab = Oave * ( Omax - Smul * Oave ) / deltaelsedelta = Oave - Omin ;a = Oave / delta ;b = -Omin * Oave / delta ;endFitnV = ObjV.*a + b ;
123version https://git-lfs.github.com/spec/v1oid sha256:93e9c1b839da6ecb637ea9004d21115ecb1084036ee1372172393ad8da6588besize 2401123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869% SELECT.M (universal SELECTion)%% This function performs universal selection. The function handles% multiple populations and calls the low level selection function% for the actual selection process.%% Syntax: SelCh = select(SEL_F, Chrom, FitnV, GGAP, SUBPOP)%% Input parameters:% SEL_F - Name of the selection function% Chrom - Matrix containing the individuals (parents) of the current% population. Each row corresponds to one individual.% FitnV - Column vector containing the fitness values of the% individuals in the population.% GGAP - (optional) Rate of individuals to be selected% if omitted 1.0 is assumed% SUBPOP - (optional) Number of subpopulations% if omitted 1 subpopulation is assumed%% Output parameters:% SelCh - Matrix containing the selected individuals.% Author: Hartmut Pohlheim% History: 10.03.94 file createdfunction SelCh = select(SEL_F, Chrom, FitnV, GGAP, SUBPOP);% Check parameter consistencyif nargin < 3, error('Not enough input parameter'); end% Identify the population size (Nind)[NindCh,Nvar] = size(Chrom);[NindF,VarF] = size(FitnV);if NindCh ~= NindF, error('Chrom and FitnV disagree'); endif VarF ~= 1, error('FitnV must be a column vector'); endif nargin < 5, SUBPOP = 1; endif nargin > 4,if isempty(SUBPOP), SUBPOP = 1;elseif isnan(SUBPOP), SUBPOP = 1;elseif length(SUBPOP) ~= 1, error('SUBPOP must be a scalar'); endendif (NindCh/SUBPOP) ~= fix(NindCh/SUBPOP), error('Chrom and SUBPOP disagree'); endNind = NindCh/SUBPOP; % Compute number of individuals per subpopulationif nargin < 4, GGAP = 1; endif nargin > 3,if isempty(GGAP), GGAP = 1;elseif isnan(GGAP), GGAP = 1;elseif length(GGAP) ~= 1, error('GGAP must be a scalar');elseif (GGAP < 0), error('GGAP must be a scalar bigger than 0'); endend% Compute number of new individuals (to select)NSel=max(floor(Nind*GGAP+.5),2);% Select individuals from populationSelCh = [];for irun = 1:SUBPOP,FitnVSub = FitnV((irun-1)*Nind+1:irun*Nind);ChrIx=feval(SEL_F, FitnVSub, NSel)+(irun-1)*Nind;SelCh=[SelCh; Chrom(ChrIx,:)];end% End of function
123version https://git-lfs.github.com/spec/v1oid sha256:ed469760636b72242f946ec8e3a852688c48ba5f6059ae2835a4fff3bda61b56size 2143123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869% sga%% This script implements the Simple Genetic Algorithm described% in the examples section of the GA Toolbox manual.%% Author: Andrew Chipperfield% History: 23-Mar-94 file createdNIND = 40; % Number of individuals per subpopulationsMAXGEN = 300; % maximum Number of generationsGGAP = .9; % Generation gap, how many new individuals are createdNVAR = 20; % Generation gap, how many new individuals are createdPRECI = 20; % Precision of binary representation% Build field descriptorFieldD = [rep([PRECI],[1, NVAR]); rep([-512;512],[1, NVAR]);...rep([1; 0; 1 ;1], [1, NVAR])];% Initialise populationChrom = crtbp(NIND, NVAR*PRECI);% Reset countersBest = NaN*ones(MAXGEN,1); % best in current populationgen = 0; % generational counter% Evaluate initial populationObjV = objfun1(bs2rv(Chrom,FieldD));% Track best individual and display convergenceBest(gen+1) = min(ObjV);plot(log10(Best),'ro');xlabel('generation'); ylabel('log10(f(x))');text(0.5,0.95,['Best = ', num2str(Best(gen+1))],'Units','normalized');drawnow;% Generational loopwhile gen < MAXGEN,% Assign fitness-value to entire populationFitnV = ranking(ObjV);% Select individuals for breedingSelCh = select('sus', Chrom, FitnV, GGAP);% Recombine selected individuals (crossover)SelCh = recombin('xovsp',SelCh,0.7);% Perform mutation on offspringSelCh = mut(SelCh);% Evaluate offspring, call objective functionObjVSel = objfun1(bs2rv(SelCh,FieldD));% Reinsert offspring into current population[Chrom ObjV]=reins(Chrom,SelCh,1,1,ObjV,ObjVSel);% Increment generational countergen = gen+1;% Update display and record current best individualBest(gen+1) = min(ObjV);plot(log10(Best),'ro'); xlabel('generation'); ylabel('log10(f(x))');text(0.5,0.95,['Best = ', num2str(Best(gen+1))],'Units','normalized');drawnow;end% End of GA
123version https://git-lfs.github.com/spec/v1oid sha256:2b10ad5906524d4e218787b0fb5d1f3c52c24cc66dc847d05fd714d0f0b01d9asize 13191234567891011121314151617181920212223242526272829303132333435363738394041% SUS.M (Stochastic Universal Sampling)%% This function performs selection with STOCHASTIC UNIVERSAL SAMPLING.%% Syntax: NewChrIx = sus(FitnV, Nsel)%% Input parameters:% FitnV - Column vector containing the fitness values of the% individuals in the population.% Nsel - number of individuals to be selected%% Output parameters:% NewChrIx - column vector containing the indexes of the selected% individuals relative to the original population, shuffled.% The new population, ready for mating, can be obtained% by calculating OldChrom(NewChrIx,:).% Author: Hartmut Pohlheim (Carlos Fonseca)% History: 12.12.93 file created% 22.02.94 clean up, commentsfunction NewChrIx = sus(FitnV,Nsel);% Identify the population size (Nind)[Nind,ans] = size(FitnV);% Perform stochastic universal samplingcumfit = cumsum(FitnV);trials = cumfit(Nind) / Nsel * (rand + (0:Nsel-1)');Mf = cumfit(:, ones(1, Nsel));Mt = trials(:, ones(1, Nind))';[NewChrIx, ans] = find(Mt < Mf & [ zeros(1, Nsel); Mf(1:Nind-1, :) ] <= Mt);% Shuffle new population[ans, shuf] = sort(rand(Nsel, 1));NewChrIx = NewChrIx(shuf);% End of function
123version https://git-lfs.github.com/spec/v1oid sha256:8c93f0a6c891265b64430b43ee597e54872267bde5189c2200cec9397548cb01size 5035123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118% DEMOGA1.M (DEMO of Genetic Algorithms 1)%% This function displays a number of figures. Select a number of these% figures with the mouse by click in the area of the shape. These% figure are the parents for the next generation. The offspring are% created by recombination and mutation. The user is the selector.%% The shape of the figures is defined by Points X- and Y-values each.% These points are ploted by patch(), each figure in a rectangle.% The X- and Y-values are the variables of a individual.%% Aim of this demo is, to "construct" a special figure, e.g. a square% or a star or ..., imagine, what you want and select appropriate.%% Parameters inside function for changing:% Num - Number of figures (4, 9, 16, 25, ...)% Points - Number of Points per figure (3, 4, 5...), 5 recommended% MAXGEN - Number of generations (more than 30 recommended)%% Syntax: demoga1();%% Input parameters:% no input parameter% Output parameter:% no output parameter% Author: Hartmut Pohlheim% History: 24.03.94 file createdfunction demoga1();Num = 16; % Number of figuresPoints = 6; % Number of points per figureMAXGEN = 30; % Number of generationsFieldDR = rep([0; 1], [1 Points]); % Fielddescription for mutation% Function needs as many rows as columns, every place has to be filledif sqrt(Num) ~= ceil(sqrt(Num)),error('sqrt(Num) must be an integer');endColRowNum = ceil(sqrt(Num)); % Number of columns and rowsShrink=Num/ColRowNum; % Value for shrinking of areaSelectNumber = ColRowNum; % Number of parents by selectionCols = 1:1:ColRowNum; % Index of individuals in first columnsRows = 1:ColRowNum:Num; % Index of individuals in first rowh = figure; % Open a new figure for outputaxes('Position',[0 0 1 1]); % Set axes to whole figureset(gca, 'xcolor',[0 0 0]); % Make X-Axis invisibleset(gca, 'ycolor',[0 0 0]); % Make Y-Axis invisibleaxis('ij'); % Position start in left-upper corneraxis(axis); % Freeze axesXStart = (Cols(1:ColRowNum-1)/Shrink); % Calculate X-start- and Y-endvalues of linesXLine1 = [XStart; XStart]; % between figuresYLine1 = [zeros(1,ColRowNum-1); ones(1,ColRowNum-1)]; % X-end- and Y-startvaluesXLine = [XLine1 YLine1]; YLine = [YLine1 XLine1]; % Assemble line vectorsMatX=rand(Points,Num); % Create X-values of figures at randomMatY=rand(Points,Num); % Create Y-values of figures at randomfor igen = 1:MAXGEN, % Loop over all generations% Recombine individualsMatXYOff = recombin('recint', [MatX MatY]',NaN, 2);% Mutate individualsMatXYOff = mutbga(MatXYOff, FieldDR, 1/Points);MatXYOff = MatXYOff'; % Invert matrix of individualsMatX = MatXYOff(:,1:Num); % Select X- and Y-valuesMatY = MatXYOff(:,size(MatXYOff,2)/2+1:size(MatXYOff,2)/2+Num);PolyMatX = MatX / Shrink; % Shrink X-values for fitting in small areaPolyMatY = MatY / Shrink; % Shrink Y-values for fitting in small area% Add a value to the X-value for placing individual in the appropriate columnfor irun = 1:ColRowNum-1,PolyMatX(:,Rows+irun)=PolyMatX(:,Rows+irun)+(irun)/Shrink;end% Add a value to the Y-value for placing individual in the appropriate rowfor irun = 1:ColRowNum-1,PolyMatY(:,Cols+(irun*ColRowNum))= ...PolyMatY(:,Cols+(irun*ColRowNum))+(irun)/Shrink;endcla; % Clear axes, removes all earlier figurespatch(PolyMatX,PolyMatY,'b'); % Plot shape of figureslh = line(XLine, YLine); % Plot lines between figuresset(lh,'Color',[.6 .6 .6]); % Set linecolor to greyxclick = []; yclick = []; % Reset vectors for storing click pointsfor isel = 1:SelectNumber, % Loop for as many points as individuals to selectset(gcf,'Name',[ ' Select ' int2str(isel) '. figure (of ' ...int2str(SelectNumber) ') with mouseclick (Generation ' ...int2str(igen) ' of ' int2str(MAXGEN) ')']);[xclick1 yclick1] = ginput(1); % get position of mouse clickxclick = [xclick; xclick1]; yclick = [yclick; yclick1]; % add position to vectorsendxpos = ceil(xclick * Shrink); % Calculate column of mouse clickypos = ceil(yclick * Shrink); % Calculate row of mouse clickSelNumber = xpos + ColRowNum * (ypos-1); % Calculate numbers of selected figures% select X- and Y-values of individuals and repeat themMatX = rep(MatX(:,SelNumber),[1 ceil(Num/SelectNumber)]);MatY = rep(MatY(:,SelNumber),[1 ceil(Num/SelectNumber)]);end% End of function
123version https://git-lfs.github.com/spec/v1oid sha256:c2f727ca711d45d9d3092595193ceb9f562b7dac9a509abb74694ecb1b8a31aasize 4726123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127% MPGA.M (Multi Population Genetic Algorithm)%% This script implements the Multi Population Genetic Algorithm.% Real valued representation for the individuals is used.%% Author: Hartmut Pohlheim% History: 23.03.94 file createdGGAP = .8; % Generation gap, how many new individuals are createdINSR = .9; % Insertion rate, how many of the offspring are insertedXOVR = 1; % Crossover rateSP = 2; % Selective PressureMUTR = 1; % Mutation rate; only a factor;MIGR = 0.2; % Migration rate between subpopulationsMIGGEN = 20; % Number of generations between migration (isolation time)TERMEXACT = 1e-4; % Value for termination if minimum reachedSEL_F = 'sus'; % Name of selection functionXOV_F = 'recdis'; % Name of recombination function for individualsMUT_F = 'mutbga'; % Name of mutation functionOBJ_F = 'objharv'; % Name of function for objective values% Get boundaries of objective functionFieldDR = feval(OBJ_F,[],1);% compute SUBPOP, NIND depending on number of variables (defined in objective function)NVAR = size(FieldDR,2); % Get number of variables from objective functionSUBPOP = 2 * floor(sqrt(NVAR)); % Number of subpopulationsNIND = 20 + 5 * floor(NVAR/50); % Number of individuals per subpopulationsMAXGEN = 300 * floor(sqrt(NVAR)); % Maximal number of generationsMUTR = MUTR / NVAR; % Mutation rate depending on NVAR% Get value of minimum, defined in objective functionGlobalMin = feval(OBJ_F,[],3);% Get title of objective function, defined in objective functionFigTitle = [feval(OBJ_F,[],2) ' (' int2str(SUBPOP) ':' int2str(MAXGEN) ') '];% Clear Best and storing matrix% Initialise Matrix for storing best resultsBest = NaN * ones(MAXGEN,3);Best(:,3) = zeros(size(Best,1),1);% Matrix for storing best individualsIndAll = [];% Create real populationChrom = crtrp(SUBPOP*NIND,FieldDR);% reset count variablesgen = 0;termopt = 0;% Calculate objective function for populationObjV = feval(OBJ_F,Chrom);% count number of objective function evaluationsBest(gen+1,3) = Best(gen+1,3) + NIND;% Iterate subpopulation till termination or MAXGENwhile ((gen < MAXGEN) & (termopt == 0)),% Save the best and average objective values and the best individual[Best(gen+1,1),ix] = min(ObjV);Best(gen+1,2) = mean(ObjV);IndAll = [IndAll; Chrom(ix,:)];% Fitness assignement to whole populationFitnV = ranking(ObjV,[2 0],SUBPOP);% Select individuals from populationSelCh = select(SEL_F, Chrom, FitnV, GGAP, SUBPOP);% Recombine selected individualsSelCh=recombin(XOV_F, SelCh, XOVR, SUBPOP);% Mutate offspringSelCh=mutate(MUT_F, SelCh, FieldDR, [MUTR], SUBPOP);% Calculate objective function for offspringsObjVOff = feval(OBJ_F,SelCh);Best(gen+1,3) = Best(gen+1,3) + size(SelCh,1);% Insert best offspring in population replacing worst parents[Chrom, ObjV] = reins(Chrom, SelCh, SUBPOP, [1 INSR], ObjV, ObjVOff);gen=gen+1;% Plot some results, rename title of figure for graphic outputif ((rem(gen,20) == 1) | (rem(gen,MAXGEN) == 0) | (termopt == 1)),set(gcf,'Name',[FigTitle ' in ' int2str(gen)]);resplot(Chrom(1:2:size(Chrom,1),:),...IndAll(max(1,gen-39):size(IndAll,1),:),...[ObjV; GlobalMin], Best(max(1,gen-19):gen,[1 2]), gen);end% Check, if best objective value near GlobalMin -> termination criterion% compute differenz between GlobalMin and best objective valueActualMin = abs(min(ObjV) - GlobalMin);% if ActualMin smaller than TERMEXACT --> terminationif ((ActualMin < (TERMEXACT * abs(GlobalMin))) | (ActualMin < TERMEXACT))termopt = 1;end% migrate individuals between subpopulationsif ((termopt ~= 1) & (rem(gen,MIGGEN) == 0))[Chrom, ObjV] = migrate(Chrom, SUBPOP, [MIGR, 1, 0], ObjV);endend% Results% add number of objective function evaluationsResults = cumsum(Best(1:gen,3));% number of function evaluation, mean and best resultsResults = [Results Best(1:gen,2) Best(1:gen,1)];% Plot Results and show best individuals => optimumfigure('Name',['Results of ' FigTitle]);subplot(2,1,1), plot(Results(:,1),Results(:,2),'-',Results(:,1),Results(:,3),':');subplot(2,1,2), plot(IndAll(gen-4:gen,:)');% End of script
123version https://git-lfs.github.com/spec/v1oid sha256:8cff116c0c77ce82edb0fe38de3c3b5d53b1862a196c4cec016126fba51dd19dsize 2529123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869% OBJBRAN.M (OBJective function for BRANin RCOS function)%% This function implements the BRANIN RCOS function.%% Syntax: ObjVal = objbran(Chrom,switch)%% Input parameters:% Chrom - Matrix containing the chromosomes of the current% population. Each row corresponds to one individual's% string representation.% if Chrom == [], then speziell values will be returned% switch - if Chrom == [] and% switch == 1 (or []) return boundaries% switch == 2 return title% switch == 3 return value of global minimum%% Output parameters:% ObjVal - Column vector containing the objective values of the% individuals in the current population.% if called with Chrom == [], then ObjVal contains% switch == 1, matrix with the boundaries of the function% switch == 2, text for the title of the graphic output% switch == 3, value of global minimum%% Author: Hartmut Pohlheim% History: 25.11.93 file created% 27.11.93 text of title and switch added% 16.12.93 switch == 3, return value of global minimum% 01.03.94 name changed in obj*function ObjVal = objbran(Chrom,switch);% Compute population parameters[Nind,Nvar] = size(Chrom);% Check size of Chrom and do the appropriate thing% if Chrom is []if Nind == 0% return text of title for graphic outputif switch == 2ObjVal = 'BRANINs RCOS function';% return value of global minimumelseif switch == 3ObjVal = 0.397887;% define size of boundary-matrix and valueselse% x1 x2ObjVal = [-5 0; % lower bounds10 15]; % upper boundsend% if two variables, compute values of functionelseif Nvar == 2% BRANIN's RCOS function% -5 <= x1 <= 10 ; 0 <= x2 <= 15% global minimum at (x1,x2)=(-pi,12.275), (pi,2.275), and% (9.42478,2.475) ; fmin=0.397887x1 = Chrom(:,1);x2 = Chrom(:,2);ObjVal = 1*(x2-(5.1/(4*pi^2))*x1.^2+(5/pi)*x1-6).^2+10*(1-(1/(8*pi))).*cos(x1)+10;% otherwise error, wrong format of Chromelseerror('size of matrix Chrom is not correct for function evaluation');end% End of function
123version https://git-lfs.github.com/spec/v1oid sha256:686287fbe6f7298dec81cc21f54f0325462f6c61fe7ec41dcb7ae9ec01f6c66fsize 4051123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107% OBJDOPI.M (OBJective function for DOuble Integrator)%% This function implements the Double Integrator.%% Syntax: ObjVal = objdopi(Chrom,switch)%% Input parameters:% Chrom - Matrix containing the chromosomes of the current% population. Each row corresponds to one individual's% string representation.% if Chrom == [], then special values will be returned% switch - if Chrom == [] and% switch == 1 (or []) return boundaries% switch == 2 return title% switch == 3 return value of global minimum%% Output parameters:% ObjVal - Column vector containing the objective values of the% individuals in the current population.% if called with Chrom == [], then ObjVal contains% switch == 1, matrix with the boundaries of the function% switch == 2, text for the title of the graphic output% switch == 3, value of global minimum%% Author: Hartmut Pohlheim% History: 17.12.93 file created (copy of valfun7.m)% 19.12.93 Dim reintroduced% Dim and STEPSIMU independend from each other, rk23% can compute control between times% 01.03.94 name changed in obj*% 05.04.94 trapz usedfunction [ObjVal,t,x] = objdopi(Chrom,switch);% Define used methodmethod = 1; % 1 - sim: simulink model% 2 - ode: ordinary differential equations% 3 - con: transfer function to state space% Dimension of objective functionDim = 20;TSTART = 0;TEND = 1;STEPSIMU = min(0.1,abs((TEND-TSTART)/(Dim-1)));TIMEVEC = linspace(TSTART,TEND,Dim)';% initial conditionsXINIT = [ 0; -1];% end conditionsXEND = [ 0; 0];% weights for control and endXENDWEIGHT = 12 * [1; 1]; % XEND(1); XEND(2)UWEIGHT = [0.5]; % Control vector% Compute population parameters[Nind,Nvar] = size(Chrom);% Check size of Chrom and do the appropriate thing% if Chrom is [], thenif Nind == 0% return text of title for graphic outputif switch == 2if method == 2, ObjVal = ['Double Integrator (ode)-' int2str(Dim)];elseif method == 3, ObjVal = ['Double Integrator (con)-' int2str(Dim)];else ObjVal = ['Double Integrator (sim)-' int2str(Dim)];end% return value of global minimumelseif switch == 3ObjVal = 2; % UWEIGHT * 3 * (TEND - TSTART);% define size of boundary-matrix and valueselse% lower and upper bound, identical for all n variablesObjVal1 = [-15; 15];ObjVal = rep(ObjVal1,[1 Dim]);end% if Dim variables, compute values of functionelseif Nvar == Dimif method == 3, % Convert transfer function to state space system[Ai2 Bi2 Ci2 Di2] = tf2ss(1, [1 0 0]);t = TIMEVEC;endObjVal = zeros(Nind,1);for indrun = 1:Nindsteuerung = [TIMEVEC [Chrom(indrun,:)]'];if method == 2,[t x] = rk23('simdopi2',[TSTART TEND],XINIT,[1e-3;STEPSIMU;STEPSIMU],steuerung);elseif method == 3,[y x] = lsim(Ai2, Bi2, Ci2, Di2, Chrom(indrun,:),TIMEVEC, XINIT);else[t x] = rk23('simdopi1',[TSTART TEND],[],[1e-3;STEPSIMU;STEPSIMU],steuerung);end% Calculate objective function, endvalues, trapez-integration for control vectorObjVal(indrun) = sum(XENDWEIGHT .* abs( x(size(x,1),:)' - XEND )) + ...(UWEIGHT / (Dim-1) * trapz(Chrom(indrun,:).^2));end% otherwise error, wrong format of Chromelseerror('size of matrix Chrom is not correct for function evaluation');end% End of function
123version https://git-lfs.github.com/spec/v1oid sha256:038c5bb2a6c7567435818ba7da42a9f0f4a39c648cd1e7f061a84f952582938esize 2427123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869% OBJEASO.M (OBJective function for EASom function)%% This function implements the EASOM function.%% Syntax: ObjVal = objeaso(Chrom,switch)%% Input parameters:% Chrom - Matrix containing the chromosomes of the current% population. Each row corresponds to one individual's% string representation.% if Chrom == [], then speziell values will be returned% switch - if Chrom == [] and% switch == 1 (or []) return boundaries% switch == 2 return title% switch == 3 return value of global minimum%% Output parameters:% ObjVal - Column vector containing the objective values of the% individuals in the current population.% if called with Chrom == [], then ObjVal contains% switch == 1, matrix with the boundaries of the function% switch == 2, text for the title of the graphic output% switch == 3, value of global minimum%% Author: Hartmut Pohlheim% History: 25.11.93 file created% 27.11.93 text of title and switch added% 16.12.93 switch == 3, return value of global minimum% 01.03.94 name changed in obj*function ObjVal = objeaso(Chrom,switch);% Compute population parameters[Nind,Nvar] = size(Chrom);% Check size of Chrom and do the appropriate thing% if Chrom is []if Nind == 0% return text of title for graphic outputif switch == 2ObjVal = 'EASOMs function';% return value of global minimumelseif switch == 3ObjVal = -1;% define size of boundary-matrix and valueselse% x1 x2ObjVal = [-100 -100; % lower bounds100 100]; % upper boundsend% if two variables, compute values of functionelseif Nvar == 2% EASOM's function% -100(-5) <= x1 <= 100(5) ; -100(-5) <= x2 <= 100(5)% global minimum at (x1,x2)=(pi,pi) ; fmin=-1x1 = Chrom(:,1);x2 = Chrom(:,2);ObjVal = -cos(x1).*cos(x2).*exp(-((x1-pi).^2+(x2-pi).^2));% otherwise error, wrong format of Chromelseerror('size of matrix Chrom is not correct for function evaluation');end% End of function
123version https://git-lfs.github.com/spec/v1oid sha256:24eea201ce7f79221e27da8a5ae9d5b1719f0c54eedc0dac275bc2c750e2ddbesize 26291234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071% OBJFUN1.M (OBJective function for de jong's FUNction 1)%% This function implements the DE JONG function 1.%% Syntax: ObjVal = objfun1(Chrom,switch)%% Input parameters:% Chrom - Matrix containing the chromosomes of the current% population. Each row corresponds to one individual's% string representation.% if Chrom == [], then special values will be returned% switch - if Chrom == [] and% switch == 1 (or []) return boundaries% switch == 2 return title% switch == 3 return value of global minimum%% Output parameters:% ObjVal - Column vector containing the objective values of the% individuals in the current population.% if called with Chrom == [], then ObjVal contains% switch == 1, matrix with the boundaries of the function% switch == 2, text for the title of the graphic output% switch == 3, value of global minimum%% Author: Hartmut Pohlheim% History: 26.11.93 file created% 27.11.93 text of title and switch added% 30.11.93 show Dim in figure titel% 16.12.93 switch == 3, return value of global minimum% 01.03.94 name changed in obj*function ObjVal = objfun1(Chrom,switch);% Dimension of objective functionDim = 20;% Compute population parameters[Nind,Nvar] = size(Chrom);% Check size of Chrom and do the appropriate thing% if Chrom is [], then define size of boundary-matrix and valuesif Nind == 0% return text of title for graphic outputif switch == 2ObjVal = ['DE JONG function 1-' int2str(Dim)];% return value of global minimumelseif switch == 3ObjVal = 0;% define size of boundary-matrix and valueselse% lower and upper bound, identical for all n variablesObjVal = 100*[-5.12; 5.12];ObjVal = ObjVal(1:2,ones(Dim,1));end% if Dim variables, compute values of functionelseif Nvar == Dim% function 1, sum of xi^2 for i = 1:Dim (Dim=30)% n = Dim, -5.12 <= xi <= 5.12% global minimum at (xi)=(0) ; fmin=0ObjVal = sum((Chrom .* Chrom)')';% ObjVal = diag(Chrom * Chrom'); % both lines produce the same% otherwise error, wrong format of Chromelseerror('size of matrix Chrom is not correct for function evaluation');end% End of function
123version https://git-lfs.github.com/spec/v1oid sha256:335e74ac50e7b5fa5eeb6732ab08d3c7258a88ba8615e4b9b75655fed29b20ebsize 25011234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768% OBJFUN1A.M (OBJective function for axis parallel hyper-ellipsoid)%% This function implements the axis parallel hyper-ellipsoid.%% Syntax: ObjVal = objfun1a(Chrom,switch)%% Input parameters:% Chrom - Matrix containing the chromosomes of the current% population. Each row corresponds to one individual's% string representation.% if Chrom == [], then special values will be returned% switch - if Chrom == [] and% switch == 1 (or []) return boundaries% switch == 2 return title% switch == 3 return value of global minimum%% Output parameters:% ObjVal - Column vector containing the objective values of the% individuals in the current population.% if called with Chrom == [], then ObjVal contains% switch == 1, matrix with the boundaries of the function% switch == 2, text for the title of the graphic output% switch == 3, value of global minimum%% Author: Hartmut Pohlheim% History: 07.04.94 file createdfunction ObjVal = objfun1a(Chrom,switch);% Dimension of objective functionDim = 10;% Compute population parameters[Nind,Nvar] = size(Chrom);% Check size of Chrom and do the appropriate thing% if Chrom is [], then define size of boundary-matrix and valuesif Nind == 0% return text of title for graphic outputif switch == 2ObjVal = ['Axis Parallel Hyper-Ellipsoid 1a-' int2str(Dim)];% return value of global minimumelseif switch == 3ObjVal = 0;% define size of boundary-matrix and valueselse% lower and upper bound, identical for all n variablesObjVal = 100*[-5.12; 5.12];ObjVal = ObjVal(1:2,ones(Dim,1));end% if Dim variables, compute values of functionelseif Nvar == Dim% function 1a, sum of i * xi^2 for i = 1:Dim (Dim=30)% n = Dim, -5.12 <= xi <= 5.12% global minimum at (xi)=(0) ; fmin=0nummer = rep(1:Dim,[Nind 1]);ObjVal = sum((nummer .* (Chrom .* Chrom))')';% ObjVal = diag((nummer .* (Chrom * Chrom))'); % both lines produce the same% otherwise error, wrong format of Chromelseerror('size of matrix Chrom is not correct for function evaluation');end% End of function
123version https://git-lfs.github.com/spec/v1oid sha256:9ec112b6d95a471539bfeaa4614e10c249dd5e200240eb1d8fd094e572d5a0c6size 2360123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566% OBJFUN1B.M (OBJective function for rotated hyper-ellipsoid)%% This function implements the rotated hyper-ellipsoid.%% Syntax: ObjVal = objfun1b(Chrom,switch)%% Input parameters:% Chrom - Matrix containing the chromosomes of the current% population. Each row corresponds to one individual's% string representation.% if Chrom == [], then special values will be returned% switch - if Chrom == [] and% switch == 1 (or []) return boundaries% switch == 2 return title% switch == 3 return value of global minimum%% Output parameters:% ObjVal - Column vector containing the objective values of the% individuals in the current population.% if called with Chrom == [], then ObjVal contains% switch == 1, matrix with the boundaries of the function% switch == 2, text for the title of the graphic output% switch == 3, value of global minimum%% Author: Hartmut Pohlheim% History: 07.04.94 file createdfunction ObjVal = objfun1b(Chrom,switch);% Dimension of objective functionDim = 10;% Compute population parameters[Nind,Nvar] = size(Chrom);% Check size of Chrom and do the appropriate thing% if Chrom is [], then define size of boundary-matrix and valuesif Nind == 0% return text of title for graphic outputif switch == 2ObjVal = ['Rotated Hyper-Ellipsoid 1b-' int2str(Dim)];% return value of global minimumelseif switch == 3ObjVal = 0;% define size of boundary-matrix and valueselse% lower and upper bound, identical for all n variablesObjVal = [-65; 65];ObjVal = ObjVal(1:2,ones(Dim,1));end% if Dim variables, compute values of functionelseif Nvar == Dim% function 1b, sum over i of ( sum of xj )^2 for i = 1:Dim, j = 1:i (Dim=30)% n = Dim, -65 <= xj <= 65% global minimum at (xi)=(0) ; fmin=0ObjVal = sum(cumsum(Chrom').^2)';% otherwise error, wrong format of Chromelseerror('size of matrix Chrom is not correct for function evaluation');end% End of function
123version https://git-lfs.github.com/spec/v1oid sha256:9c23916aaee358f3bff7e371882a0278ee1b6e002d613b9436b65f0e9fc4946dsize 2522123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172% OBJFUN2.M (OBJective function for rosenbrock's FUNction)%% This function implements the ROSENBROCK valley (DE JONG's Function 2).%% Syntax: ObjVal = objfun2(Chrom,switch)%% Input parameters:% Chrom - Matrix containing the chromosomes of the current% population. Each row corresponds to one% individual's string representation.% if called with Chrom == [], then boundaries of% the function or title for figure will be returned% switch - if Chrom == [] and switch == 1 (or []) then return% boundaries, if switch == 2 return title%% Output parameters:% ObjVal - Column vector containing the objective values of the% individuals in the current population.% if called with Chrom == [], then ObjVal contains% the matrix with the boundaries of the function or% the Text for the title of the graphic output%% Author: Hartmut Pohlheim% History: 26.01.94 file created% 01.03.94 name changed in obj*function ObjVal = objfun2(Chrom,switch);% Dimension of objective functionDim = 2;% Compute population parameters[Nind,Nvar] = size(Chrom);% Check size of Chrom and do the appropriate thing% if Chrom is [], then define size of boundary-matrix and valuesif Nind == 0% return text of title for graphic outputif switch == 2ObjVal = ['ROSENBROCKs function 2-' int2str(Dim)];% return value of global minimumelseif switch == 3ObjVal = 0;% define size of boundary-matrix and valueselse% lower and upper bound, identical for all n variablesObjVal = [-2; 2];ObjVal = ObjVal(1:2,ones(Dim,1));end% if Dim variables, compute values of functionelseif Nvar == Dim% function 11, sum of 100* (x(i+1) -xi^2)^2+(1-xi)^2 for i = 1:Dim (Dim=10)% n = Dim, -10 <= xi <= 10% global minimum at (xi)=(1) ; fmin=0Mat1 = Chrom(:,1:Nvar-1);Mat2 = Chrom(:,2:Nvar);if Dim == 2ObjVal = 100*(Mat2-Mat1.^2).^2+(1-Mat1).^2;elseObjVal = sum((100*(Mat2-Mat1.^2).^2+(1-Mat1).^2)')';end% otherwise error, wrong format of Chromelseerror('size of matrix Chrom is not correct for function evaluation');end% End of function
123version https://git-lfs.github.com/spec/v1oid sha256:9e9b9d03f1ad19c8e5b5492ff7a1e6289d6e8564d07235fa7beafc1b51c5ca5asize 273512345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273% OBJFUN6.M (OBJective function for rastrigins FUNction 6)%% This function implements the RASTRIGIN function 6.%% Syntax: ObjVal = objfun6(Chrom,switch)%% Input parameters:% Chrom - Matrix containing the chromosomes of the current% population. Each row corresponds to one individual's% string representation.% if Chrom == [], then speziell values will be returned% switch - if Chrom == [] and% switch == 1 (or []) return boundaries% switch == 2 return title% switch == 3 return value of global minimum%% Output parameters:% ObjVal - Column vector containing the objective values of the% individuals in the current population.% if called with Chrom == [], then ObjVal contains% switch == 1, matrix with the boundaries of the function% switch == 2, text for the title of the graphic output% switch == 3, value of global minimum%% Author: Hartmut Pohlheim% History: 26.11.93 file created% 27.11.93 text of title and switch added% 30.11.93 show Dim in figure titel% 16.12.93 switch == 3, return value of global minimum% 01.03.94 name changed in obj*function ObjVal = objfun6(Chrom,switch);% Dimension of objective functionDim = 20;% Compute population parameters[Nind,Nvar] = size(Chrom);% Check size of Chrom and do the appropriate thing% if Chrom is [], then define size of boundary-matrix and valuesif Nind == 0% return text of title for graphic outputif switch == 2ObjVal = ['RASTRIGINs function 6-' int2str(Dim)];% return value of global minimumelseif switch == 3ObjVal = 0;% define size of boundary-matrix and valueselse% lower and upper bound, identical for all n variablesObjVal = [-5.12; 5.12];ObjVal = ObjVal(1:2,ones(Dim,1));end% if Dim variables, compute values of functionelseif Nvar == Dim% function 6, Dim*A + sum of (xi^2 - A*cos(Omega*xi)) for i = 1:Dim (Dim=20)% n = Dim, -5.12 <= xi <= 5.12% global minimum at (xi)=(0) ; fmin=0A = 10;Omega = 2 * pi;ObjVal = Dim * A + sum(((Chrom .* Chrom) - A * cos(Omega * Chrom))')';% ObjVal = diag(Chrom * Chrom'); % both lines produce the same% otherwise error, wrong format of Chromelseerror('size of matrix Chrom is not correct for function evaluation');end% End of function
123version https://git-lfs.github.com/spec/v1oid sha256:c2d8e97be04a95910b9ef6ee144e39d018a0a8e902ffc6bc0d8dae7f9d50a3bcsize 24491234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768% OBJFUN7.M (OBJective function for schwefel's FUNction)%% This function implements the SCHWEFEL function 7.%% Syntax: ObjVal = objfun7(Chrom,switch)%% Input parameters:% Chrom - Matrix containing the chromosomes of the current% population. Each row corresponds to one% individual's string representation.% if called with Chrom == [], then boundaries of% the function or title for figure will be returned% switch - if Chrom == [] and switch == 1 (or []) then return% boundaries, if switch == 2 return title%% Output parameters:% ObjVal - Column vector containing the objective values of the% individuals in the current population.% if called with Chrom == [], then ObjVal contains% the matrix with the boundaries of the function or% the Text for the title of the graphic output%% Author: Hartmut Pohlheim% History: 27.11.93 file created% 30.11.93 show Dim in figure titel% 01.03.94 name changed in obj*function ObjVal = objfun7(Chrom,switch);% Dimension of objective functionDim = 20;% Compute population parameters[Nind,Nvar] = size(Chrom);% Check size of Chrom and do the appropriate thing% if Chrom is [], then define size of boundary-matrix and valuesif Nind == 0% return text of title for graphic outputif switch == 2ObjVal = ['SCHWEFELs function 7-' int2str(Dim)];% return value of global minimumelseif switch == 3xmin = 420.9687;ObjVal = Dim * (-xmin * sin(sqrt(abs(xmin))));% define size of boundary-matrix and valueselse% lower and upper bound, identical for all n variablesObjVal = [-500; 500];ObjVal = ObjVal(1:2,ones(Dim,1));end% if Dim variables, compute values of functionelseif Nvar == Dim% function 7, sum of -xi*sin(sqrt(abs(xi))) for i = 1:Dim (Dim=10)% n = Dim, -500 <= xi <= 500% global minimum at (xi)=(420.9687) ; fmin=?ObjVal = sum((-Chrom .* sin(sqrt(abs(Chrom))))')';% otherwise error, wrong format of Chromelseerror('size of matrix Chrom is not correct for function evaluation');end% End of function
123version https://git-lfs.github.com/spec/v1oid sha256:48d08e996e74eee124e3e7cd224bdf1ef1fe12dd78410276efaab2af1245f7b5size 2664123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172% OBJFUN8.M (OBJective function for griewangk's FUNction)%% This function implements the GRIEWANGK function 8.%% Syntax: ObjVal = objfun8(Chrom,switch)%% Input parameters:% Chrom - Matrix containing the chromosomes of the current% population. Each row corresponds to one individual's% string representation.% if Chrom == [], then speziell values will be returned% switch - if Chrom == [] and% switch == 1 (or []) return boundaries% switch == 2 return title% switch == 3 return value of global minimum%% Output parameters:% ObjVal - Column vector containing the objective values of the% individuals in the current population.% if called with Chrom == [], then ObjVal contains% switch == 1, matrix with the boundaries of the function% switch == 2, text for the title of the graphic output% switch == 3, value of global minimum%% Author: Hartmut Pohlheim% History: 12.12.93 file created (copy of valfun7.m)% 16.12.93 switch == 3, return value of global minimum% 27.01.94 20* in formula, correction ??% 01.03.94 name changed in obj*function ObjVal = objfun8(Chrom,switch);% Dimension of objective functionDim = 10;% Compute population parameters[Nind,Nvar] = size(Chrom);% Check size of Chrom and do the appropriate thing% if Chrom is [], then define size of boundary-matrix and valuesif Nind == 0% return text of title for graphic outputif switch == 2ObjVal = ['GRIEWANGKs function 8-' int2str(Dim)];% return value of global minimumelseif switch == 3ObjVal = 0;% define size of boundary-matrix and valueselse% lower and upper bound, identical for all n variablesObjVal = [-600; 600];ObjVal = ObjVal(1:2,ones(Dim,1));end% if Dim variables, compute values of functionelseif Nvar == Dim% function 8, sum(xi^2/4000) - 20*prod(cos(xi/sqrt(i))) + 1 for i = 1:Dim (Dim=10)% n = Dim, -600 <= xi <= 600% global minimum at (xi)=(0) ; fmin=0% nummer = 1:Dim;nummer = rep(1:Dim,[Nind 1]);ObjVal = sum(((Chrom.^2) / 4000)')' - prod(cos(Chrom ./ sqrt(nummer))')' + 1;% otherwise error, wrong format of Chromelseerror('size of matrix Chrom is not correct for function evaluation');end% End of function
123version https://git-lfs.github.com/spec/v1oid sha256:bf0e7e8d9a68317c34ca930b133d0d156e6655425f6397d6ebad000dc4927574size 238612345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667% OBJFUN9.M (OBJective function for sum of different power FUNction 9)%% This function implements the sum of different power.%% Syntax: ObjVal = objfun9(Chrom,switch)%% Input parameters:% Chrom - Matrix containing the chromosomes of the current% population. Each row corresponds to one individual's% string representation.% if Chrom == [], then special values will be returned% switch - if Chrom == [] and% switch == 1 (or []) return boundaries% switch == 2 return title% switch == 3 return value of global minimum%% Output parameters:% ObjVal - Column vector containing the objective values of the% individuals in the current population.% if called with Chrom == [], then ObjVal contains% switch == 1, matrix with the boundaries of the function% switch == 2, text for the title of the graphic output% switch == 3, value of global minimum%% Author: Hartmut Pohlheim% History: 07.04.94 file createdfunction ObjVal = objfun9(Chrom,switch);% Dimension of objective functionDim = 10;% Compute population parameters[Nind,Nvar] = size(Chrom);% Check size of Chrom and do the appropriate thing% if Chrom is [], then define size of boundary-matrix and valuesif Nind == 0% return text of title for graphic outputif switch == 2ObjVal = ['Sum of different Power 9-' int2str(Dim)];% return value of global minimumelseif switch == 3ObjVal = 0;% define size of boundary-matrix and valueselse% lower and upper bound, identical for all n variablesObjVal = [-1; 1];ObjVal = ObjVal(1:2,ones(Dim,1));end% if Dim variables, compute values of functionelseif Nvar == Dim% function 9, sum of abs(xi)^(i+1) for i = 1:Dim (Dim=30)% n = Dim, -1 <= xi <= 1% global minimum at (xi)=(0) ; fmin=0nummer = rep(1:Dim,[Nind 1]);ObjVal = sum((abs(Chrom).^(nummer+1))')';% otherwise error, wrong format of Chromelseerror('size of matrix Chrom is not correct for function evaluation');end% End of function
123version https://git-lfs.github.com/spec/v1oid sha256:683ff891777d96ffa9aa34b86b508f6a819deaf524e463c0f0b3e00a6d5745f7size 26151234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071% OBJGOLD.M (OBJective function for GOLDstein-price function)%% This function implements the GOLDSTEIN-PRICE function.%% Syntax: ObjVal = objgold(Chrom,switch)%% Input parameters:% Chrom - Matrix containing the chromosomes of the current% population. Each row corresponds to one individual's% string representation.% if Chrom == [], then speziell values will be returned% switch - if Chrom == [] and% switch == 1 (or []) return boundaries% switch == 2 return title% switch == 3 return value of global minimum%% Output parameters:% ObjVal - Column vector containing the objective values of the% individuals in the current population.% if called with Chrom == [], then ObjVal contains% switch == 1, matrix with the boundaries of the function% switch == 2, text for the title of the graphic output% switch == 3, value of global minimum%% Author: Hartmut Pohlheim% History: 25.11.93 file created% 27.11.93 text of title and switch added% 16.12.93 switch == 3, return value of global minimum% 01.03.94 name changed in obj*function ObjVal = objgold(Chrom,switch);% Compute population parameters[Nind,Nvar] = size(Chrom);% Check size of Chrom and do the appropriate thing% if Chrom is [], then define size of boundary-matrix and valuesif Nind == 0% return text of title for graphic outputif switch == 2ObjVal = 'GOLDSTEIN-PRICE function';% return value of global minimumelseif switch == 3ObjVal = 3;% define size of boundary-matrix and valueselsebrd = 3;% x1 x2ObjVal = [-brd -brd; % lower boundsbrd brd]; % upper boundsend% if two variables, compute values of functionelseif Nvar == 2% GOLDSTEIN-PRICE function% -2 <= x1 <= 2 ; -2 <= x2 <= 2 (or -10 <= xi <= 10)% global minimum at (x1,x2)=(0,-1) ; fmin=3x1 = Chrom(:,1);x2 = Chrom(:,2);ObjVal = ((1+(x1+x2+1).^2.*(19-14*x1+3*x1.^2-14*x2+6*x1.*x2+3*x2.^2))....*(30+(2*x1-3*x2).^2.*(18-32*x1+12*x1.^2+48*x2-36*x1.*x2+27*x2.^2)));% otherwise error, wrong format of Chromelseerror('size of matrix Chrom is not correct for function evaluation');end% End of function
123version https://git-lfs.github.com/spec/v1oid sha256:771ae25c9b3f8818c984b601db80fcd04e73cdeb37b7d629a8c5d3bfe953c806size 2560123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778% OBJHARV.M (OBJective function for HARVest problem)%% This function implements the HARVEST PROBLEM.%% Syntax: ObjVal = objharv(Chrom,switch)%% Input parameters:% Chrom - Matrix containing the chromosomes of the current% population. Each row corresponds to one individual's% string representation.% if Chrom == [], then speziell values will be returned% switch - if Chrom == [] and% switch == 1 (or []) return boundaries% switch == 2 return title% switch == 3 return value of global minimum%% Output parameters:% ObjVal - Column vector containing the objective values of the% individuals in the current population.% if called with Chrom == [], then ObjVal contains% switch == 1, matrix with the boundaries of the function% switch == 2, text for the title of the graphic output% switch == 3, value of global minimum%% Author: Hartmut Pohlheim% History: 18.02.94 file created (copy of vallinq.m)% 01.03.94 name changed in obj*function ObjVal = objharv(Chrom,switch);% global gen;% Dimension of objective functionDim = 20;% values from MICHALEWICZa = 1.1;x0 = 100;xend = x0;XENDWEIGHT = 0.4/(Dim^0.6);% Compute population parameters[Nind,Nvar] = size(Chrom);% Check size of Chrom and do the appropriate thing% if Chrom is [], then define size of boundary-matrix and valuesif Nind == 0% return text of title for graphic outputif switch == 2ObjVal = ['HARVEST PROBLEM-' int2str(Dim)];% return value of global minimumelseif switch == 3ObjVal = -sqrt(x0*(a^Dim-1)^2/(a^(Dim-1)*(a-1)));% define size of boundary-matrix and valueselse% lower and upper bound, identical for all n variablesObjVal1 = [0; 10*Dim];ObjVal = rep(ObjVal1,[1 Dim]);end% if Dim variables, compute values of functionelseif Nvar == DimObjVal = zeros(Nind,1);X = rep(x0,[Nind 1]);for irun = 1:Nvar,X = a*X - Chrom(:,irun);endX;ObjVal = -(sum(sqrt(Chrom)')' - XENDWEIGHT * abs(X-x0));% otherwise error, wrong format of Chromelseerror('size of matrix Chrom is not correct for function evaluation');end% End of function
123version https://git-lfs.github.com/spec/v1oid sha256:2a429b54f46b0bd5a7d4b02a8966c9194485c3be57e32ef747ae7220fef2a7dasize 32971234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586% OBJLINQ.M (OBJective function for LINear Quadratic problem)%% This function implements the discret LINEAR-QUADRATIC PROBLEM.%% Syntax: ObjVal = objlinq(Chrom,switch)%% Input parameters:% Chrom - Matrix containing the chromosomes of the current% population. Each row corresponds to one individual's% string representation.% if Chrom == [], then special values will be returned% switch - if Chrom == [] and% switch == 1 (or []) return boundaries% switch == 2 return title% switch == 3 return value of global minimum%% Output parameters:% ObjVal - Column vector containing the objective values of the% individuals in the current population.% if called with Chrom == [], then ObjVal contains% switch == 1, matrix with the boundaries of the function% switch == 2, text for the title of the graphic output% switch == 3, value of global minimum%% Author: Hartmut Pohlheim% History: 18.02.94 file created (copy of valfun7.m)% 01.03.94 name changed in obj*function ObjVal = objlinq(Chrom,switch);% Dimension of objective functionDim = 45;% values from MICHALEWICZx0 = 100; % start of Xvar = 1; % 1 - 10 possiblePara = [ 1 1 1 1 1 16180.3399;10 1 1 1 1 109160.7978;1000 1 1 1 1 10009990.0200;1 10 1 1 1 37015.6212;1 1000 1 1 1 287569.3725;1 1 0 1 1 16180.3399;1 1 1000 1 1 16180.3399;1 1 1 0.01 1 10000.5000;1 1 1 1 0.01 431004.0987;1 1 1 1 100 10000.9999];s = Para(var,1); r = Para(var,2); q = Para(var,3);a = Para(var,4); b = Para(var,5); GlobalMinimum = Para(var,6);% Compute population parameters[Nind,Nvar] = size(Chrom);% Check size of Chrom and do the appropriate thing% if Chrom is [], then define size of boundary-matrix and valuesif Nind == 0% return text of title for graphic outputif switch == 2ObjVal = ['Linear-quadratic problem (dis)-' int2str(Dim)];% return value of global minimumelseif switch == 3ObjVal = GlobalMinimum;% define size of boundary-matrix and valueselse% lower and upper bound, identical for all n variablesObjVal1 = [-100 -70 -50; 20 20 20];ObjVal = [ObjVal1 rep([-30;20],[1 Dim-3])];end% if Dim variables, compute values of functionelseif Nvar == DimObjVal = zeros(Nind,1);X = zeros(Nind,Nvar+1);X(:,1) = rep(x0,[Nind 1]);for irun = 1:Nvar,X(:,irun+1) = a*X(:,irun) + b*Chrom(:,irun);endObjVal = q * X(:,Nvar+1).^2 + sum((s * X(:,1:Nvar).^2 + r * Chrom.^2)')';% otherwise error, wrong format of Chromelseerror('size of matrix Chrom is not correct for function evaluation');end% End of function
123version https://git-lfs.github.com/spec/v1oid sha256:73e21e33e6f035caad2f6e5ece899eae4fdcfd478e906fe407259566f77e5562size 3952123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105% OBJLINQ2.M (OBJective function for LINear Quadratic problem)%% This function implements the continuous LINear Quadratic problem.%% Syntax: ObjVal = objlinq2(Chrom,switch)%% Input parameters:% Chrom - Matrix containing the chromosomes of the current% population. Each row corresponds to one individual's% string representation.% if Chrom == [], then special values will be returned% switch - if Chrom == [] and% switch == 1 (or []) return boundaries% switch == 2 return title% switch == 3 return value of global minimum%% Output parameters:% ObjVal - Column vector containing the objective values of the% individuals in the current population.% if called with Chrom == [], then ObjVal contains% switch == 1, matrix with the boundaries of the function% switch == 2, text for the title of the graphic output% switch == 3, value of global minimum%% Author: Hartmut Pohlheim% History: 03.03.94 file created% 06.04.94 all linq (sim, ode, con) in 1 filefunction [ObjVal,t,x] = objlinq2(Chrom,switch);% Define used methodmethod = 1; % 1 - sim: simulink model% 2 - ode: ordinary differential equations% 3 - con: transfer function to state space% Dimension of objective functionDim = 50;TSTART = 0;TEND = 1;STEPSIMU = min(0.1,abs((TEND-TSTART)/(Dim-1)));TIMEVEC = linspace(TSTART,TEND,Dim)';% initial conditionsXINIT = [100];% end conditionsXEND = [0];% weights for control and endXENDWEIGHT = [20]; % XENDXWEIGHT = [2]; % State vectorUWEIGHT = [1]; % Control vector% Compute population parameters[Nind,Nvar] = size(Chrom);% Check size of Chrom and do the appropriate thing% if Chrom is [], thenif Nind == 0% return text of title for graphic outputif switch == 2if method == 2, ObjVal = ['Linear-quadratic problem (ode)-' int2str(Dim)];elseif method == 3, ObjVal = ['Linear-quadratic problem (con)-' int2str(Dim)];else ObjVal = ['Linear-quadratic problem (sim)-' int2str(Dim)];end% return value of global minimumelseif switch == 3ObjVal = 16180.3399;% define size of boundary-matrix and valueselse% lower and upper bound, identical for all n variablesObjVal = rep([-600; 0],[1 Dim]);end% if Dim variables, compute values of functionelseif Nvar == Dimif method == 3, % Convert transfer function to state space system[NC DC]=cloop(1, [1 0], +1);[Ai2 Bi2 Ci2 Di2] = tf2ss(NC, DC);t = TIMEVEC;endObjVal = zeros(Nind,1);for indrun = 1:Nindsteuerung = [TIMEVEC Chrom(indrun,:)'];if method == 2,[t x] = linsim('simlinq2',[TSTART TEND],[],[1e-3;STEPSIMU;STEPSIMU],steuerung);elseif method == 3,[y x] = lsim(Ai2, Bi2, Ci2, Di2, Chrom(indrun,:),TIMEVEC, XINIT);else[t x] = linsim('simlinq1',[TSTART TEND],[],[1e-3;STEPSIMU;STEPSIMU],steuerung);end% Calculate objective function, endvalues, trapez-integration for control vectorObjVal(indrun) = (XENDWEIGHT * ( x(size(x,1),:)^2 )) + ...(UWEIGHT / (Dim-1) * trapz(Chrom(indrun,:).^2)) + ...(XWEIGHT / size(x,1) * sum(x.^2));end% otherwise error, wrong format of Chromelseerror('size of matrix Chrom is not correct for function evaluation');end% End of function
123version https://git-lfs.github.com/spec/v1oid sha256:d1be6b1755abd35d4b7c98b1bcc52f996c17d89230edd10856279f5a1016df3csize 2595123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475% OBJPUSH.M (OBJective function for PUSH-cart problem)%% This function implements the PUSH-CART PROBLEM.%% Syntax: ObjVal = objpush(Chrom,switch)%% Input parameters:% Chrom - Matrix containing the chromosomes of the current% population. Each row corresponds to one individual's% string representation.% if Chrom == [], then speziell values will be returned% switch - if Chrom == [] and% switch == 1 (or []) return boundaries% switch == 2 return title% switch == 3 return value of global minimum%% Output parameters:% ObjVal - Column vector containing the objective values of the% individuals in the current population.% if called with Chrom == [], then ObjVal contains% switch == 1, matrix with the boundaries of the function% switch == 2, text for the title of the graphic output% switch == 3, value of global minimum%% Author: Hartmut Pohlheim% History: 19.02.94 file created (copy of valharv.m)% 01.03.94 name changed in obj*function ObjVal = objpush(Chrom,switch);% Dimension of objective functionDim = 20;% values from MICHALEWICZx0 = [0 0];% Compute population parameters[Nind,Nvar] = size(Chrom);% Check size of Chrom and do the appropriate thing% if Chrom is [], then define size of boundary-matrix and valuesif Nind == 0% return text of title for graphic outputif switch == 2ObjVal = ['PUSH-CART PROBLEM-' int2str(Dim)];% return value of global minimumelseif switch == 3ObjVal = -(1/3 - ((3*Dim-1)/(6*Dim^2)) - (1/(2*Dim^3))*sum((1:Dim-1).^2));% define size of boundary-matrix and valueselse% lower and upper bound, identical for all n variablesObjVal = [0; 5];ObjVal = rep(ObjVal,[1 Dim]);end% if Dim variables, compute values of functionelseif Nvar == DimObjVal = zeros(Nind,1);X = rep(x0,[Nind 1]);for irun = 1:Nvar,Xsave = X;X(:,1) = Xsave(:,2);X(:,2) = 2 * X(:,2) - Xsave(:,1) + (1/Dim^2) * Chrom(:,irun);endX;ObjVal = -(X(:,1) - (1/(2*Dim)) * sum((Chrom.^2)')');% otherwise error, wrong format of Chromelseerror('size of matrix Chrom is not correct for function evaluation');end% End of function
123version https://git-lfs.github.com/spec/v1oid sha256:61da893b40bb39e526de184ec3e52e610b1b8af6bfae65d782fe38550d399394size 25251234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768% OBJSIXH.M (OBJective function for SIX Hump camelback function)%% This function implements the six hump camelback function.%% Syntax: ObjVal = objsixh(Chrom,switch)%% Input parameters:% Chrom - Matrix containing the chromosomes of the current% population. Each row corresponds to one individual's% string representation.% if Chrom == [], then speziell values will be returned% switch - if Chrom == [] and% switch == 1 (or []) return boundaries% switch == 2 return title% switch == 3 return value of global minimum%% Output parameters:% ObjVal - Column vector containing the objective values of the% individuals in the current population.% if called with Chrom == [], then ObjVal contains% switch == 1, matrix with the boundaries of the function% switch == 2, text for the title of the graphic output% switch == 3, value of global minimum%% Author: Hartmut Pohlheim% History: 25.11.93 file created% 27.11.93 text of title and switch added% 16.12.93 switch == 3, return value of global minimum% 01.03.94 name changed in obj*function ObjVal = objsixh(Chrom,switch);% Compute population parameters[Nind,Nvar] = size(Chrom);% Check size of Chrom and do the appropriate thing% if Chrom is [], then define size of boundary-matrix and valuesif Nind == 0% return text of title for graphic outputif switch == 2ObjVal = 'six-hump camelback function';% return value of global minimumelseif switch == 3ObjVal = -1.0316;% define size of boundary-matrix and valueselse% x1 x2ObjVal = [-3 -2; % lower bounds3 2]; % upper boundsend% if two variables, compute values of functionelseif Nvar == 2% six-hump camelback function% -3 <= x1 <= 3 ; -2 <= x2 <= 2% global minimum at (x1,x2)=(-0.0898,0.7126),(0.0898,-0.7126) ; fmin=-1.0316x1 = Chrom(:,1);x2 = Chrom(:,2);ObjVal = (4-2.1*x1.^2+1/3*x1.^4).*x1.^2+x1.*x2+(-4+4*x2.^2).*x2.^2;% otherwise error, wrong format of Chromelseerror('size of matrix Chrom is not correct for function evaluation');end% End of function
123version https://git-lfs.github.com/spec/v1oid sha256:15424c52c7db18fd673d1d7d2004f7177a6ef38a34607db94dd1d37b3856bd37size 206712345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455% RESPLOT.M (RESult PLOTing)%% This function plots some of the results during computation.%% Syntax: resplot(Chrom,IndAll,ObjV,Best,gen)%% Input parameters:% Chrom - Matrix containing the chromosomes of the current% population. Each line corresponds to one individual.% IndAll - Matrix containing the best individual (variables) of each% generation. Each line corresponds to one individual.% ObjV - Vector containing objective values of the current% generation% Best - Matrix containing the best and average Objective values of each% generation, [best value per generation,average value per generation]% gen - Scalar containing the number of the current generation%% Output parameter:% no output parameter% Author: Hartmut Pohlheim% History: 27.11.93 file created% 29.11.93 decision, if plot or not deleted% yscale not log% 15.12.93 MutMatrix as parameter and plot added% 16.03.94 function cleaned, MutMatrix removed, IndAll addedfunction resplot(Chrom,IndAll,ObjV,Best,gen);% plot of best and mean value per generationsubplot(2,2,1), plot(Best);title('Best and mean objective value');xlabel('generation'), ylabel('objective value');% plot of best individuals in all generationssubplot(2,2,2), plot(IndAll);title(['Best individuals']);xlabel('generation'), ylabel('value of variable');% plot of variables of all individuals in current generationsubplot(2,2,3), plot(Chrom');title(['All individuals in gen ',num2str(gen)]);xlabel('number of variable'), ylabel('value of variable');% plot of all objective values in current generationsubplot(2,2,4), plot(ObjV,'y.');title(['All objective values']);xlabel('number of individual'), ylabel('objective value');drawnow;% End of function
123version https://git-lfs.github.com/spec/v1oid sha256:e65330edf6404154493ef42c844dbcc005548383ac20ea3e5b5436237289736csize 191112345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667% SGA.M (Simple Genetic Algorithm)%% This script implements the Simple Genetic Algorithm.% Binary representation for the individuals is used.%% Author: Hartmut Pohlheim% History: 23.03.94 file createdNIND = 20; % Number of individuals per subpopulationsMAXGEN = 300; % maximal Number of generationsGGAP = .8; % Generation gap, how many new individuals are createdSEL_F = 'sus'; % Name of selection functionXOV_F = 'xovsp'; % Name of recombination function for individualsMUT_F = 'mut'; % Name of mutation function for individualsOBJ_F = 'objfun1'; % Name of function for objective values% Get boundaries of objective functionFieldDR = feval(OBJ_F,[],1);% Number of variables of objective function, in OBJ_F definedNVAR = size(FieldDR,2);% Build fielddescription matrixPRECI = 20; % Precisicion of binary representationFieldDD = [rep([PRECI],[1, NVAR]);...FieldDR;...rep([1; 0; 1 ;1], [1, NVAR])];% Create populationChrom = crtbp(NIND, NVAR*PRECI);% reset count variablesgen = 0;Best = NaN*ones(MAXGEN,1);% Iterate populationwhile gen < MAXGEN,% Calculate objective function for populationObjV = feval(OBJ_F,bs2rv(Chrom, FieldDD));Best(gen+1) = min(ObjV);plot(log10(Best),'ro');drawnow;% Fitness assignement to whole populationFitnV = ranking(ObjV);% Select individuals from populationSelCh = select(SEL_F, Chrom, FitnV, GGAP);% Recombine selected individuals (crossover)SelCh=recombin(XOV_F, SelCh);% Mutate offspringSelCh=mutate(MUT_F, SelCh);% Insert offspring in population replacing parentsChrom = reins(Chrom, SelCh);gen=gen+1;end% End of script
123version https://git-lfs.github.com/spec/v1oid sha256:72e18d256066390606b71890a08513834396f3adf51dadd1b53013a60b79b6ddsize 26901234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980function [ret,x0,str]=simdopi1(t,x,u,flag);%SIMDOPI1 is the M-file description of the SIMULINK system named SIMDOPI1.% The block-diagram can be displayed by typing: SIMDOPI1.%% SYS=SIMDOPI1(T,X,U,FLAG) returns depending on FLAG certain% system values given time point, T, current state vector, X,% and input vector, U.% FLAG is used to indicate the type of output to be returned in SYS.%% Setting FLAG=1 causes SIMDOPI1 to return state derivatives, FLAG=2% discrete states, FLAG=3 system outputs and FLAG=4 next sample% time. For more information and other options see SFUNC.%% Calling SIMDOPI1 with a FLAG of zero:% [SIZES]=SIMDOPI1([],[],[],0), returns a vector, SIZES, which% contains the sizes of the state vector and other parameters.% SIZES(1) number of states% SIZES(2) number of discrete states% SIZES(3) number of outputs% SIZES(4) number of inputs.% For the definition of other parameters in SIZES, see SFUNC.% See also, TRIM, LINMOD, LINSIM, EULER, RK23, RK45, ADAMS, GEAR.% Note: This M-file is only used for saving graphical information;% after the model is loaded into memory an internal model% representation is used.% the system will take on the name of this mfile:sys = mfilename;new_system(sys)simver(1.2)if(0 == (nargin + nargout))set_param(sys,'Location',[100,100,600,400])open_system(sys)end;set_param(sys,'algorithm', 'RK-45')set_param(sys,'Start time', '0.0')set_param(sys,'Stop time', '1')set_param(sys,'Min step size', '0.001')set_param(sys,'Max step size', '0.01')set_param(sys,'Relative error','1e-3')set_param(sys,'Return vars', '')add_block('built-in/Inport',[sys,'/','Inport'])set_param([sys,'/','Inport'],...'position',[65,95,85,115])add_block('built-in/Note',[sys,'/','Doppelintegrator'])set_param([sys,'/','Doppelintegrator'],...'position',[225,10,230,15])add_block('built-in/Note',[sys,'/','Steuerung'])set_param([sys,'/','Steuerung'],...'position',[75,65,80,70])add_block('built-in/Integrator',[sys,'/','Integrator1'])set_param([sys,'/','Integrator1'],...'position',[175,95,195,115])add_block('built-in/Integrator',[sys,'/','Integrator2'])set_param([sys,'/','Integrator2'],...'Initial','-1',...'position',[280,95,300,115])add_line(sys,[90,105;165,105])add_line(sys,[200,105;270,105])% Return any arguments.if (nargin | nargout)% Must use feval here to access system in memoryif (nargin > 3)if (flag == 0)eval(['[ret,x0,str]=',sys,'(t,x,u,flag);'])elseeval(['ret =', sys,'(t,x,u,flag);'])endelse[ret,x0,str] = feval(sys);endend
matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/DOC/GATBXA1.PS
matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/DOC/GATBXA2.PS
matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/BS2RV.M+115-3
matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/CONTENTS.M+54-3
matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/CRTBASE.M+47-3
matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/CRTBP.M+72-3
matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/CRTRP.M+53-3
matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/MIGRATE.M+149-3
matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/MPGA.M+119-3
matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/MUT.M+54-3
matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/MUTATE.M+82-3
matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/MUTBGA.M+113-3
matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/OBJFUN1.M+71-3
matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/OBJHARV.M+78-3
matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/RANKING.M+125-3
matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/RECDIS.M+52-3
matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/RECINT.M+55-3
matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/RECLIN.M+57-3
matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/RECMUT.M+118-3
matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/RECOMBIN.M+69-3
matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/REINS.M+123-3
matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/REP.M+46-3
matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/RESPLOT.M+56-3
matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/RWS.M+31-3
matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/SCALING.M+52-3
matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/SELECT.M+69-3
matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/SGA.M+69-3
matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/SUS.M+41-3
matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/TEST_FNS/DEMOGA1.M+118-3
matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/TEST_FNS/MPGA.M+127-3
matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/TEST_FNS/OBJBRAN.M+69-3
matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/TEST_FNS/OBJDOPI.M+107-3
matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/TEST_FNS/OBJEASO.M+69-3
matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/TEST_FNS/OBJFUN1.M+71-3
matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/TEST_FNS/OBJFUN1A.M+68-3
matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/TEST_FNS/OBJFUN1B.M+66-3
matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/TEST_FNS/OBJFUN2.M+72-3
matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/TEST_FNS/OBJFUN6.M+73-3
matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/TEST_FNS/OBJFUN7.M+68-3
matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/TEST_FNS/OBJFUN8.M+72-3
matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/TEST_FNS/OBJFUN9.M+67-3
matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/TEST_FNS/OBJGOLD.M+71-3
matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/TEST_FNS/OBJHARV.M+78-3
matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/TEST_FNS/OBJLINQ.M+86-3
matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/TEST_FNS/OBJLINQ2.M+105-3
matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/TEST_FNS/OBJPUSH.M+75-3
matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/TEST_FNS/OBJSIXH.M+68-3
matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/TEST_FNS/RESPLOT.M+55-3
matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/TEST_FNS/SGA.M+67-3
matlab数学建模算法/遗传算法@遗传退火算法(算法简介+编程技巧+工具箱+应用大全)(含源代码)/《Matlab遗传算法工具箱及应用》源码/gatbx/gatbx-origin/SRC/TEST_FNS/SIMDOPI1.M+80-3