资源简介

MATLAB的梯度法,内点法,外点法,罚函数,惩罚函数,线性梯度法,源程序,按照提示输入,可直接运行-MATLAB' s gradient method, interior point method, outside the point of law, penalty function, penalty function, the linear gradient method, source code, follow the prompts to input, can be directly run

资源截图

代码片段和文件信息

function Conjugate_grads_method
%This function applies only the function like
%this:fx=X1^2+X2^2-X1*X2-10*X1-4*X2+60

syms X1 X2 real;
fx=X1^2+X2^2-X1*X2-10*X1-4*X2+60;
X0=[0;0];
e=0.0001;
k=0;
n=2;
t=1;
N=100;
S0_f=[diff(fxX11);diff(fxX21)];
value_S0_1=inline(vectorize(S0_f(1))‘X1‘‘X2‘);
value_S0_2=inline(vectorize(S0_f(2))‘X1‘‘X2‘);
S0=-[value_S0_1(X0(1)X0(2));value_S0_2(X0(1)X0(2))];
options=optimset(‘Display‘‘off‘);
fx_value=inline(vectorize(fx)‘X1‘‘X2‘);

while sqrt(sum(S0.^2))>e&k    t=t+1;
    k=k+1;
    if k==(n+1)
        k=0;
        S0_f=[diff(fxX11);diff(fxX21)];
        value_S0_1=inline(vectorize(S0_f(1))‘X1‘‘X2‘);
        value_S0_2=inline(vectorize(S0_f(2))‘X1‘‘X2‘);
        S0=-[value_S0_1(X0(1)X0(2));value_S0_2(X0(1)X0(2))];
    end
    syms r real;
    XX=X0+r.*S0;
    r_fx=fx_value(XX(1)XX(2));
    diff_r_fx=inline(vectorize(diff(r_fxr1))‘r‘);
    r=fzero(diff_r_fx1options);
    X=X0+r.*S0;
    grad_S1=[value_S0_1(X(1)X(2));value_S0_2(X(1)X(2))];
    bk=sum(grad_S1.^2)/sum(S0.^2);
    S0=-grad_S1+bk*S0;
    X0=X;
end
disp(k);
disp(X0);

        
        

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       1170  2007-11-17 23:26  Conjugate_grads_method.m

     文件       2090  2007-11-22 19:41  ExteriorPenaltyFunctionMethod.m

     文件        959  2007-11-20 22:22  InteriorPenaltyFunctionMethod.m

     文件       1108  2007-11-12 17:39  Jacobi_iterative_method.m

     文件        701  2007-11-14 15:53  Conjugate_grad_2d.m

     文件       2655  2007-11-22 21:29  LinearCofficientMethod.m

----------- ---------  ---------- -----  ----

                 8683                    6


评论

共有 条评论