Hi all guys!
i have a problem with the genetic algorithm solver.
i'm trying to use "ga" to get close to a minimum and then use an fmincon solver starting from the point that ga gimme in output (i used fmincon becouse all parameters must be positive).
There is my program (vasicek intrest rate model):
format long g
r0=0.0187;
options = optimset('Algorithm','interior-point');
A = [-1 0 0 0 ; 0 -1 0 0 ; 0 0 -1 0 ; 0 0 0 -1];
b = [0 0 0 0];
T=[1 2 3 4 5];
v=[0.990 0.980 0.971 0.961 0.951];
for i=1:5
R(i)=(-1/T(i))*log(v(i));
end
sf = @(x)sum(arrayfun(@(K)parameterfun(x,T(K),R(K)),1:length(T)));
x = ga(sf,4,A,b);
y = fmincon(sf,x,A,b,[],[],[],[],[],options);
where th funct is: (it is long but is well defined)
function f = parameterfun(x,T,R)
r0=0.0187;
f = ((x(1)+((x(2)*x(4))/x(3))-((1/2)*((x(2)^2)/x(3))))+((r0)-(x(1)+((x(2)*x(4))/x(3))-((1/2)*((x(2)^2)/x(3)))))*(1/(x(3)*T))*(1-(exp(-x(3)*T)))+((x(2)^2)/(4*((x(3)^3)*T)))*(1-(exp(-x(3)*T)))^2)-R;
when I use a fixed starting point and there is no problem, when I try with the genetic algorithm and then apply fmincon i get strange results of order 10^9.
i cant find the problem. can anyone help me ?
there is another way to get close to a minimum point without having a starting point ?
thank you so much!