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

François Laferrière commented on MATH-1658:
-------------------------------------------

The MATH-1658.patch is the unarguably the simplest solution. I would just add 
(as you suggested earlier) a protected default constructor (with no 
parameters). That would be an intermediate solution that would still be 
compatible with current caller code.

Nevertheless this imply that default constructors shall be provided in all 
descendant classes of BaseOptimizer (otherwise, the modification to 
BaseOptimizer is pointless).

It seems that this has impact on some *Optimizer that have "final" fields (e.g. 
NonLinearConjugateGradientOptimizer). Those "final" modifiers should be removed 
to allow homogenous API. To prevent problems, all classes should have a 
"checkParameters()" method. For the moment, some *Optimizer have one, other 
don't. Typically, existing implementations of checkParameters() are called at 
the end of parseOptimizationData() code.

> 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
>         Attachments: 
> MATH-1658-ConvergenceChecker-implements-OptimizationData.patch, 
> MATH-1658.patch
>
>
> 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)

Reply via email to