@PaulWAyers @tovrstra
In src/denspart/vh.py (line 137), there was a TODO comment: # TODO: projected gradient may be better.
Analysis : Currently, the optimization callback reports the standard Euclidean norm of the gradient _(np.linalg.norm(gradient))_. However, MBIS optimization involves bound constraints (populations and exponents must be positive). When parameters lie on the boundary of the feasible region, the raw gradient may be non-zero even at a local minimum (pointing outside the feasible region). This makes the standard gradient norm a poor metric for convergence in this context.
Solution : I propose checking the projected gradient norm in the log output instead of the raw norm. This involves calculating a grad_proj where components are zeroed out if they correspond to parameters at their bounds (within a tolerance) and the gradient is pushing against that bound. This would provide a mathematically correct measure of convergence for this constrained optimization problem.
- Modify optimize_pro_model in
src/denspart/vh.py .
- Move the bounds extraction so it is available inside the callback.
- Implement the masking logic to compute the projected gradient.
- Update the logging statement to report this new metric.
@PaulWAyers @tovrstra
In
src/denspart/vh.py(line 137), there was a TODO comment: # TODO: projected gradient may be better.Analysis : Currently, the optimization callback reports the standard Euclidean norm of the gradient
_(np.linalg.norm(gradient))_. However, MBIS optimization involves bound constraints (populations and exponents must be positive). When parameters lie on the boundary of the feasible region, the raw gradient may be non-zero even at a local minimum (pointing outside the feasible region). This makes the standard gradient norm a poor metric for convergence in this context.Solution : I propose checking the projected gradient norm in the log output instead of the raw norm. This involves calculating a
grad_projwhere components are zeroed out if they correspond to parameters at their bounds (within a tolerance) and the gradient is pushing against that bound. This would provide a mathematically correct measure of convergence for this constrained optimization problem.src/denspart/vh.py.