# JuMP optimization with registered function

**URL:** <https://discourse.julialang.org/t/jump-optimization-with-registered-function/29445>\
**Category:** General Usage\
**Created:** [October 3, 2019, 11:14am UTC](https://discourse.julialang.org/t/jump-optimization-with-registered-function/29445 "2019-10-03T11:14:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matthew\_Overlin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/matthew_overlin/32/10533_2.png) [@Matthew\_Overlin](https://discourse.julialang.org/u/Matthew_Overlin)\
**Post date:** [October 3, 2019, 11:14am UTC](https://discourse.julialang.org/t/jump-optimization-with-registered-function/29445/1 "2019-10-03T11:14:53Z")

</div>

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.
