From 46928c6b2f9439fb0664cf01e820c568feae8ec1 Mon Sep 17 00:00:00 2001 From: tlatorre Date: Tue, 14 Aug 2018 15:08:54 -0500 Subject: add lower and upper bounds for the fit parameters --- src/fit.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/fit.c b/src/fit.c index afbf5bb..bf4d018 100644 --- a/src/fit.c +++ b/src/fit.c @@ -53,8 +53,7 @@ double nll(unsigned int n, const double *x, double *grad, void *params) int fit_event(event *ev, double *fmin) { - double x[7]; - double ss[7]; + double x[7], ss[7], lb[7], ub[7]; int rv; nlopt_opt opt = nlopt_create(NLOPT_LN_SBPLX, 7); @@ -77,6 +76,25 @@ int fit_event(event *ev, double *fmin) ss[5] = 0.1; ss[6] = 1.0; + lb[0] = 1.0; + lb[1] = -1000.0; + lb[2] = -1000.0; + lb[3] = -1000.0; + lb[4] = 0.0; + lb[5] = 0.0; + lb[6] = 0.0; + + ub[0] = 100000.0; + ub[1] = 1000.0; + ub[2] = 1000.0; + ub[3] = 1000.0; + ub[4] = M_PI; + ub[5] = 2*M_PI; + ub[6] = 400.0; + + nlopt_set_lower_bounds(opt, lb); + nlopt_set_upper_bounds(opt, ub); + nlopt_set_initial_step(opt, ss); rv = nlopt_optimize(opt,x,fmin); -- cgit