From: Theuns C. <the...@gm...> - 2009-08-05 19:07:02
|
Gary, Wiehann and myself have discussed this a bit and I will try to summarise it here: Algorithm.get() is legacy code that everyone was comfortable with to the extent that it now consumes CIlib. Algorithm.get() is bad because it breaks testability and it is also not a complete solution for what we sometimes want to achieve. Sometimes we want to get hold of the sub-algorithm so that we can get hold of the sub-problem; this is possible. But other times we want to get hold of the main problem, whilst executing the sub-algorithm; this is not possible. Sometimes we use Algorithm.get() to get hold of the topology with entities. And sometimes we just use Algorithm.get() so that we can know how many iterations have been executed. What we have learnt from CIlib Algorithms so far, especially MultiPopulationBasedAlgorithms, is that an Algorithm can be a composite of other Algorithms that usually results in some tree structure. Two things should ring your bells: 1. Composite design pattern. 2. Tree -> visitor design pattern; different configurable visitors depending on what you want to achieve. Also, the Algorithm class is bloated, because it has state that deals with things like the number of iterations, stopping conditions and whether the "algorithm" is still running or not. These are all things that are related to a simulation rather than an algorithm. We thought of making Algorithm an interface and moving these extra things into a separate Simulation class. This shouldn't be too difficult and might even be done before we tackle the Algorithm.get() issue. The CIlib population still needs to explore more of the search space to find the optimal solution. Regards -- Theuns On Wed, Aug 5, 2009 at 9:17 AM, Gary Pampara<gpa...@gm...> wrote: > I should mention that ideally I'm looking to remove Algorithm.get() and access > it in a more dependency injected fashion. In other words, have the Algorithm > given to me. > > Regards, > Gary > > On Wednesday 05 August 2009 09:14:06 Gary Pampara wrote: >> Hi all, >> >> The static access to Algorithm.get() is seriously annoying as it breaks >> testability of the code. >> >> I'm asking for suggestions on how to resolve this correctly. I know that >> the method is convenient, but it's not a healthy relationship to have. At >> the moment, I'm struggling to test the updates to ControlParameter due to >> the tight coupling that the Algorithm.get() method introduces. >> >> Looking forward to you ideas! >> >> Regards, >> Gary |