📄 ps_alloc.m
字号:
% PS_alloc.m file
% Fin max profits of an allocation process
% PenChen Chou, 4-8-2002
% PenChen Chou. 2005-4-18.
clear all
ans=1;
who
fprintf('>>>Start this program [PS_alloc.m] now. Please wait!\n');
pause(1)
global MTX MAX
MAX=-400;
MTX=[300 960 5 0.8
150 450 2.5 0.35
100 250 2.0 0.25
80 200 8.5 1.3
50 150 3.0 0.35];
%**********************************************************/
% User can modify the following in blocks
%**********************************************************/
obj_fcn = 'PS_falloc'; % Objective function
%range = [0 0 0 0 0
% 208 444 300 300 300]; % Range of the input variables
ranges=[-1 -1 -1 -1 -1
2.8 2.8 2.8 2.8 2.8];
gen_no=2000;popuSize=50;maxmin=1;
%************************************************************
% call GA written by Chang
tic
GA_particleswarm(obj_fcn,popuSize,gen_no,ranges,maxmin);
t=toc/60;
fprintf('==> Computation time is (%.2f) minutes.\n\n',t);
% Calculate the last result
load tempx
temp=x*MTX;
fprintf('The max profit=%10.2f\n',temp(4));
fprintf('The max weight=%10.2f(<=70000)\n',temp(1));
fprintf('The max volume=%10.2f(<=200000)\n',temp(2));
fprintf('The max cost =%10.2f(<= 3000)\n',temp(3));
fprintf('Items=[%3i %3i %3i %3i %3i]\n',x(1),x(2),x(3),x(4),x(5));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -