📄 e692.m
字号:
%------------------------------------------------------------------------
% Example 6.9.2: Transportation Planning
%------------------------------------------------------------------------
% Initialize
clear
clc
n = 6; % number of variables
r = 5; % equality constraints
s = n; % inequality constraints
m = 100; % maximum iterations
trials = 5; % number of runs
tol = 1.0e-5; % error tolerance
x0 = [666,666,667,400,400,400]';
x = zeros (n,1);
u = zeros (r,1);
g = fopen ('e692.dat','w');
% Compute optimal solution for different penalty parameters
fprintf ('Example 6.9.2: Transportation Planning\n');
for j = 1 : trials
mu = 10^(j-2);
fprintf ('\nFinding optimal x when mu = %g ...\n',mu)
[x,ev,k] = penalty (x0,mu,tol,m,'funf692','funp692','funq692');
u = funp692(x);
fprintf (g,'\n%10.1f & %10.2f & %10.4f \\\\',mu,funf692(x),norm(u,inf));
fprintf (g,'\n & & \\\\');
show ('Iterations',k)
show ('Function evaluations',ev)
show ('x',x)
show ('f(x)',funf692(x))
show ('||p(x)||',norm(u,inf))
end
fclose(g);
%------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -