<>现在的matlab7.0里面就有官方的遗传算法的命令 点击help ga </P>
<>就可以查阅相关的用法。不过值得注意的是:在matlab7.0中有</P>
<>许多语法都与以前的版本不相同,所以在编写程序的时候一定</P>
<P>要学会使用在线帮助才是。</P>
<P>>> help ga<BR> GA Genetic algorithm solver.<BR> X = GA(FITNESSFCN,NVARS) finds the minimum of FITNESSFCN using<BR> GA. NVARS is the dimension (number of design variables) of the<BR> FITNESSFCN. FITNESSFCN accepts a vector X of size 1-by-NAVRS,<BR> and returns a scalar evaluated at X. <BR> <BR> X = GA(FITNESSFCN,NAVRS,OPTIONS) finds the minimum for<BR> FITNESSFCN with the default optimization parameters replaced by values<BR> in the structure OPTIONS. OPTIONS can be created with the GAOPTIMSET<BR> function.<BR> <BR> X = GA(PROBLEM) finds the minimum for PROBLEM. PROBLEM is a structure<BR> that has the following fields:<BR> fitnessfcn: <Fitness Function><BR> nvars: <Number of design variables><BR> options: <Options structure created with GAOPTIMSET><BR> randstate: <Optional field to reset rand state><BR> randnstate: <Optional field to reset randn state><BR> <BR> [X, FVAL] = GA(FITNESSFCN, ...) returns FVAL, the value of the fitness<BR> function FITNESSFCN at the solution X.<BR> <BR> [X,FVAL,REASON] = GA(FITNESSFCN, ...) returns the REASON for stopping.<BR> <BR> [X,FVAL,REASON,OUTPUT] = GA(FITNESSFCN, ...) returns a<BR> structure OUTPUT with the following information: <BR> randstate: <State of the function RAND used before GA started><BR> randnstate: <State of the function RANDN used before GA started><BR> generations: <Total generations, excluding HybridFcn iterations><BR> funccount: <Total function evaluations><BR> message: <GA termination message><BR> <BR> [X,FVAL,REASON,OUTPUT,POPULATION] = GA(FITNESSFCN, ...) returns the final<BR> POPULATION at termination.<BR> <BR> [X,FVAL,REASON,OUTPUT,POPULATION,SCORES] = GA(FITNESSFCN, ...) returns the<BR> SCORES of the final POPULATION.<BR> <BR> There are several steps to the GA:<BR> population generation<BR> scoring<BR> loop<BR> fitness <BR> scaling <BR> selection <BR> crossover <BR> mutation <BR> scoring <BR> migration<BR> output <BR> termination testing<BR> end loop<BR> Each of these steps can be controlled by the options structure created <BR> by GAOPTIMSET.<BR> <BR> Example:<BR> Minimize 'rastriginsfcn' fitness function of numberOfVariables = 2<BR> x = ga(@rastriginsfcn,2)<BR> Display plotting functions while GA minimizes<BR> options = gaoptimset('PlotFcns',...<BR> <a href="mailt{@gaplotbestf,@gaplotbestindiv,@gaplotexpectation,@gaplotstopping" target="_blank" >{@gaplotbestf,@gaplotbestindiv,@gaplotexpectation,@gaplotstopping</A>});<BR> [x,fval,reason,output] = ga(@rastriginsfcn,2,options)<BR> <BR> See also gaoptimset, fitnessfunction, patternsearch, @.</P>
<P><BR> Reference page in Help browser<BR> doc ga</P>
|