diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/fit.c | 51 |
1 files changed, 47 insertions, 4 deletions
@@ -288,7 +288,7 @@ int fit_event(event *ev, double *xopt, double *fmin) fpars.epsrel = 1e-1; fpars.fast = 1; nlopt_set_ftol_abs(opt, 1.0); - nlopt_set_maxeval(opt, 100); + nlopt_set_maxeval(opt, 10); for (i = 0; i < sizeof(startingParameters)/sizeof(startingParameters[0]); i++) { memcpy(x,x0,sizeof(x)); @@ -296,6 +296,29 @@ int fit_event(event *ev, double *xopt, double *fmin) x[2] = startingParameters[i].y; x[3] = startingParameters[i].z; + /* Only fit for the direction and t0 when doing the "quick" + * minimizations. To do this we set the lower bound equal to the upper + * bound for these parameters which eliminates them from the + * minimization. + * + * See https://nlopt.readthedocs.io/en/latest/NLopt_Reference/. */ + lb[0] = T0; + lb[1] = x[1]; + lb[2] = x[2]; + lb[3] = x[3]; + lb[7] = 0.0; + lb[8] = 0.0; + + ub[0] = T0; + ub[1] = x[1]; + ub[2] = x[2]; + ub[3] = x[3]; + ub[7] = 0.0; + ub[8] = 0.0; + + nlopt_set_lower_bounds(opt, lb); + nlopt_set_upper_bounds(opt, ub); + guess_direction(ev,x+1,&x[4],&x[5]); x[6] = guess_t0(ev,x+1); @@ -310,9 +333,29 @@ int fit_event(event *ev, double *xopt, double *fmin) memcpy(x,xopt,sizeof(x)); - /* Reset path coefficients. */ - x[7] = 0.0; - x[8] = 0.0; + /* Reset the lower and upper bounds. */ + lb[0] = Tmin; + lb[1] = -1000.0; + lb[2] = -1000.0; + lb[3] = -1000.0; + lb[4] = -INFINITY; + lb[5] = -INFINITY; + lb[6] = 0.0; + lb[7] = -10.0; + lb[8] = -10.0; + + ub[0] = 10000.0; + ub[1] = 1000.0; + ub[2] = 1000.0; + ub[3] = 1000.0; + ub[4] = INFINITY; + ub[5] = INFINITY; + ub[6] = 400.0; + ub[7] = 10.0; + ub[8] = 10.0; + + nlopt_set_lower_bounds(opt, lb); + nlopt_set_upper_bounds(opt, ub); /* Now, we do the "real" minimization. */ fpars.epsrel = 1e-4; |