非线性优化约束条件中if函数嵌套问题?。
11 views (last 30 days)
Show older comments
if函数是想用来在max(PT-K,0)>0时取I=1
if函数嵌套的位置有些问题,请问如何解决?
[ctmp,ceqtmp] = feval(confcn{3},X,varargin{:});这句话什么意思?
0 Comments
Accepted Answer
cojamaw
on 24 Nov 2022
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 Comments
More Answers (0)
See Also
Categories
Find more on Gamma Functions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!