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

📄 ga_ham248.m

📁 其中提到遺傳學的程式碼與應用提供給次淚相向的研究者參考下載
💻 M
字号:
% GA_HAM248.m file
% Fin max of a function of 2 varaibles
% Maximize f(x)=x1+x2 subject to
%    -2x1+x2<=3
%     x1+3x2<=16
%    4x1+x2<=20
%      x1, x2>=0

% PenChen Chou, 4-11-2002

clear all
ans=1;
who
fprintf('>>>Start this program [GA_HAM248.m] now. Please wait!\n');
pause(1)
global MIN_offset MUL_factor 
MIN_offset=0; MUL_factor=1;

%**********************************************************/
%       User can modify the following in blocks
%**********************************************************/
obj_fcn = 'GA_H248F';	% Objective function
range = [0 0
    5 5];	% Range of the input variables
IC=[]; elite=1; gen_no=20000; popuSize=50;
bit_n=50; xover_rate=1; mutate_rate=0.2;

%************************************************************
% call GA written by Chang
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);            

% Print output
%para=10.^para;
x=para(1); y=para(2); a1=-2*x+y; a2=x+3*y; a3=4*x+y;
fprintf('[Constraints]\n');
fprintf('-2x+ y=(%10.2f<= 3)\n',a1);
fprintf('  x+3y=(%10.2f<=16)\n',a2);
fprintf(' 4x+ y=(%10.2f<=20)\n',a3);
fprintf('MAX   =(%10.4f) at point (%10.6f,%10.6f)\n',x+y,x,y);

⌨️ 快捷键说明

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