非线性优化约束条件中if函数嵌套问题?。

11 ビュー (過去 30 日間)
harof
harof 2022 年 11 月 24 日
回答済み: cojamaw 2022 年 11 月 24 日
if函数是想用来在max(PT-K,0)>0时取I=1
if函数嵌套的位置有些问题,请问如何解决?
[ctmp,ceqtmp] = feval(confcn{3},X,varargin{:});这句话什么意思?

採用された回答

cojamaw
cojamaw 2022 年 11 月 24 日
function [c, ceq] = confun(x)
c = [];
gamma=3;
P0=100;
d=0.0269;
sigma=0.3315;
K=88.254;
T=4.3122;
rf=0.0435;
W0=1.1465;
phi=0.0941;
ns=0.0029;
no=0.0089;
PT=@(u)(P0*exp((rf-d-sigma^2/2)*T+u*T^(1/2)*sigma));
WT=@(u)((x(1)+W0)*exp(rf*T)+x(2)*exp(d*T)*PT(u)+x(3).*max(PT(u)-K,0));
Wd=@(u)((phi+W0)*exp(rf*T)+ns*exp(d*T)*PT(u)+no*max(PT(u)-K,0));
F=@(u)(WT(u).^(1-gamma).*normpdf(u));
Fd=@(u)(Wd(u).^(1-gamma).*normpdf(u));
I = @(u) (PT(u)-K)>0 + 0;
G=@(u)WT(u).^(-gamma).*(x(2)*exp(d*T)+x(3)*I(u)).*PT(u)./P0.*normpdf(u);
Gd=@(u)Wd(u).^(-gamma).*(ns*exp(d*T)+no*I(u)).*PT(u)./P0.*normpdf(u);
ceq =[quadgk(@(u) F(u) - Fd(u),-Inf,Inf),quadgk(@(u) G(u) - Gd(u),-Inf,Inf)];

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGamma Functions についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!