• 大小: 2KB
    文件类型: .m
    金币: 1
    下载: 0 次
    发布日期: 2021-01-05
  • 语言: Matlab
  • 标签: matlab  DFP  

资源简介

运用matlab编写的最优化理论基础课程中DFP法

资源截图

代码片段和文件信息

%function [out1out2]=DFP(jxx11x21)
       syms x1 x2 a x;
        jx=log(x1)-x2-1/100*log(x1-1)+100*(x1^2+x2^2-4)^2;
        g=[diff(jxx1);diff(jxx2)];
        x11=2;
       x21=0;
        flag=1;
        while flag
            I=[10;01]
            g1=subs(g[x1x2][x11x21])
            k=1;
            h1=I;
            while 1
                d1=-h1*g1
                %******此处用一维搜索确定a        subs(hxax)   a=fminsearch(char(subs(hxax))0)
                hx=subs(jx[x1x2][x11+a*d1(11)x21+a*d1(21)])
                a=fminsearch(char(subs(hxax))0)
                x12=x11+a*d1(11)
                x22=x21+a*d1(21)
                syms a;
               if  norm(subs(jx[x1x2][x12x22]))<=0.01
                   flag=0;
                   break;

评论

共有 条评论