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

9 vues (au cours des 30 derniers jours)
harof
harof le 24 Nov 2022
if函数是想用来在max(PT-K,0)>0时取I=1
if函数嵌套的位置有些问题,请问如何解决?
[ctmp,ceqtmp] = feval(confcn{3},X,varargin{:});这句话什么意思?

Réponse acceptée

cojamaw
cojamaw le 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)];

Plus de réponses (0)

Catégories

En savoir plus sur Gamma Functions 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!