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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? genetic.m

?? 一系列好用的用戶友好的啟發式優化算法
?? M
?? 第 1 頁 / 共 2 頁
字號:
function [sol, fval, evals] = genetic(varargin)
%GENETIC                         Optimization using genetic algorithm
%
%   GENETIC(func, popsize, lb, ub) tries to find the global optimum of 
%   the fitness-function [func], using a basic genetic algorithm. The 
%   population size set by [popsize], and the boundaries for each 
%   dimension are set by the vectors [lb] and [ub], respectively. 
%
%   [sol, fval, evals] = GENETIC(...) returns the trial vector found to 
%   yield the global minimum in [sol], and the corresponding function value 
%   by [fval]. The total amount of function evaluations that the algorithm
%   performed is returned in [evals].
%
%   The function [func] must accept a number of input arguments [N], equal to 
%   the number of elements in the vectors [lb] or [ub]. The function must be 
%   vectorized so that inserting a matrix of [popsize]x[N] will return a 
%   vector of size [popsize] containing the corresponding function values
%   for the [N] trial vectors.
%
%   The default control parameters GENETIC uses, are
%
%       crossover probability = 0.25    Probability that an individual will 
%                                       perform a crossover
%
%       mutation probability  = 0.01    Probability that an individual gene
%                                       will mutate
%
%       convergence = 100   Maximum amount of iterations the best
%                           individual ever found should remain the best
%                           individual before the algorithm converges. This
%                           is the default convergence criterion -- see
%                           HEURSET for other options.
%
%   These values, as well as additional options, may be given manually in 
%   any extra input variables. Additionally, GENETIC may be called as 
%   GENETIC(PROBLEM), where [PROBLEM] is a complete problem-structure 
%   constructed by HEURSET.
%
%   Some optimizations require repeated evaluation of a function that takes 
%   in the order of hours per evaluation. In those cases, it might be 
%   convenient to interrupt the optimization after a few days and use the 
%   results thus far obtained. Unfortunately, usually after you interrupt a 
%   function, its results are lost. For that reason, GENETIC creates two 
%   global variables, [GENETIC_bestind] and [GENETIC_bestfval], which 
%   store the best individual and function value thus far found. When the
%   optimization is interrupted, the intermediate results from the
%   optmization are still available. Once an optimization has succesfully
%   converged, these variables are deleted from the workspace again.
%   
%   See also heurset, diffevolve, swarm, multiswarm, simanneal, godlike.

% Author: Rody P.S. Oldenhuis
% Delft University of Technology
% E-mail: oldenhuis@dds.nl
% Last edited: 02/Feb/2008


%%  initialise & parse input   
          
    % initial values
    skippop  = false;
    problem  = heurset;  
    [pop, func, popsize, lb, ub, grace, display, maxfevals, convmethod,...
     convvalue, mutationprob, crossprob] = parseprob(problem);
    
    % define temporary globals
    global GENETIC_bestfval GENETIC_bestind
 
    % common inputs
    if (nargin >= 4)
        func     =  varargin{1};
        popsize  =  varargin{2}; 
        lb       =  varargin{3};
        ub       =  varargin{4};        
    end
    
    % additional inputs
    if (nargin >= 5) 
        if ~isstruct(varargin{5})
            options = heurset(varargin{5:end});
        else
            options = varargin{5};                
        end
        [dum1, dum2, dum3, dum4, dum5, grace, display, maxfevals, convmethod,...
         convvalue, mutationprob, crossprob] = parseprob(options);
    end
    
    % if called from GODLIKE
    if (nargin == 2)  
        problem = varargin{2};  
        % errortrap
        if ~isstruct(problem)
            error('PROBLEM should be a structure. Type `help heurset` for details.')
        end 
        [pop, func, popsize, lb, ub, grace, display, maxfevals, convmethod,...
         convvalue, mutationprob, crossprob] = parseprob(problem);
        
        % make sure the options are correct        
        convmethod = 'maxiters'; 
        grace   = 0;
        display = false;
        skippop = true;
    end
    
    % if given a full problem structure
    if (nargin == 1)
        problem  = varargin{1};        
        % errortrap
        if ~isstruct(problem)
            error('PROBLEM should be a structure. Type `help heurset` for details.')
        end 
        [dum1, func, dims, popsize, lb, ub, grace, display, maxfevals, convmethod,...
                  convvalue, mutationprob, crossprob] = parseprob(problem);
    end  
    
    % initialize convergence method, setting the default values if omitted
    if strcmpi(convmethod, 'exhaustive')
        convergence  = 1;
        maxiterinpop = convvalue;
        maxiters     = inf; 
    elseif strcmpi(convmethod, 'maxiters')
        convergence  = 2;
        maxiterinpop = inf;
        maxiters     = convvalue; 
    elseif strcmpi(convmethod, 'achieveFval')
        convergence  = 3;          
        %errortrap
        if isempty(convvalue)
            error('Please define function value to achieve.')
        end        
        maxiterinpop = inf;
        maxiters     = inf;        
    else
        convergence  = 1;
        maxiterinpop = convvalue;
    end  
    
    % problem dimensions
    dims = size(lb, 2);
    
    % errortraps
    if ( (size(lb, 2) ~= 1 || size(ub, 2) ~= 1) &&...
         (size(lb, 2) ~= dims || size(ub, 2) ~= dims) )
        error('Upper- and lower boundaries must be the same size.')
    end
    if (popsize < 2)
        error('GENETIC needs a population size of at least 2.')
    end  
    
%%  initial values

    % iteration-zero values
    oldbestfit   = inf;
    oldbestind   = zeros(1, dims);
    iters        = 0;
    evals        = 0;
    improvement  = maxiterinpop;
    firsttime    = true;
    converging1  = false;
    converging2  = false;
    
    % boundaries
    if (numel(lb) == 1)
        mins   = repmat(lb, popsize, dims);
        maxs   = repmat(ub, popsize, dims); 
    end
    if (numel(lb) == numel(ub) && size(lb, 2) == dims)
        mins   = repmat(lb, popsize, 1);
        maxs   = repmat(ub, popsize, 1);                        
    end
    range  = (maxs - mins); 
    
    % Display strings
    if display        
        fprintf(1, ['\nNote that when GENETIC is interrupted, the best solution and function\n',...
                    'value are saved in global variables GENETIC_bestind and GENETIC_bestfval.\n\n']);
        fprintf(1, 'Optimizing with ');
        switch convergence
            case 1
            	fprintf(1, 'exhaustive convergence criterion...\n');
            case 2
                fprintf(1, 'maximum iterations convergence criterion...\n');
            case 3
                fprintf(1, 'goal-attain convergence criterion...\n');
        end
        fprintf(1, 'Current best solution has cost of   ------------- ');
        overfevals1  = '\n\nCould not find better solution within given maximum';
        overfevals2  = '\nof function evaluations. Increase MaxFevals option.\n\n';
        fitbackspace = '\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b';
        converge1bck = [fitbackspace, '\b\b\b\b\b\b\b\b\b\b\b'];
        converge2bck = [fitbackspace, '\b\b\b\b\b\b\b'];
        convergestr  = ', possibly converging: ';
        itersstr     = ', iterations left: ';
    end
    
%%  initialize pop
    if (~skippop)
        pop = repmat(ub, popsize, 1) - repmat(ub-lb, popsize, 1).* rand(popsize, dims);
    end
    
%%  Genetic Algorithm loop

    % replication matrices for vectorization
    poprep = ones(1, popsize);
    popvec = (1:popsize)';
    
    % loop while one of the convergence criteria is not met
    while (improvement > 0 && iters <= maxiters)
    
        % evaluate and scale fitnesses
        try
            fitnesses  = feval(func, pop);
        catch
            error('genetic:fevalerror', ...
                 ['Genetic cannot continue because the supplied cost function ',...
                  'gave the following error:\n %s'], lasterr);
        end
        if (numel(fitnesses) ~= popsize)
            error('genetic:function_not_vectorized_or_incorrect_dimensions', ...
                 ['The user-supplied cost function does not appear to get enough arguments,\n',...
                  'or is not vectorized properly. Make sure the dimensions of the limits [Lb]\n',...
                  'and [Ub] are the same as the required input vector for the function, or that\n',...
                  'the function is vectorized properly.'])            
        end
        fitproper  = fitnesses;
        fitnesses  = fitnesses ./ sum(fitnesses);       
        fitcum     = cumsum(fitnesses);
        [bestindfit, inds] = min(fitproper);
        bestind    = pop(inds, :);

        % increase function evaluations counter
        evals = evals + numel(fitnesses);
                    
        % improving solutions
        if (bestindfit <= oldbestfit)
            
            % new best individual
            oldbestind  = bestind;
            oldbestfit  = bestindfit; 
            improvement = maxiterinpop;
            
            % assign also the globals
            GENETIC_bestfval = bestindfit;
            GENETIC_bestind  = bestind;
            
            % display progress

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲一区二区三区激情| 国产精品久久久久久久久果冻传媒| 福利电影一区二区| 美女视频黄频大全不卡视频在线播放| 亚洲精品高清在线| 亚洲黄色性网站| 一区二区三区高清| 亚洲主播在线播放| 日韩电影在线观看网站| 天天爽夜夜爽夜夜爽精品视频| 亚洲综合网站在线观看| 亚洲国产精品一区二区久久| 亚洲午夜激情网页| 日韩二区三区在线观看| 老司机免费视频一区二区| 国产在线精品不卡| 成人性生交大合| 91福利视频久久久久| 欧美猛男gaygay网站| 日韩免费高清av| 国产亚洲一区字幕| 自拍偷拍亚洲综合| 日韩高清欧美激情| 国产精品99久久久久久似苏梦涵 | 337p亚洲精品色噜噜| 日韩一区二区电影在线| 国产亚洲婷婷免费| 亚洲品质自拍视频| 寂寞少妇一区二区三区| 不卡一区中文字幕| 69堂精品视频| 国产精品人妖ts系列视频| 亚洲一区二区三区爽爽爽爽爽| 肉丝袜脚交视频一区二区| 国产一区二区伦理| 欧洲一区二区三区在线| 亚洲精品一区二区三区在线观看 | 欧美性生交片4| 精品美女在线播放| 一区二区在线看| 国产在线不卡视频| 777xxx欧美| 亚洲另类色综合网站| 精品一区精品二区高清| 色综合久久久久久久久久久| 精品国产一区二区三区久久影院| 亚洲欧美在线aaa| 黄色精品一二区| 欧美午夜不卡在线观看免费| 日本一区二区三区dvd视频在线| 亚洲成人在线观看视频| 99久久久无码国产精品| 久久亚洲一级片| 日韩中文字幕一区二区三区| 97se狠狠狠综合亚洲狠狠| 精品av综合导航| 日本不卡视频一二三区| 欧美日韩日本视频| 自拍偷拍国产亚洲| 成人免费高清视频| 久久―日本道色综合久久| 免费欧美在线视频| 7777精品伊人久久久大香线蕉| 一区二区三区中文字幕精品精品 | 欧美在线观看视频一区二区三区| 国产欧美日韩不卡| 国产精品中文字幕日韩精品| 91精品国产欧美一区二区| 亚洲国产裸拍裸体视频在线观看乱了| jlzzjlzz亚洲日本少妇| 国产精品免费av| 成人黄色电影在线 | 99国产精品久久久久久久久久久| 久久麻豆一区二区| 国产最新精品免费| 亚洲精品一区二区三区蜜桃下载| 久久丁香综合五月国产三级网站 | 韩国三级中文字幕hd久久精品| 51精品国自产在线| 蜜桃av一区二区| 欧美大片国产精品| 久88久久88久久久| 久久久综合激的五月天| 国产成人在线色| 国产精品不卡一区二区三区| 99视频有精品| 一区二区三区久久| 欧美老年两性高潮| 久久66热偷产精品| 国产精品―色哟哟| 色婷婷亚洲综合| 亚洲国产你懂的| 精品免费国产一区二区三区四区| 国产在线乱码一区二区三区| 国产女人18毛片水真多成人如厕 | 欧美精品 日韩| 天天色 色综合| 精品国产伦一区二区三区观看体验| 国产麻豆精品视频| 一区二区在线观看视频| 3d动漫精品啪啪| 国产大片一区二区| 亚洲综合精品自拍| 欧美videos中文字幕| 国产成人av福利| 亚洲无人区一区| 久久久久国色av免费看影院| 色哟哟在线观看一区二区三区| 首页国产欧美久久| 国产精品拍天天在线| 欧美日韩国产综合一区二区三区| 国产最新精品免费| 亚洲午夜精品在线| 国产嫩草影院久久久久| 4438x亚洲最大成人网| 成人av手机在线观看| 美女视频一区在线观看| 国产无遮挡一区二区三区毛片日本| 成人激情综合网站| 日韩av不卡一区二区| 中文字幕一区二区日韩精品绯色| 欧美日本国产视频| www.日本不卡| 国产在线播精品第三| 亚洲成人一区在线| 最新中文字幕一区二区三区| 日韩一级片网址| 在线观看精品一区| 成人av中文字幕| 激情综合一区二区三区| 亚州成人在线电影| 亚洲色图制服诱惑| 欧美国产亚洲另类动漫| 日韩一二三区视频| 欧美男同性恋视频网站| 91浏览器打开| 99久久精品99国产精品 | 99精品桃花视频在线观看| 麻豆精品在线看| 日韩电影在线观看网站| 亚洲午夜三级在线| 亚洲最新在线观看| 亚洲色图都市小说| 国产精品国产三级国产三级人妇| 久久久综合精品| 久久久国产午夜精品| 久久久精品中文字幕麻豆发布| 欧美成人vps| 亚洲精品一区二区三区蜜桃下载| 欧美成人激情免费网| 精品国产免费人成在线观看| 欧美一区二区三区思思人| 欧美日本不卡视频| 欧美日本精品一区二区三区| 欧美日韩国产综合一区二区三区 | 国产福利不卡视频| 国产精品77777| 成人丝袜18视频在线观看| 国产精品69毛片高清亚洲| 国产成人综合网站| 99国产精品国产精品毛片| 99久久99久久精品国产片果冻| 99国产欧美另类久久久精品| 色综合视频在线观看| 欧美综合一区二区| 在线不卡中文字幕| 日韩欧美三级在线| 国产午夜久久久久| 亚洲欧美日韩国产综合| 亚洲福利视频一区| 蜜桃一区二区三区在线| 国产乱妇无码大片在线观看| 床上的激情91.| 欧洲色大大久久| 日韩欧美成人一区二区| 国产精品色哟哟| 亚洲第一成人在线| 国模套图日韩精品一区二区 | 奇米影视在线99精品| 国内久久精品视频| 91在线丨porny丨国产| 欧美日韩在线三区| 久久综合九色欧美综合狠狠| 国产精品私房写真福利视频| 亚洲成a天堂v人片| 国产一区免费电影| 欧洲av一区二区嗯嗯嗯啊| 日韩视频在线你懂得| 国产精品卡一卡二卡三| 五月天激情综合网| 国产69精品久久久久毛片 | 日韩区在线观看| 国产精品久久久久精k8| 日韩不卡一区二区| 成人av影视在线观看| 日韩欧美国产午夜精品| 亚洲美女免费在线| 国产高清精品久久久久| 欧美日免费三级在线| 欧美激情一区二区三区|