optimization - using fmin
显示 更早的评论
have a non linear maximization problem in Matlab (Max utility):
A=(((V/I)-Epsilon_A_S)*S_Initial-Epsilon_A_c*Call_Price)*
(1+r)+Epsilon_A_S*S_A-(Gamma/2)*(Epsilon_A_S^2)*(Sigma_i^2)
B=(((V/I)-Epsilon_A_S)*S_Initial-Epsilon_A_c*Call_Price)*(1+r)+
(Epsilon_A_S+Epsilon_A_c)*S_A-(Gamma/2)*(Epsilon_A_S+Epsilon_A_c)^2*(Sigma_i^2)-
Epsilon_A_c*K
z=(K-S_A)/Sigma_i
Utility_A=-exp(-Gamma*A)*normcdf(z+Gamma*Epsilon_A_S*Sigma_i)
+-exp(-Gamma*B)*(1-normcdf(z+Gamma*(Epsilon_A_S+Epsilon_A_c)*Sigma_i))
I want to maximize utility function by finding: Epsilon_A_S, Epsilon_A_c
The constraints are:
Epsilon_A_S<=2
Epsilon_A_c>=-1
All the rest are parameters.
How do I do I set this problem in Matlab?
1 个评论
Rik
2018-5-16
Sent by email:
"Dear Rik, Thank you very much for helping me with fminseach problem, as I'm doing my first steps in matlab. I still having problem for finding this equilibrium (I cannot find a feasible solution while trying to get the results in this paper in figure 1: https://www.scirp.org/journal/PaperInformation.aspx?PaperID=74734 can you please help me with that? kind regards, Yossi"
The advice offered on this page is applicable here as well. I won't invest the time to read an academic paper outside my field just to help you write code. If you write a good description of what you want to implement, you can post your question on this forum. Make sure to include what you tried and what specifically is different from your intended result. Have a read here and here. It will greatly improve your chances of getting an answer.
采纳的回答
更多回答(2 个)
Yossi
2018-5-13
2 个评论
Rik
2018-5-13
Is the pattern clear? You need to add the 1/(test)-1 with your additional constraint. I've added it in the lines below.
minimize_function=@(Epsilon_A_S,Epsilon_A_c)...
-Utility_A(Epsilon_A_S,Epsilon_A_c)+...
1/(Epsilon_A_S<=2)-1+...
1/(Epsilon_A_S>=-1)-1+...
1/(Epsilon_A_c>=-1)-1;
Yossi
2018-5-13
Yossi
2018-5-13
3 个评论
Rik
2018-5-14
You shouldn't use the answer field for comments. And about your code, I think it would help to add an else statement, change this
if fitted_Epsilon_A_S+fitted_Epsilon_B_S<V-error_model
S_Initial=S_Initial-0.0001;
Cond1=0;
end
Cond1=1;
to this
if fitted_Epsilon_A_S+fitted_Epsilon_B_S<V-error_model
S_Initial=S_Initial-0.0001;
Cond1=0;
else
Cond1=1;
end
You should really take note of the m-lint warnings, they are very useful in picking up this type of bug. If this doesn't solve your problem, use the debugger to go through your code step by step to see where unexpected things start happening.
Yossi
2018-5-14
Rik
2018-5-14
It is an anonymous function, so you will have to input the results of the fit to get a value:
Utility_A (fitted_val(1),fitted_val(2))
类别
在 帮助中心 和 File Exchange 中查找有关 Mathematics and Optimization 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!