fmincon非线性约束方程可以实现参数化吗。

10 vues (au cours des 30 derniers jours)
N/A
N/A le 15 Nov 2022
Réponse apportée : N/A le 15 Nov 2022
本人现在在尝试优化问题的参数化。具体程序如下
主程序
function [x,fval,exitflag,output,lambda,grad,hessian] = opt3(x0,lb)
%% This is an auto generated MATLAB file from Optimization Tool.
%% Start with the default options
options = optimoptions('fmincon');
%% Modify options setting
options = optimoptions(options,'Display', 'on');
options = optimoptions(options,'PlotFcns', { @optimplotx @optimplotfunccount @optimplotfval @optimplotstepsize });
[x,fval,exitflag,output,lambda,grad,hessian] = ...
fmincon(@fun3,x0,[],[],[],[],lb,[],@fun4,options);
end
目标函数
function f = fun3(x)
f = (0.003287/x(1)^1.34-0.06213/x(2)^0.8878+269.9/x(1)^1.34./x(2)^0.8879)/2;
end
约束方程
function [c,ceq] = fun4(x)
ceq = x(2)-(x(2)^3)/40/(x(1)^2)+(x(1)^5)/3456/(x(1)^4)-(x(1)^7)/599040/(x(1)^6)-x(1)*sin(x(2)/2/x(1))+(x(2)^2)/6/x(1)-(x(2)^4)/336/(x(1)^3)+(x(2)^6)/42240/(x(1)^5)-(x(2)^8)/1612800/(x(1)^7)+x(1)*cos(x(2)/2/x(1))-90;
c=[];
end
现在希望可以实现90这个值自动调用其他的值,最好通过函数传递,跪求哪位大神给解决方案:'(:'(:'(

Réponse acceptée

N/A
N/A le 15 Nov 2022
你可以这样传,我试了一下,可以用:
约束文件名:function [c,ceq] = fun4(x,p)
约束代码:将90改为p
给定p: p=90
fmincon调用改为:[x,fval,exitflag,output,lambda,grad,hessian] = ...
fmincon(@fun3,x0,[],[],[],[],lb,[],@(x) fun4(x,p),options)

Plus de réponses (0)

Catégories

En savoir plus sur 数学 dans Help Center et File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!