Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of fixed params in scipy minimizer #2439

Open
1 task done
andrewfowlie opened this issue Jan 11, 2024 · 0 comments
Open
1 task done

Implementation of fixed params in scipy minimizer #2439

andrewfowlie opened this issue Jan 11, 2024 · 0 comments
Labels
feat/enhancement New feature or request needs-triage Needs a maintainer to categorize and assign

Comments

@andrewfowlie
Copy link

Summary

I'm using some fixed parameters in a pyhf model and scipy optimization. I noticed that fixed parameters are implemented using equality constraints. Only two minimization methods support equality constraints: 'SLSQP' (the default) and ''trust-constr'.

If you use a method that does not support them, you only get a warning, e.g., `RuntimeWarning: Method TNC cannot handle constraints.' And the minimization doesn't respect the constraints, i.e., the fixed parameters are not fixed. This wasn't obvious to me as a user.

Can I suggest that if there are fixed params, and method that does not support constraints is attempted, it throws an exception?

I wonder, though, if we could do a more general way of implementing fixed parameters. Something like:

def minimize_with_fixed_param_at_0(func, fixed_param, *args, **kwargs):
    def wrapped(x):
        y = [fixed_param] + x
        return func(y)
    return minimize(wrapped, *args, **kwargs)

It needs more sophisticated logic to combine the fixed params with the unfixed ones (here I just assume the fixed parameter is at index 0). This would not rely on methods that support equality constraints.

Additional Information

Code of Conduct

  • I agree to follow the Code of Conduct
@andrewfowlie andrewfowlie added feat/enhancement New feature or request needs-triage Needs a maintainer to categorize and assign labels Jan 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat/enhancement New feature or request needs-triage Needs a maintainer to categorize and assign
Projects
None yet
Development

No branches or pull requests

1 participant