You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
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:
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
The text was updated successfully, but these errors were encountered: