How to improve curve-fitting results using Genetic Algorithm?

5 次查看(过去 30 天)
Hello all,
I am trying to solve a curve-fitting problem using multi-objective GA (I've tried lsqcurvefit previously which didn't work well so I switch to GA hoping get better results). What I am trying to do is to fit some curves to my experminetal data using the results of a differential equation. In fact, I have a parametric differential equation that I am trying to adjust those parametres and add a number of them together to obtain my experimental curve. I have written the following codes for this task:
My parametric differential equation is incorporated into the following function:
function denaturate = firstorderDSC(T,n,D,C,A)
dndT=A*exp(D)*exp(C*1e4/T)*(1-n);
denaturate=dndT;
end
In which A, D, and C needs to be determined through curve-fitting (either GA or any other curve-fitting function)
I've also introduced another function to add-up the result of the differential equation (because I need to add multiple curves to form my final curve)
function dndt = firstorderDSC1(B,xx,m)
%a matrix that include the result of differential equation
dndt1=zeros(size(xx,1),1);
for i=1:m
% solve the differential equation with diferent initial values
odefun = @(xx,n) firstorderDSC(xx,n,B(i),B(m+i),B(2*m+i));
options = odeset('AbsTol', 1e-8,'RelTol',1e-8);%,'OutputFcn',@odeplot);
[temp,num] = ode23s(odefun, xx, 0, options);
%add-up the result of differential equation with different initial values
for k=1:size(num,1)
dndt1(k,1) = firstorderDSC(temp(k),num(k),B(i),B(m+i),B(2*m+i))+dndt1(k,1);
end
dndt=dndt1;
end
end
Finally, my main program is as follows:
clc
clear all;
close all;
%My experimental data (my curves should be fitted to these data)
[d,s,r] = xlsread('DSC.csv');
xx = d(:,2);
yy = d(:,3);
%Initial guesses for the parameters of my differential equation @firstorderDSC
B1=[198.1498,183.8,23.9814,13,132.4,203.0657,221.0482,29.9336];
m=size(B1,2);
B2=[-6.7629,-6.226,-0.8756,-0.5292,-4.55,-7.0564,-7.5,-1.1];
m2=size(B2,2);
B3=[1,1,1,1,1,1,1,1];
m3=size(B3,2);
B0=[B1,B2,B3];
m0=size(B0,2);
FitnessFunction = @(B) norm(yy-firstorderDSC1(B,xx,m)); %Fittness function
numberOfVariables = m0; % Number of decision variables
lb =[0,0,0,0,0,0,0,0,-7,-7,-7,-7,-7,-7,-7,-7,0,0,0,0,0,0,0,0]; % Lower bound
ub=[200,200,200,200,200,200,200,200,0,0,0,0,0,0,0,0,10,10,10,10,10,10,10,10]; % Upper bound
A = []; % No linear inequality constraints
b = []; % No linear inequality constraints
Aeq = []; % No linear equality constraints
beq = []; % No linear equality constraints
options = optimoptions(@gamultiobj,'CreationFcn',{@gacreationlinearfeasible},'FunctionTolerance',1e-4,...
'MaxGenerations',300,'MaxStallGenerations',200,'PopulationSize',500,'MutationFcn',{@mutationadaptfeasible},...
'CrossoverFraction',0.8,'CrossoverFcn',{@crossoverintermediate});
[B,Fval,exitFlag,Output] = gamultiobj(FitnessFunction,numberOfVariables,A,b,Aeq,beq,lb,ub,options);
%Create plot
figure;
plot(xx,firstorderDSC1(B,xx,m),xx,yy,'LineWidth',2)
legend('Experimental data (Gaussian)','Differential equation','real DSC')
ylim([-0.02 0.2])
What GA does is make all curves flat and keep only one curve which doesn't fit to my experimental data well (I have also attached B matrix that GA obtained). I don't know what should I do to improve the result of GA. I have also attached my experimetal data "DSC.csv".

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Particle Swarm 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by