You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gilles Sadowski (Jira)" <ji...@apache.org> on 2023/03/31 13:47:00 UTC

[jira] [Commented] (MATH-1658) ConvergenceChecker should implement OptimizationData

    [ https://issues.apache.org/jira/browse/MATH-1658?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17707264#comment-17707264 ] 

Gilles Sadowski commented on MATH-1658:
---------------------------------------

bq. It is a bit peculiar that with BaseOptimizer, ConvergenceChecker can be passed only in constructor.

From the outset, let me state that actually, the peculiarity is rather that not all settings are passed to the constructor.
Indeed, one of the principles which we try to enforce as often as possible is _immutability_.

I now view {{OptimizationData}} as kind-of a "hack" (but it was meant to try and fix more blatant problems of the previous design); but I don't say that there is an urgent need to refactor, even though the contents of package [{{o.a.c.math4.legacy.fitting.leastsquares}}|https://commons.apache.org/proper/commons-math/commons-math-docs/apidocs/org/apache/commons/math4/legacy/fitting/leastsquares/package-summary.html] is an indication of how things could be done (noting that the functionality there was previously within the {{optim}} package).

It may indeed be more consistent to treat all settings in the same way.
However, if so, I wouldn't maintain two ways of passing {{OptimizationData}} arguments; that is, we should drop the constructor way.  It can done now because 4.0 allows compatibility breaking (and we release a "beta" version).


> ConvergenceChecker should implement OptimizationData
> ----------------------------------------------------
>
>                 Key: MATH-1658
>                 URL: https://issues.apache.org/jira/browse/MATH-1658
>             Project: Commons Math
>          Issue Type: Improvement
>          Components: legacy
>    Affects Versions: 4.0-beta1
>            Reporter: François Laferrière
>            Priority: Minor
>
> It is a bit peculiar that with BaseOptimizer, ConvergenceChecker can be passed only in constructor.
> It should be possible to change ConvergenceChecker at any other time.
> Further it is a bit strange that the constructor do not accept other OptimizationData.
> In my use cases, I need to create an optimizer once with complex OptimizationData and reuse it many time with very few changes (including changing the ConvergenceChecker).
> So, I suggest that
>  * ConvergenceChecker implements OptimizationData.
>  * protected BaseOptimizer(ConvergenceChecker<PAIR> checker) is replaced by protected BaseOptimizer(OptimizationData... optData) 
> Doing so is compatible with existing code and provide much more flexibility.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)