📄 ga_h248f.m
字号:
function PI=GA_H248F(chro)
global MIN_offset MUL_factor
% function PI=GA_H248F(chro)
% Fitness function evaluation
% 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
% chro is the input argument and is a vector of 2 elements
% MIN_offset, MUL_factor should be declared and values assigned
% before calling this function, such as
% MIN_offset=0; MUL_factor=1;
% in the other program. However, if you want to use function
% alone,(both of the above varaibles are not declared
% before), this program will give you DEFAULT values as
% MIN_offset=0; MUL_factor=1; %<== DEFAULT
% CALLING example:
% PI=GA_H248F([1.3 3.5])
% PenChen Chou, 4-11-2002
if isempty(MIN_offset)
MIN_offset=0;
end
if isempty(MUL_factor)
MUL_factor=1;
end
%chro=10.^chro;
x=chro(1); y=chro(2);
PI=(x+y);
a1=-2*x+y; a2=x+3*y; a3=4*x+y;
MIN=1e5;
if a1> 3, PI=PI-MIN; end;
if a2>16, PI=PI-MIN; end;
if a3>20, PI=PI-MIN; end;
attached_part;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -