1、关于Trust-region-reflective算警告
该类适用于存非线性约束情况所用警告式提示使用别介意看警告信息直接忽略妨想看警告主程序调用:
opt=optimset('Algorithm', 'active-set',)
x0=[2.5 21 7]
[x,FVAL] = fmincon(@myfun,x0,[4 -1 0-18 1 0],[00],[],[],[2.2163],[3.528Inf],@mycon,opt)
2、程序现问题给初始解行域内说满足所约束条件(容易验证满足非线性等式约束c(x)<=0)
通更进步析我看非线性约束条件第四完全没能满足:
c(4) =10*w-3.56*10^5*x(1)/(x(2)^2*x(3))
式考虑x1-x3界条件尽量使c(4)取值显应该取x(1)=3.5x(2)=16x(3)=3计算c(4)=1.3378e+004值数能满足约束
至结论:所给约束条件冲突行解集合空论用优化算都能求结
顺便再说句第三约束条件疑我于x1、x2取值区间及x3100000内数取值(几万)都没发现满足第三约束条件行解
求解代码如下:
function zd1381661017193379500fmincon(@(x)4*(x(1)-5)^2+(x(2)-6)^2,[5 6],[],[],[],[],[],[],@noncon)
function [c,ceq] = noncon(x)
c(1)=-(x(1)^2+x(2)^2-64)
c(2)=x(2)-x(1)-10
c(3)=x(1)-10
ceq = []
保存成M文件运行即可。
运行输出如下:
>> zd1381661017193379500Warning: The default trust-region-reflective algorithm does not solve problems with the constraints 运册you
have specified. FMINCON will use the active-set algorithm instead. For information on applicable
algorithms, see Choosing the Algorithm in the documentation.
> In fmincon at 504
In zd1381661017193379500 at 2
Warning: Your current settings will run a different algorithm (interior-point) in a future release.
> In fmincon at 509
In zd1381661017193379500 at 2
Local minimum possible. Constraints satisfied.
fmincon stopped because the size of the current search direction is less than
twice the default value of the step size tolerance and constraints are 陪兄
satisfied to within the default value of the constraint tolerance.
<stopping 旁乱宏criteria details>
Active inequalities (to within options.TolCon = 1e-06):
lower upper ineqlin ineqnonlin
1
ans =
5.0427 6.2105
这需要一定的步骤判旦。第一、在命令行里面输入
type fmincon
显示出fmincon函数的代码,如下图。
复制这些代码到掘乱扰一个事先创建好的m文件里面,然后保存为fmincon.m文件。
第二、点击应用程序,陪段下拉
出现matlab Coder选项,点进去
第三、选择文件
然后继续就可以了
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)