• 大小: 3.04MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-08-12
  • 语言: 其他
  • 标签:

资源简介

多维函数搜索:(1)最速下降法 (2)阻尼牛顿法 (3)共轭梯度法 (4)鲍维尔法 (5)变尺度法  (6)单纯形法

资源截图

代码片段和文件信息

#include “AimFunction.h“
#include 

// 第一个测试函数:
// f(x1x2)=x1^2 + 2*x2^2 -2*x1*x2 - 4*x1
// x0=(11) e=0.1
double aimf1(double *xdouble* gradientdouble** haisai=NULL)
{
if (NULL!=gradient) // 求梯度
{
gradient[0]=2*x[0]-2*x[1]-4;
gradient[1]=4*x[1]-2*x[0];
}
if (NULL!=haisai) // 海塞矩阵
{
haisai[0][0]=2;  haisai[0][1]=-2;
haisai[1][0]=-2; haisai[1][1]=4;
}
return x[0]*x[0]+2*x[1]*x[1]-2*x[0]*x[1]-4*x[0];
}


// 第二个测试函数:
// f(xy)=x^4-2xxy-2xy+xx+2yy+4.5x-4y+4
// 初始点(-2.54.25)ey=0.01
double aimf2(double *xdouble* gradientdouble** haisai=NULL)
{
if (NULL!=gradient) // 求梯度
{
gradient[0]=4*x[0]*x[0]*x[0] - 4*x[0]*x[1] -2*x[1] + 2*x[0] + 4.5;
gradient[1]=-2*x[0]*x[0] -2*x[0] + 4*x[1] -4;
}

if (NULL!=haisai) // 海塞矩阵
{
haisai[0][0]=12*x[0]*x[0]-4*x[1]+2;
haisai[0][1]=-4*x[0]-2;
haisai[1][0]=-4*x[0]-2;
haisai[1][1]=4;
}
return (x[0]*x[0]*x[0]*x[0] - 2*x[0]*x[0]*x[1] - 2*x[0]*x[1] 
+x[0]*x[0] + 2*x[1]*x[1] + 4.5*x[0] - 4*x[1] +4);
}

// 四维测试函数:
// f(x)=(x1+10*x2)^2 + 5*(x3-x4)^2 + (x2-2*x3)^4 + 10*(x1-x4)^4
// 初始点:x0=[3 -1 0 1]  f(x0)=215
// 最优解:x =[0  0 0 0]  f(x)=0
double aimf3(double *xdouble* gradientdouble** haisai=NULL)
{
if (NULL!=gradient) // 求梯度
{
gradient[0]=2*(x[0]+10*x[1])+40*(x[0]-x[3])*(x[0]-x[3])*(x[0]-x[3]);
gradient[1]=20*(x[0]+10*x[1])+4*(x[1]-2*x[2])*(x[1]-2*x[2])*(x[1]-2*x[2]);
gradient[2]=10*(x[2]-x[3])-8*(x[1]-2*x[2])*(x[1]-2*x[2])*(x[1]-2*x[2]);
gradient[3]=-10*(x[2]-x[3])-40*(x[0]-x[3])*(x[0]-x[3])*(x[0]-x[3]);
}

if (NULL!=haisai) // 海塞矩阵
{
haisai[0][0]=2+120*(x[0]-x[3])*(x[0]-x[3]);
haisai[0][1]=20;
haisai[0][2]=0;
haisai[0][3]=-120*(x[0]-x[3])*(x[0]-x[3]);

haisai[1][0]=20;
haisai[1][1]=200+12*(x[1]-2*x[2])*(x[1]-2*x[2]);
haisai[1][2]=-24*(x[1]-2*x[2])*(x[1]-2*x[2]);
haisai[1][3]=0;

haisai[2][0]=0;
haisai[2][1]=-24*(x[1]-2*x[2])*(x[1]-2*x[2]);
haisai[2][2]=10+48*(x[1]-2*x[2])*(x[1]-2*x[2]);
haisai[2][3]=-10;

haisai[3][0]=-120*(x[0]-x[3])*(x[0]-x[3]);
haisai[3][1]=0;
haisai[3][2]=-10;
haisai[3][3]=10+120*(x[0]-x[3])*(x[0]-x[3]);
}
return ((x[0]+10*x[1])*(x[0]+10*x[1]) + 5*(x[2]-x[3])*(x[2]-x[3]) + (x[1]-2*x[2])*(x[1]-2*x[2])*(x[1]-2*x[2])*(x[1]-2*x[2])
+ 10*(x[0]-x[3])*(x[0]-x[3])*(x[0]-x[3])*(x[0]-x[3]));
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2009-12-11 22:41  unconstrained_optimization\
     目录           0  2009-11-25 13:14  unconstrained_optimization\.svn\
     文件         663  2009-11-25 13:14  unconstrained_optimization\.svn\entries
     目录           0  2009-10-31 11:51  unconstrained_optimization\.svn\prop-base\
     文件          53  2009-10-31 11:51  unconstrained_optimization\.svn\prop-base\unconstrained_optimization.suo.svn-base
     目录           0  2009-10-31 11:51  unconstrained_optimization\.svn\props\
     目录           0  2009-11-09 21:03  unconstrained_optimization\.svn\text-base\
     文件         943  2009-10-31 11:51  unconstrained_optimization\.svn\text-base\unconstrained_optimization.sln.svn-base
     文件       72192  2009-11-09 21:03  unconstrained_optimization\.svn\text-base\unconstrained_optimization.suo.svn-base
     目录           0  2009-11-25 13:14  unconstrained_optimization\.svn\tmp\
     目录           0  2009-11-23 23:01  unconstrained_optimization\.svn\tmp\prop-base\
     目录           0  2009-11-23 23:01  unconstrained_optimization\.svn\tmp\props\
     目录           0  2009-11-23 23:01  unconstrained_optimization\.svn\tmp\text-base\
     目录           0  2009-11-08 21:14  unconstrained_optimization\debug\
     目录           0  2009-11-25 13:14  unconstrained_optimization\debug\.svn\
     文件         285  2009-11-25 13:14  unconstrained_optimization\debug\.svn\entries
     目录           0  2009-10-31 11:51  unconstrained_optimization\debug\.svn\prop-base\
     目录           0  2009-10-31 11:51  unconstrained_optimization\debug\.svn\props\
     目录           0  2009-10-31 11:51  unconstrained_optimization\debug\.svn\text-base\
     目录           0  2009-11-25 13:14  unconstrained_optimization\debug\.svn\tmp\
     目录           0  2009-11-23 23:01  unconstrained_optimization\debug\.svn\tmp\prop-base\
     目录           0  2009-11-23 23:01  unconstrained_optimization\debug\.svn\tmp\props\
     目录           0  2009-11-23 23:01  unconstrained_optimization\debug\.svn\tmp\text-base\
     文件       77824  2009-11-09 21:02  unconstrained_optimization\debug\unconstrained_optimization.exe
     文件      667392  2009-11-09 21:02  unconstrained_optimization\debug\unconstrained_optimization.ilk
     文件      658432  2009-11-09 21:02  unconstrained_optimization\debug\unconstrained_optimization.pdb
     目录           0  2009-12-11 22:41  unconstrained_optimization\unconstrained_optimization\
     文件     7982080  2009-12-11 22:41  unconstrained_optimization\unconstrained_optimization.ncb
     文件         943  2009-10-31 09:56  unconstrained_optimization\unconstrained_optimization.sln
     文件       68096  2009-12-11 22:41  unconstrained_optimization\unconstrained_optimization.suo
     目录           0  2009-11-25 13:14  unconstrained_optimization\unconstrained_optimization\.svn\
............此处省略50个文件信息

评论

共有 条评论

相关资源