Question for shut down the simulation in DifferentialEquations.jl

Hi everyone
I read the Q&A document of DifferentialEquations.jl and find the following statement:

if you see these warnings during a parameter estimation process, this is likely the underlying problem. Simply check sol.retcode != :Success and throw an Inf cost and most optimizers will reject steps in those parameter regimes!

My question is : throw an Inf to what? Could someone please give me an example?

This means that your cost function to the optimizer should be something like

cost(prob, good_val)
    sol = solve(prob)
    if sol.retcode != :Success
        return Inf
    return norm(sol.u .- good_value)
1 Like

Sorry… could you be more specific?
What is the cost() function for? I didn’t search out any result in help?

If you are doing any type of optimization process, you will likely have some function that you pass to the optimizer to tell it how good the solution is. That is what this cost function I gave represents.

okey… I start to understand the cost function. but it doesn’t need to be a cost() right? like in a loop of parameter estimation process,

for i in (1:10)
sol = solve(prob[i])
    if sol.retcode != :Success

Is that right?


1 Like

But what indicates how well your model describes some existing data then? (Which is presumably why you do parameter estimation?)

Actually, it is the official document mentioned the parameter estimation. I just meet a similar problem in calculating the Lyapunov spectrum, which needs a parameter to be changed in a certain range.