Hello, I'm running two maximization problem and I want to use the output for additional condition in "If" function. How can I use the output as parameter? (e.g. X+z in this code)
Here is the Code:
ClearAll[Y ,X,z,w]
T0=1
Hmu=0.2
SA=10+Hmu
SB=10-Hmu
Sigma=1.5
K=10
r=1.02
gamma=0.1
Vi=2
Eye=2
ZC=(K-SA)/Sigma
ZB=(K-SB)/Sigma
S0=(SA-gamma(Sigma^2)(Vi /Eye ))/r
C0=((SA-gamma(Sigma^2)(Vi /Eye ) -K)(1-CDF[NormalDistribution[0, 1], ZC+gamma*Sigma*(Vi /Eye ) ])+(PDF[NormalDistribution[0, 1], ZC+gamma*Sigma*(Vi /Eye ) ])Sigma)/r
A=(((Vi /Eye ) -X)S0-Y*C0)r+X*SA-(gamma/2)(X^2)(Sigma^2)
B=(((Vi /Eye ) -X)S0-Y*C0)r +(X +Y)SA -(gamma/2)(X +Y) ^2(Sigma^2) -Y *K
Q=(((Vi /Eye ) -z)S0-w*C0)r+z*SB-(gamma/2)(z^2)(Sigma^2)
P=(((Vi /Eye ) -z)S0-w*C0)r +(z +w)SB -(gamma/2)(z +w) ^2(Sigma^2) -w *K
UA=-Exp[-gamma*A]*(CDF[NormalDistribution[0, 1], ZC+gamma*X *Sigma ]) -Exp[-gamma*B]*(1-CDF[NormalDistribution[0, 1], ZC+gamma*(X +Y )*Sigma ])
UB=-Exp[-gamma*Q ]*(CDF[NormalDistribution[0, 1], ZB+gamma*z *Sigma ]) -Exp[-gamma*P ]*(1-CDF[NormalDistribution[0, 1], ZB+gamma*(z +w )*Sigma ])
NMaximize[UA ,{X >=0,X<=2,Y>=-1,Y<=1},{X ,Y}]
NMaximize[UB ,{z >=0,z<=2,w>=-1,w<=1},{z ,w}]
If[X+z<=2,1,0]