genetic algorithm problems.
3 views (last 30 days)
Show older comments
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):
%Valerio Matteucci MF410 A.A 2010/11
%INPUT
format long g
r0=0.0187;
options = optimset('Algorithm','interior-point');
%vincoli per la minimizzazione (i parametri devono essere positivi)
A = [-1 0 0 0 ; 0 -1 0 0 ; 0 0 -1 0 ; 0 0 0 -1];
b = [0 0 0 0];
%costruzione di Ri (tasso d'interesse istantaneo)
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
%1)minimizzo la distanza rispetto alla struttura a termine osservata in t=0
sf = @(x)sum(arrayfun(@(K)parameterfun(x,T(K),R(K)),1:length(T)));
%A) x0 fissato
%x = [0.5388 0.1165 0.0005 1.0012];
%y = fmincon(sf,x,A,b,[],[],[],[],[],options);
%B) Algoritmo genetico
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;
%x(1)= gamma ; x(2)= rho ; x(3)= alfa ; x(4)= q
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!
0 Comments
Answers (1)
Matt J
on 26 Dec 2020
Edited: Matt J
on 26 Dec 2020
It appears that you haven't provided sufficient constraints to keep the solution bounded away from areas where the objective function diverges to negative infinity. ga, as a global optimizer, has sucessfully found this region:
x = [0.5388 0.1165 0.0005 1.0012];
[~,f0] = fmincon(sf,x,A,b,[],[],[],[],[],options)
%B) Algoritmo genetico
[~,fga] = ga(sf,4,A,b)
0 Comments
See Also
Categories
Find more on Genetic Algorithm in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!