how to minimize distance with optimization
Ältere Kommentare anzeigen
hi all i am new member i did had some difficulties to express my point, here is the real problem: i did optimize moments at the variance unit=0.0003 so i did get Z1* Z2* Z3*
now the problem is how to optimize the portfolio so that mean,skewness kurtosis are near the optimum value Z1* Z2* Z3* at the same time under investor preferences parameters ex alpha=1 beta=0 gamma=0 so the investor is more interested in mean return. i have to solve
minimize Z=(0.0003+d1)^alpha +(0.0003+d3)^beta +(0.0003+d4)^gamma
subject to
mean(Rtilt*X) +d1=Z1* (mean +d1=Z1*)
mean(((Rtilt*X)-mean(Rtilt*X)).^3)/(.0003*sqrt(.0003)) +d3=Z3* (skewness +d3=Z3*)
mean(((Rtilt*X)-mean(Rtilt*X)).^4)/(.0003*.0003) +d4=Z4* (kurtosis +d4=Z4*)
somme Xi=1 and 0=<Xi=<0.35 d1,d3,d4 >=0
X'*V*X=0.0003 V(7x7)=cov(Rtilt)
alpha,beta,gamma are known numbers (investor preferences)
Z1*,Z3*,Z4* are known numbers (goals)
Rtilt is known matrix (132x7) : returns
i want to minimize distances(unknown) d1,d3,d4 to get my vector of weights X(7x1):unknown.
alpha,beta,gamma are parameteres that i use it can be(1,0,0) or anything i want.
what function to use ? i tried fgoalattain but am not sure cause i cant handle parameters alpha beta gamma.
Thanks
5 Kommentare
As written, this your problem doesn't seem to do what you're asking it to do. Is y a number? If so, then this has a solution. If y is a variable, then the answer is to set y to be negative infinity.
What does your problem have to do with the description? If you want to minimize the distance, then why not something like:
minimize Z = abs(y - 1) + 3*abs(y - 4)
instead of what you've written? As an aside, you can solve this analytically pretty easily.
In any case, your solution is:
f = @(y)(abs(y - 1) + 3*abs(y - 4));
y = fminsearch(f,0);
x1 = abs(y - 1);
x2 = abs(y - 4);
jean claude
am 1 Apr. 2016
Hmm, this is a little harder than your original problem. You probably want to use a constrained solver like fmincon. I don't your problem as well as you do, but it's fairly straightforward. First, get rid of the auxillary d variables; you're not directly choosing them:
Step 1) Rewrite objective and set up objective functions
func = @(X,Rtilt,Z1,Z3,Z4)(0.0003+Z1-mean(Rtilt*X))^alpha +(0.0003+Z3-mean(((Rtilt*X)-mean(Rtilt*X)).^3)/(.0003*sqrt(.0003)))^beta +(0.0003+Z4 - mean(((Rtilt*X)-mean(Rtilt*X)).^4)/(.0003*.0003))^gamma
Now, you have an objective function solely in terms of X and your parameters. Next, load in the parameters and declare the function; this lets you easily change the parameters later on. (You could also make another parameter to replace 0.0003 if you want).
%set Rtilt, Z1, Z3, Z4 etc here
obj_func = @(X)(func(R_tilt,Z1,Z3,Z4));
Now, you have a function which just takes in |X| and returns a value.
Step 2) Minimize this function subject to your constraints; using fmincon for example
%set up a starting point for X
X_0 = %some values you think might work
Set up your constraints on X:
A_eq = ones(length(X_0),1);
b_eq = 1;
%this is the equality constraint A_eq*X = 1; you may need to transpose A_eq here
Set up your bounds on X
lb = zeros(1,length(X_0));
ub = 0.35*ones(1,length(X_0))
%upper and lower bounds
Write a function and save it in your directory which takes in your non-linear constraint:
function [c,ceq] = mycon(X,V)
c = 0;
c_eq = X'*V*X - 0.0003;
end
In your main file, create a wrapper for it in and pass the V matrix:
nonlcon = @(X)mycon(X,V);
Then, feed in all your inputs to the optimizer:
options = optimset('Display', 'iter');
x = fmincon(obj_func,X0,[],[],Aeq,beq,lb,ub,nonlcon,options)
You will probably have to play with this a little bit to get it working exactly right, and they way you want to do it, but this is the basic workflow.
jean claude
am 1 Apr. 2016
nadia meftah
am 10 Feb. 2017
how to defined Z1, Z2,Z3
Antworten (1)
Torsten
am 1 Apr. 2016
The problem as stated does not have a solution since it is unbounded.
Choose
x1=(M-9)/4, x2=(M+3)/4 and y=(13-M)/4
for arbitrary M.
Then you get M as the value of your objective function, and your constraints are satisfied.
Best wishes
Torsten.
1 Kommentar
jean claude
am 1 Apr. 2016
Kategorien
Mehr zu Special Functions finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!