📄 ga_extra2.m
字号:
% GA_extra2.m file
% Fin min of a function of 2 varaibles
% minimize f(x,y)=x*y with x+y=100, x-y>=5
% PenChen Chou, 2003-11-12
clear all
ans=1;
who
fprintf('>>>Start this program [GA_extra2.m] now. Please wait!\n');
pause(1)
global MIN_offset MUL_factor LOCUS x_data y_data
MIN_offset=0; LOCUS=0; x_data=[]; y_data=[];
MUL_factor=1;
%**********************************************************/
% User can modify the following in blocks
%**********************************************************/
obj_fcn = 'GA_fextra2'; % Objective function
range = [0
100]; % Range of the input variables
IC=[]; elite=1;
gen_no=400;popuSize=50;bit_n=40;
xover_rate=0.8;mutate_rate=0.05;
%************************************************************
% call GA_genetic
tic
[popu, popu_real, fcn_value, upper, average,...
lower, BEST_popu, popuSize, gen_no, para, best_pi,...
bit_n, xover_rate, mutate_rate]=...
GA_genetic(obj_fcn, range, IC, elite, gen_no, popuSize,...
bit_n, xover_rate, mutate_rate);
t=toc/60;
fprintf('==> Computation time is (%.2f) minutes.\n\n',t);
% SAMPLE RESULTS
%The best generation occurred at generation #152.
% x1 = 52.50000000
%==>Best fitness for MAX. problem is (2493.75000000)
%==> Computation time is (0.56) minutes.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -