Provide gradient for fmincon when the function to minimize uses ODE
Mostrar comentarios más antiguos
I am trying to fit a model to experimental points by using the function fmincon. The function I need to minimize is defined in a file called objfunction and is as following:
mi=zeros(n_exp,n_comp);
for i=1: n_exp
mi(i,:)=(pts_exp(i,:)-pts_mod(i,:)).^2;
end
Summin=sum(sum(mi));
Where pts_exp is a matrix obtained by solving differential equations using ode15s. I set the constraints (inequalities and bounds) and use fmincon:
[para,fval]=fmincon(@(para)objfunction(pts_exp,para,t_T_exp,n0,ordre,n_exp,n_comp,reactif,n_react),param0,A,b,Aeq,beq,lb,ub,nonlcon,options);
The vector para has 864 decision variables, all of them with lower and upper bounds and it takes around 10 minutes to optimize my problem. I know that providing the gradient and the hessian can make the code run faster but I do not know how to do it since my objective function uses a matrix given by ode15s. What I mean is that I do not have an analytical expression of my function as in f(x,y)=x+y or something like that. Is there any way of providing the gradient or making the code run faster?
Any help is greatly appreciated!
Respuestas (1)
Torsten
el 8 de Oct. de 2018
0 votos
Look up "sensitivity equations for ordinary differential equations".
The solution of these equations give you the derivative of the ODE solution with respect to the parameters.
Best wishes
Torsten.
4 comentarios
Alan Weiss
el 8 de Oct. de 2018
The technique that Torsten refers to is outlined in the documentation topic Use a Gradient Evaluation Function. To do this involves solving a larger set of ODEs than the original set (you would need 864 new variables in your ODE). So it is not clear to me whether there would be a worthwhile speedup. But, if it is important to you, then you can try and see.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
FM
el 9 de Oct. de 2018
Torsten
el 9 de Oct. de 2018
More than 864 parameters to be fitted ? You are kidding, aren't you ?
FM
el 9 de Oct. de 2018
Categorías
Más información sobre Solver Outputs and Iterative Display en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!