⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 binaryexample.m

📁 matlab6.5辅助小波分析与应用例程 希望对大家能有所帮助
💻 M
字号:
echo on% This script shows how to use the ga using a float representation. % You should see the demos for% more information as well. gademo1, gademo2, gademo3global bounds% Setting the seed back to the beginning for comparison sakerand('seed',0)% Crossover OperatorsxFns = 'simpleXover';xOpts = [.4];% Mutation OperatorsmFns = 'binaryMutation';mOpts = [0.005];% Termination OperatorstermFns = 'maxGenTerm';termOps = [200]; % 200 Generations% Selection FunctionselectFn = 'roulette'selectOps = [];% Evaluation FunctionevalFn = 'gaMichEval';evalOps = [];type gaMichEval% Bounds on the variablesbounds = [-3 12.1; 4.1 5.8];% GA Options [epsilon float/binar display]gaOpts=[1e-6 0 1];% Generate an intialize population of size 20startPop = initializega(20,bounds,'gaMichEval',[],[1e-6 0]);% Lets run the GA% Hit a return to continuepause[x endPop bestPop trace]=ga(bounds,evalFn,evalOps,startPop,gaOpts,...    termFns,termOps,selectFn,selectOps,xFns,xOpts,mFns,mOpts);% x is the best solution foundx% Hit a return to continuepause% endPop is the ending populationendPop% Hit a return to continuepause% trace is a trace of the best value and average value of generationstrace% Hit a return to continuepause% Plot the best over timeclfplot(trace(:,1),trace(:,2));% Hit a return to continuepause% Add the average to the graphhold onplot(trace(:,1),trace(:,3));% Hit a return to continuepause% Lets increase the population size by running the defaults% rand('seed',0)termOps=[100];[x endPop bestPop trace]=ga(bounds,evalFn,evalOps,[],gaOpts,termFns,termOps,...    selectFn,selectOps);% x is the best solution foundx% Hit a return to continuepause% endPop is the ending populationendPop% Hit a return to continuepause% trace is a trace of the best value and average value of generationstrace% Hit a return to continuepause% Plot the best over timeclfplot(trace(:,1),trace(:,2));% Hit a return to continuepause% Add the average to the graphhold onplot(trace(:,1),trace(:,3));echo off

⌨️ 快捷键说明

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