[ https://issues.apache.org/jira/browse/MATH-655?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13098520#comment-13098520 ]
Sébastien Brisard commented on MATH-655: ---------------------------------------- In the attached file {{iteration-manager.zip}} is a new version which follows Phil's suggestion to use composition instead of inheritance. We now have three classes * {{IterationManager}}: besides the methods to add/remove listeners, fire events and manage the iteration count, I've added {{shouldStop()}}, which returns {{true}} if the iterations should be stopped. This method should be called by the iterative algorithm at the end of each iteration; it allows the implementation of a custom stopping criterion. What do you think of this option (?) * {{IterationListener}} * {{IterationEvent}} I should also add that I took Greg's suggestion into account, and replaced {{ArrayList}} by {{CopyOnWriteArrayList}}. Finally, you will see that {{TooManyEvaluationsException}} is potentially thrown. In the final version of these classes, I'll define a proper {{TooManyIterationsException}}, with localized message and so on. > General framework for iterative algorithms > ------------------------------------------ > > Key: MATH-655 > URL: https://issues.apache.org/jira/browse/MATH-655 > Project: Commons Math > Issue Type: New Feature > Affects Versions: 3.0 > Reporter: Sébastien Brisard > Priority: Minor > Labels: algorithm, events > Attachments: iteration-manager.zip, iterative-algorithm.zip > > > Following the thread [Monitoring iterative > algorithms|http://mail-archives.apache.org/mod_mbox/commons-dev/201108.mbox/%3CCAGRH7HrgcgoBA=jcoKovjiQU=TjpQHnspBkOGNCu7oDdKk=k...@mail.gmail.com%3E], > here is a first attempt at defining a general enough framework for iterative > algorithms at large. At the moment, the classes provide support for > * maximum number of iterations > * events handling > ** initialization event (prior to entering the main loop), > ** iteration event (after completion of one iteration), > ** termination event (after termination of the main loop). > These classes do not yet provide support for a stopping criterion. > Some points worth to note > * For the time being, the classes are part of the o.a.c.m.linear package. > * For the time being, {{IterativeAlgorithm.incrementIterationCount()}} throws > a {{TooManyEvaluationsException}}. If the proposed new feature is integrated > into CM, then a proper {{TooManyIterationsException}} should be created, from > which the former could derive. -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira