matlab如何求解带参数的非线性规划

matlab如何求解带参数的非线性规划,第1张

假设你的参数为:C,其声明和调用方法如下

nonlfunm

function f=nonlfun(x,C)

f=-2x(1) -3 x(2) -5 x(3);

nonlconm

function [c,ceq]=nonlcon (x,C)

ceq=[x(1)^2+ x(2)^2+x(3)^2-1];

c=[];

[x,fval]=fmincon(@nonlfun,[1,1,1],[],[],[],[],[0,0,0],[1,1,1], @nonlcon,C)

这样就可以实现带参数求优化,我没有调试,希望对你有帮助。

先保存自定义函数文件

yfunm

function y=yfun(Z)

y=-144Z(1)+935Z(2)+108Z(3)-14838Z(4)-305Z(1)Z(2)

-137Z(1)Z(3)+17629Z(1)Z(4)-2562Z(2)Z(3)

+17521Z(2)Z(4)+17114Z(3)Z(4);

y=-y;

end

然后,在命令框输入

>>A = [-1 0 0 0;1 0 0 0;0 -1 0 0;0 1 0 0;0 0 -1 0;0 0 1 0;0 0 0 -1;0 0 0 1;1 1 1 1; -1 -1 -1 -1;];

>>b==[-035; 06; -009; 015; -03; 05; -007; 009; 1; -1];

>>Z0= [04;01;042;008];

>>[zvalue yvalue] = fmincon(@yfun,Z0,A,b)

运行结果:

Optimization terminated: Magnitude of directional derivative in search

direction less than 2optionsTolFun and maximum constraint violation

is less than optionsTolCon

Active inequalities (to within optionsTolCon = 1e-006):

lower upper ineqlin ineqnonlin

4

5

9

10

zvalue =

0469134664040214

015

03

00808653359597858

yvalue =

-456721006934595

可以运行,问题主要在于你书写格式不正确,而导致错误。

运行结果如下

>> [x,y]=fmincon('fun1',[01;01;01],[],[],[],[],[01;01;01],[],'fun2',optimset)

Warning: Trust-region-reflective algorithm does not solve this type of problem, using active-set algorithm

You could also try the interior-point or sqp algorithms: set the Algorithm option to 'interior-point' or

'sqp' and rerun For more help, see Choosing the Algorithm in the documentation

> In fmincon at 472

Local minimum possible Constraints satisfied

fmincon stopped because the predicted change in the objective function

is less than the default value of the function tolerance and constraints

were satisfied to within the default value of the constraint tolerance

<stopping criteria details>

Active inequalities (to within optionsTolCon = 1e-006):

lower upper ineqlin ineqnonlin

1

x =

0627962286552050

0459703343062521

0627961945396026

y =

-5098076220590748

以上就是关于matlab如何求解带参数的非线性规划全部的内容,包括:matlab如何求解带参数的非线性规划、matlab程序 怎么用非线性规划的方法求曲面方程的最大和最小值,求最大值的程序在下面、matlab求非线性规划问题等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zz/9511981.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-29
下一篇 2023-04-29

发表评论

登录后才能评论

评论列表(0条)

保存