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

📄 floatgradexample.m

📁 matlab6.5辅助小波分析与应用例程 希望对大家能有所帮助
💻 M
字号:
echo off%load seed.matrand('seed',0);echo on% This script shows how to use the ga. You should see the demos for% more information as well. gademo1, gademo2, gademo3global bounds% Crossover OperatorsxFns = 'arithXover heuristicXover simpleXover';xOpts = [2 0; 2 3; 2 0];% Mutation OperatorsmFns = 'boundaryMutation multiNonUnifMutation nonUnifMutation unifMutation';mOpts = [4 0 0;6 10 3;4 10 3;4 0 0];% Termination OperatorstermFns = 'maxGenTerm';termOps = [10];% Selection FunctionselectFn = 'normGeomSelect';selectOps = [0.06];% Evaluation Function takes two options % prob to use gradient, prob to perform Lamarkian evolutionevalFn = 'gaZBGradEval';evalOps = [1.00 1.00];% Bounds on the variablesbounds = [-3 12.1; 4.1 5.8];% GA Options [epsilon float/binar display]gaOpts=[1e-6 1 1];% Generate an intialize population of size 80startPop = initializega(80,bounds,evalFn,evalOps,[1e-6 1]);evalOps = [1.00 0.00]; % 1 - Peform learning 0-Do not update% Lets run the GA using Baldwinian Evolution[x endPop bestPop trace]=ga(bounds,evalFn,evalOps,startPop,gaOpts,...    termFns,termOps,selectFn,selectOps,xFns,xOpts,mFns,mOpts);% x is the best solution foundxpause% endPop is the ending populationendPoppause% bestPop is the best solution tracked over generationsbestPoppause% trace is a trace of the best value and average value of generationstracepause% Plot the best over timeclfplot(trace(:,1),trace(:,2));pause% Add the average to the graphhold onplot(trace(:,1),trace(:,3));pause% Lets run the GA using Lamarkian EvolutionevalOps = [1.00 1.00];[x endPop bestPop trace]=ga(bounds,evalFn,evalOps,startPop,gaOpts,...    termFns,termOps,selectFn,selectOps,xFns,xOpts,mFns,mOpts);% x is the best solution foundxpause% endPop is the ending populationendPoppause% bestPop is the best solution tracked over generationsbestPoppause% trace is a trace of the best value and average value of generationstracepause% Plot the best over timeclfplot(trace(:,1),trace(:,2));pause% Add the average to the graphhold onplot(trace(:,1),trace(:,3));pause

⌨️ 快捷键说明

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