非线性优化约束条件中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 CenterFile Exchange 中查找有关 Gamma Functions 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!