亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? ga.m

?? 這是一個用遺傳算法GA處理實際問題的實例
?? M
字號:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Function simpleGA:
% This Function illustrate how a GA could be used to evolve a population of 
% randomly generated bianry strings. The Fitness of an individual is determined 
% by the number of '1'. An archive will store the fittest individual at each
% generation and the evolutionary trace plotted after the algorithm shows that 
% GA is capable of improving the fitness of the evolving population
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Algorithm Definations: 
% pop               An array of individuals which represent the evolving population
% pop(i)            The ith individual in the evolving population
% pop(i).chromosome The genotype value of the ith individual, which is a
%                   binary sting in this algorithm
% pop(i).fitness    The fitness of the ith individual 
% fitness_trend     An array which tracks the fitness of the archive
% pop_archive       An archive which stores the fittest individual in each generation
% matingpop         An array of individuals that are being selected for crossover and mutation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function simpleGA()
close all       % Close all active windows
clc             % Clear the command window
clear           % Initialize the memory
rand('state',1) % Modify the random number generator by considering other integers 
                % so that re-running the program without changes will not yield the 
                % same results. 
                
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Parameter Initialisation: 
% Input your own parameters below
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

POP_SIZE=10;            % Number of individuals in the population
                        % Even POP_SIZE MUST be used for proper operation
MUTATION_RATE=0.03;     % Probability of mutation (typically <.1)
CROSSOVER_RATE=0.8;     % Probability of crossover (typically near 1)
CHRMOSOME_LENGTH=30;    % Length of the chromosome
MAX_GENERATION=50;      % Number of times the loop will run  

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Algorithm Initialisation:
% The Intial Population of the algorithm will be created here. It will
% consists of POP_SIZE chrmosomes of length CHRMOSOME_LENGTH each. Each
% chrmosome will have the default fitness of 0 and each allele will be
% randomised to take the value of 0 or 1.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

for i=1:1:POP_SIZE
    pop(i).chromosome = rand(1, CHRMOSOME_LENGTH);
    pop(i).fitness = 0;
    for j=1:1:CHRMOSOME_LENGTH
        if (pop(i).chromosome(j)<0.5)
            pop(i).chromosome(j)=0;
        else
            pop(i).chromosome(j)=1;
        end
    end
end
fitness_trend=zeros(1,MAX_GENERATION);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Begin of Evolution:
% The population will be evolved here. First the fitness of each chrmosome 
% will be calcluated and the best chromosome will be stored in the archive. 
% The mating pool will be created by applying tourament selection on the 
% combined evolving population and archive. Uniform crossover and bit-flipped 
% mutation will be applied subsequently. This process will be repeated for 
% MAX_GENERATION generations 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

pop_archive=[];
for gen=1:1:MAX_GENERATION
    %Fitness Evaluation
    for n=1:1:POP_SIZE,
        pop(n).fitness = get_Fitness(pop(n).chromosome,CHRMOSOME_LENGTH);
    end
    %Archiving
    for n=1:1:POP_SIZE
        pop_archive = archive(pop(n), pop_archive);  
    end
    %Tracking the fitness of the best individual
    fitness_trend(gen)=pop_archive(1).fitness;
    
    
    %Initialise the mating pool via tournament selection
    
    %elite is appended to the current population
    if size(pop_archive,2)~= 0
         pop = [pop pop_archive];         
    end
    
    %elite replace the weakest individual of the current population 
%     if size(pop_archive,2)~= 0
%         tmp_fitness = pop(1).fitness;
%         tmp_index=1;
%         for n=2:1:POP_SIZE,
%             if pop(n).fitness < tmp_fitness
%                 tmp_fitness = pop(n).fitness;
%                 tmp_index = n;
%             end
%         end
%         pop(tmp_index)=pop_archive;
%     end
    
    
    %Tournament selection with replacement
    for n=1:1:POP_SIZE
        matingpop(n)=tournament(pop);
    end

    %Tournament selection without replacement
%     matingpop=tournament2(pop,POP_SIZE);

    %Applying the genetic operators
    pop = crossover(matingpop, CROSSOVER_RATE,CHRMOSOME_LENGTH);
    for n=1:1:POP_SIZE,
        pop(n).chromosome = mutate(pop(n).chromosome, MUTATION_RATE);
    end
end
%Plot the fitness trace
figure
plot(fitness_trend);
title('Fitness Trace');
ylabel('Fitness')
xlabel('Generations')

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% End of function simpleGA
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Function tournament:
% This Function wil randomly select two individuals from the evolving
% population. The fitter individual will be chosen and added to the
% mating pool. This will be repeated for POP_SIZE times until the mating
% pool is full
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function pair = tournament(pop)
sel = ceil(rand(1,1)*size(pop,2));
com = ceil(rand(1,1)*size(pop,2));
if pop(sel).fitness > pop(com).fitness;
    index = sel;
else
    index = com;
end
pair=pop(index);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% End of function tournament
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Function tournament 2:
% This Function will perform tournament selection without replacement. The
% parent population will be grouped in pairs. The winner of each pair for this 
% first tournament will be selected for the variation operation. This process 
% will be repeated again. The winners of both tournaments will be paired together
% where the n-th winner of both groups will be together.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function popC = tournament2(pop,pop_size)

order1=randperm(size(pop,2));
order2=randperm(size(pop,2));

for i=1:2:pop_size
    if pop(order1(i)).fitness > pop(order1(i+1)).fitness;
        index1 = order1(i);
    else
        index1 = order1(i+1);
    end
    if pop(order2(i)).fitness > pop(order2(i+1)).fitness;
        index2 = order2(i);
    else
        index2 = order2(i+1);
    end
    popC(i)=pop(index1);
    popC(i+1)=pop(index2);
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% End of function tournament 2
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Function mutate:
% This Function will mutate the different allele with a probability MUTATION_RATE 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function indnew = mutate(ind, mutation_rate)
for i=1:1:size(ind,2)
    if rand(1,1)<mutation_rate
        ind(i) = 1-ind(i) ;
    end
end
indnew = ind;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% End of function mutate
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Function crossover:
% This Function will crossover alleles between two selected chromosomes.
% Crossover will occur at a probability of CROSSOVER_RATE and if it does,
% each pairs of allele will have a 50% chance of being swapped
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function childpop = crossover(pop, crossover_rate,length);
for n=1:2:size(pop,2)
    sis = pop(n).chromosome;bro = pop(n+1).chromosome;
    if rand(1,1)<crossover_rate
        for len=1:1:length
            if rand(1,1)<0.5
                tmp = sis(len);
                sis(len)=bro(len);
                bro(len)=tmp;
            end
        end
    end
    pop(n).chromosome = sis;
    pop(n+1).chromosome = bro; 
end
childpop = pop;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% End of function crossover
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Function archive:
% This Function will select the better individuals and store it into pop_archive
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function popC = archive(ind, popB)
%Add if archive is empty
if size(popB,2)==0,
    popB(1).chromosome = ind.chromosome;
    popB(1).fitness = ind.fitness;
end

if (popB(1).fitness < ind.fitness)
    popB(1).chromosome = ind.chromosome;
    popB(1).fitness = ind.fitness;
end
popC=popB;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% End of function archive
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Function get_fitness:
% This Function evaluate the fitness of a given chrmosome which is given by
% the number of '1'. The optimal solution is a bianry string with all
% alleles equal to one
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function fitness = get_Fitness(ind, length)
fitness = 0;
for len=1:1:length
    fitness = fitness + ind(len);
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% End of function get_fitness
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美影院一区二区| 成人av在线影院| 色综合久久88色综合天天免费| 91精品国产综合久久久久久久久久| 国产精品视频在线看| 免费观看日韩av| 在线亚洲+欧美+日本专区| 久久久久久免费毛片精品| 无码av免费一区二区三区试看| 26uuu精品一区二区三区四区在线| 国产精品国产三级国产| 激情亚洲综合在线| 欧美久久婷婷综合色| 亚洲视频在线一区观看| 国产精品一线二线三线精华| 3d成人动漫网站| 亚洲精品国产第一综合99久久| 成人小视频在线| 26uuu国产在线精品一区二区| 亚洲高清视频的网址| 91蝌蚪porny成人天涯| 国产欧美日韩精品一区| 经典三级视频一区| 91精品国产日韩91久久久久久| 亚洲综合一二三区| 91亚洲大成网污www| 国产精品青草综合久久久久99| 国产在线不卡视频| 精品伦理精品一区| 久久精品国产第一区二区三区| 欧美精品在线视频| 天天操天天干天天综合网| 欧美色老头old∨ideo| 伊人一区二区三区| 色婷婷av一区二区三区大白胸| 亚洲欧美怡红院| 97久久久精品综合88久久| 国产精品麻豆99久久久久久| 国产a区久久久| 国产日韩影视精品| 成人午夜av影视| 中文一区在线播放| hitomi一区二区三区精品| 国产精品素人视频| 97久久超碰国产精品| 日韩码欧中文字| 一本久久a久久免费精品不卡| 综合婷婷亚洲小说| 色综合中文综合网| 国产精品久久久久一区| 国产成人亚洲综合a∨猫咪| 国产午夜精品一区二区三区视频 | 国产制服丝袜一区| 久久综合久久综合久久综合| 国产一区二区三区四区五区入口 | 精品国产免费视频| 精品一区二区免费看| 国产亚洲欧美中文| 成人av在线影院| 亚洲精品你懂的| 欧美人与性动xxxx| 另类小说综合欧美亚洲| 精品电影一区二区三区| 国产成人亚洲精品狼色在线 | 日韩欧美专区在线| 国产尤物一区二区| 中文字幕一区在线观看| 99久久精品一区二区| 亚洲欧美日韩中文播放| 欧美色中文字幕| 蜜臀久久久99精品久久久久久| 精品国产一区二区国模嫣然| 国产精选一区二区三区| 国产精品久久久久久久久果冻传媒| 91免费视频网| 色老头久久综合| 亚洲h动漫在线| 2欧美一区二区三区在线观看视频| 国产成人亚洲精品狼色在线| 亚洲视频图片小说| 制服丝袜一区二区三区| 国产精品一区二区免费不卡| 综合久久给合久久狠狠狠97色| 在线免费亚洲电影| 九九在线精品视频| 亚洲三级免费电影| 日韩一区二区三区视频| 国产ts人妖一区二区| 亚洲综合小说图片| 欧美大肚乱孕交hd孕妇| 99综合影院在线| 青青青爽久久午夜综合久久午夜| 国产亚洲欧美日韩日本| 欧美伊人久久大香线蕉综合69| 奇米影视7777精品一区二区| 日本一区二区成人| 欧美日韩国产a| 高清不卡一区二区在线| 亚洲成人777| 欧美激情在线观看视频免费| 欧美色精品在线视频| 国产成人在线影院| 午夜成人免费电影| 国产精品狼人久久影院观看方式| 欧美色中文字幕| 成人免费观看男女羞羞视频| 丝袜国产日韩另类美女| 国产精品久久久99| 日韩精品一区二区三区四区视频 | 精东粉嫩av免费一区二区三区| 亚洲欧美日韩精品久久久久| 欧美成人国产一区二区| 色婷婷久久99综合精品jk白丝| 国产麻豆精品theporn| 亚洲成人手机在线| 亚洲欧洲av另类| 久久久久久一二三区| 欧美精选午夜久久久乱码6080| 成人黄色电影在线| 韩国中文字幕2020精品| 午夜视频在线观看一区二区| 国产精品高潮呻吟| 久久久久久久av麻豆果冻| 88在线观看91蜜桃国自产| 96av麻豆蜜桃一区二区| 国产一区二区伦理片| 人人精品人人爱| 91浏览器打开| 国产一区二区三区四区五区美女 | 国产精品第一页第二页第三页| 欧美v亚洲v综合ⅴ国产v| 欧美酷刑日本凌虐凌虐| 日本国产一区二区| 99视频精品免费视频| 国产经典欧美精品| 精品无码三级在线观看视频| 日韩电影免费一区| 亚洲成人免费电影| 一区二区三区四区不卡在线| 亚洲欧洲日韩av| 国产婷婷一区二区| 欧美精品一区二区在线观看| 欧美高清精品3d| 精品视频资源站| 在线观看一区不卡| 色狠狠av一区二区三区| 99国产精品久久久久久久久久| 成人免费视频视频在线观看免费| 国内精品伊人久久久久av一坑 | 国产精品灌醉下药二区| 欧美韩日一区二区三区四区| 久久久亚洲精华液精华液精华液| 日韩精品一区在线| 日韩精品一区二区三区视频播放| 69成人精品免费视频| 欧美精品高清视频| 在线观看欧美黄色| 91久久免费观看| 欧美主播一区二区三区| 91福利资源站| 欧洲一区二区三区免费视频| 色激情天天射综合网| 色94色欧美sute亚洲线路一ni| 一本久道中文字幕精品亚洲嫩| 97成人超碰视| 日本丶国产丶欧美色综合| 色婷婷激情综合| 欧美视频你懂的| 69成人精品免费视频| 日韩视频一区在线观看| 欧美不卡激情三级在线观看| 精品不卡在线视频| 国产视频一区在线播放| 国产精品你懂的在线| 亚洲人成精品久久久久| 一区二区三区不卡在线观看| 亚洲观看高清完整版在线观看 | 国产免费成人在线视频| 国产精品久久久久毛片软件| 亚洲视频每日更新| 一二三四社区欧美黄| 日韩国产一二三区| 国产一区二区三区免费观看| 国产精品一区不卡| 97久久精品人人做人人爽50路| 欧美伊人久久大香线蕉综合69| 91精品国产91热久久久做人人| 精品久久久久香蕉网| 欧美激情综合网| 一区二区三区四区蜜桃| 日韩 欧美一区二区三区| 国产乱码一区二区三区| caoporm超碰国产精品| 91久久线看在观草草青青| 欧美一区二区免费视频| 国产三级一区二区三区| 亚洲精品成人少妇| 777久久久精品| 国产性做久久久久久| 一区二区三区免费看视频|