许可优化
许可优化
产品
产品
解决方案
解决方案
服务支持
服务支持
关于
关于
软件库
当前位置:服务支持 >  软件文章 >  Matlab线性/非线性规划优化算法(5):高级求解技巧

Matlab线性/非线性规划优化算法(5):高级求解技巧

阅读数 5
点赞 0
article_banner

值得单独一说的是fminunc, fminseach, fminbnd的区别:

   fminunc只能用于求解连续 函数 ,对于变量没有限制

   fminbnd只能用于求解单变量函数,

   fminsearch只能用于求解多变量函数,

%%
clc
clear all
fun = @(x) -abs(1/x);
x0 = 1;
x1= -3;
x2 = 3;

我们解这个函数的最值,在0出可以取到最值,但函数在0处没有导数:

[x,fval,exitflag,output] = fminbnd(fun,x1,x2)
[x,fval,exitflag,output] = fminsearch(fun,x0)
[x,fval,exitflag,output] = fminunc(fun,x0)

求解这个函数,可以看到结果:

x =

   8.8818e-16


fval =

  -1.1259e+15


exitflag =

     1


output = 

  struct with fields:

    iterations: 17
     funcCount: 18
     algorithm: 'golden section search, parabolic interpolation'
       message: 'Optimization terminated:↵ the current x satisfies the termination criteria using OPTIONS.TolX of 1.000000e-04 ↵'

 
Exiting: Maximum number of function evaluations has been exceeded
         - increase MaxFunEvals option.
         Current function value: -1267650600228229401496703205376.000000 


x =

   7.8886e-31


fval =

  -1.2677e+30


exitflag =

     0


output = 

  struct with fields:

    iterations: 100
     funcCount: 200
     algorithm: 'Nelder-Mead simplex direct search'
       message: 'Exiting: Maximum number of function evaluations has been exceeded↵         - increase MaxFunEvals option.↵         Current function value: -1267650600228229401496703205376.000000 ↵'


Solver stopped prematurely.

fminunc stopped because it exceeded the function evaluation limit,
options.MaxFunctionEvaluations = 1.000000e+02.


x =

   2.2204e-16


fval =

  -4.5036e+15


exitflag =

     0


output = 

  struct with fields:

       iterations: 1
        funcCount: 101
         stepsize: 1.0000
     lssteplength: 1.0000
    firstorderopt: 3.0223e+23
        algorithm: 'quasi-newton'
          message: '↵Solver stopped prematurely.↵↵fminunc stopped because it exceeded the function evaluation limit,↵options.MaxFunctionEvaluations = 1.000000e+02.↵↵'

只有fminbnd的exitflag是1, 其他两个都是0, 因为这是一个单变量函数,所以fminsearch不能使用,又因为在0出不可导,所以fminunc也不能使用。


免责声明:本文系网络转载或改编,未找到原创作者,版权归原作者所有。如涉及版权,请联系删


相关文章
技术文档
QR Code
微信扫一扫,欢迎咨询~
customer

online

联系我们
武汉格发信息技术有限公司
湖北省武汉市经开区科技园西路6号103孵化器
电话:155-2731-8020 座机:027-59821821
邮件:tanzw@gofarlic.com
Copyright © 2023 Gofarsoft Co.,Ltd. 保留所有权利
遇到许可问题?该如何解决!?
评估许可证实际采购量? 
不清楚软件许可证使用数据? 
收到软件厂商律师函!?  
想要少购买点许可证,节省费用? 
收到软件厂商侵权通告!?  
有正版license,但许可证不够用,需要新购? 
联系方式 board-phone 155-2731-8020
close1
预留信息,一起解决您的问题
* 姓名:
* 手机:

* 公司名称:

姓名不为空

姓名不为空

姓名不为空
手机不正确

手机不正确

手机不正确
公司不为空

公司不为空

公司不为空