📄 sos.m
字号:
global bounds
% Crossover Operators
rand('seed',0);
xFns = 'arithXover heuristicXover simpleXover';
xOpts = [10 0; 10 3; 10 0];
% Mutation Operators
mFns = 'boundaryMutation multiNonUnifMutation nonUnifMutation unifMutation';
mOpts = [2 0 0;3 20 3;2 20 3;2 0 0];
% Termination Operators
termFns = 'maxGenTerm';
termOps = [200]; % 200 Generations
% Selection Function
selectFn = 'normGeomSelect';
selectOps = [0.08];
% Evaluation Function
evalFn = 'locate_main';
evalOps = [];
% Bounds on the variables
bounds=[39484000 39489000;3935000 3940000;-10000 0;0 20];
% GA Options [epsilon float/binar display]
gaOpts=[1e-6 1 1];
% Generate an intialize population of size 20
startPop = initializega(20,bounds,evalFn,[1e-6 1]);
% Lets run the GA
% Hit a return to continue
% [x endPop bestPop trace]=ga(bounds,evalFn,evalOps,startPop,gaOpts,...
% termFns,termOps,selectFn,selectOps,xFns,xOpts,mFns,mOpts);
[x endPop bestPop trace]=ga(bounds,evalFn,evalOps,[],gaOpts,termFns,termOps);
x
clf
plot(trace(:,1),trace(:,2));
hold on
plot(trace(:,1),trace(:,3));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -