genetic algorithm problems.

3 views (last 30 days)
Valerio Matteucci
Valerio Matteucci on 1 Oct 2011
Edited: Matt J on 26 Dec 2020
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!

Answers (1)

Matt J
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)
Local minimum possible. Constraints satisfied. fmincon stopped because the size of the current step is less than the value of the step size tolerance and constraints are satisfied to within the value of the constraint tolerance.
f0 =
0.0527622447580981
%B) Algoritmo genetico
[~,fga] = ga(sf,4,A,b)
Optimization terminated: maximum number of generations exceeded.
fga =
-1.10369179085643e+16

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!