JuMP optimization with registered function

I am trying to use JuMP for parameter estimation. In my julia script, I have a line “JuMP.register(model, :fun_to_min, 24, fun_to_min, autodiff=true);” That is, I have “fun_to_min” which takes 24 parameters and returns a cost. After registering the function, I run “JuMP.optimize!(model)”.

In my “fun_to_min” function, I set up an ODEproblem and then solve it for a duration of time. So, I get a data_matrix (size: [num_variables, num_time_samples]) as a result of the integration.

Now, if I cheat and just pass the ODEproblem in fun_to_min the correct set of parameters, “JuMP.optimize!(model)” succeeds and gives me an objective value of 0, which makes sense. If, however, I initialize each of my 24 parameters to some initial guess (@variable(model, 0.1 <= p1 <= 50.0, start = 1.0);), then, I see the an error with my integrator: “[CVODES ERROR] CVode
At t = 0 and h = 5.3762e-15, the corrector convergence test failed repeatedly or with |h| = hmin.”

I have observed failure with other integrators also. For what I’m trying to do, this is not unexpected. Put another way, it is very likely that the initial guesses for the parameters will be very wrong. Having said that, is there some way for JuMP to recoginize that there is an error when calling my fun_to_min, and keep trying with a new set of parameters?

I want JuMP to notice that there fun_to_min had an error and keep trying.