早教吧 育儿知识 作业答案 考试题库 百科 知识分享

还是昨天那个问题,用matlab优化一个方程,d=x-(x*x-40-6*a*x)^(0.5),多一个条件,x在10到20之间,a在0到1之间,求d取最小值,同时a尽可能的接近1.如果要加权的话,就随便设一个,要过程,麻烦您了请问

题目详情
还是昨天那个问题,用matlab优化一个方程, d=x-(x*x-40-6*a*x)^(0.5) ,多一个条件, x在10到20之间, a在0到1之间,求d取最小值,同时a尽可能的接近1 . 如果要加权的话,就随便设一个, 要过程,麻烦您了
请问怎么加权重呢,比如a的权取0.2 ,d取0.8
▼优质解答
答案和解析
[x,feval,flag]= fmincon(@(x)x(1)-(x(1)*x(1)-40-6*x(2)*x(1))^(0.5),[11;0.9],[],[],[],[],[10 0],[20 1])
Warning: Trust-region-reflective method does not currently solve this type of problem,
using active-set (line search) instead.
> In fmincon at 439
Local minimum found that satisfies the constraints.
Optimization completed because the objective function is non-decreasing in
feasible directions, to within the default value of the function tolerance,
and constraints were satisfied to within the default value of the constraint tolerance.

Active inequalities (to within options.TolCon = 1e-006):
lower upper ineqlin ineqnonlin
2 1
x =
20
0
feval =
1.0263
flag =
1
d取最小值,同时a尽可能的接近1,这有个权重,d取最小值,a=0,a尽可能的接近1,d就不是最小值
你可以看下三维图,用下面的语句画图
ezsurf('x-(x.*x-40-6*y*x)^(0.5)',[10 20 0 1])