Why does it take forever to solve my optimization problem (using ode45 and fmincon)?
Afficher commentaires plus anciens
To estimate kinetic parameters in a kinetic model, I use experimental data to fit the rate constants in the differential equations. For this reason,I use fmincon to minimize an objective function (sum of squared errors between calculated and measured values). The calculation worked pretty good until I changed the definition of the objective function. Now calculations run for hours without results. I tried to reduce MaxFunctionEvaluations (before it was 1e10, now 100) but the error "Solver stopped prematurely.fmincon stopped because it exceeded the function evaluation limit, options.MaxFunctionEvaluations = 200 (the selected value)." appears.
Are there some tools or tricks to find out, where the calculation got stuck?
Réponse acceptée
Plus de réponses (1)
John D'Errico
le 29 Nov 2016
Modifié(e) : John D'Errico
le 29 Nov 2016
0 votes
How can we know what you did that now causes the problem? Since we do not see your code, we cannot read your mind. You changed something, and it no longer works. Surprise! What, EXACTLY did you change?
Changing the optimizer parameters as you have is generally not (almost never) the solution.
You might use the debugger to put a break point inside your objective function. That will stop it so you can check the current parameters at each call. Or just dump out the values of the parameters, as well as the current objective function produced.
Note that doing so will generate lots of calls at essentially the same location when it computes a gradient. So it will help to understand how an optimizer works, so you understand what it is doing at any point in time.
Finally, there are always problems when you try to use an optimizer on top of another tool like an ODE solver or an integration, or another optimization. The internal computation is only accurate to within some tolerance. So when you change the parameters slightly to compute a gradient, it uses a finite difference approximation to compute the gradient. But if there is error in the result, that gradient computation will HIGHLY magnify any error. Remember that a derivative is essentially delta_y/delta_x, as delta_x approaches zero. But if y becomes essentially a random variable, with a significant noise variance, then the gradient as computed becomes worthless.
The point is that these computations will often be nasty. Essentially your objective function is not differentiable at a fine scale. But fmincon (and other optimizers) assume that it is differentiable.
3 commentaires
Teresa Schubert
le 30 Nov 2016
The vector "a" you create with the command
a=cs(length(cs),:);
only contains the simulated values of cs1, cs2, cs3 and cs4 for the final time of the integration.
So. if your code were correct, your vector of experimental data "cd" should only contains 4 elements, namely cd1(tend),cd2(tend),cd3(tend) and cd4(tend).
Is this really the case ?
Another point:
Usually problems from chemical engineering are stiff. You should change the ODE solver from ODE45 to ODE15S.
Best wishes
Torsten.
Teresa Schubert
le 30 Nov 2016
Catégories
En savoir plus sur Get Started with Curve Fitting Toolbox dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
