New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to set up evolution steps #4
Comments
What would the repeat step look like? Will we make many many |
We would indeed need a step class for each of the operations, i.e. for evaluate, survive, filter, map, breed, repeat, etc. |
I really like the idea of being able to pickle everything [I recall multicore having very poor support for lambda's too]. The library might get a bit more verbose but this is more than compensated by clearer debugging and general code safety. I'll make a new branch and a small start. |
Mhm. Just to check. @rogiervandergeer Don't we want this?
Explicit is better than implicit, but what happens if you pass the required |
Another thing. What is a good standard for the name that we attach to a step. Currently I am thinking about something like this;
But it may be a good standard to force that order number such that user cannot overwrite that. |
Well, I'm not sure if we want to store the
and voilà no more |
When it comes to names... that is a tough one. I like having a default name with an order number in there. I'm open for discussion on whether we want to enforce it. But then we have to decide what we do when we combine multiple evolutions. Say we create an evolution:
which will then have steps
What will the steps of this evolution be called?
Option 1 us ugly, 2 is difficult, so perhaps 3 is best? Or suppose we create an evolution that contains the above:
What do we call these? Perhaps we don't even want to add these to the evolution, but make a |
Is option 2 that hard?
Sure if things are nested it may get tricky, but we can fix this by adding This means we may have a slightly different |
The true complexity will appear once we introduce grouping though ... but I am willing to let that one slide for now and worry about that once we're at the grouping stage. |
Here you introduce the order number inside the It isn't too hard to add the order number to a step when adding it (since we add it from the |
Ah. I was mainly concerning myself with the I guess if you are really debugging though... you're probably going to take the effort to add names to steps right? I am wondering how much the number we'll add is going to help you with debugging. If you need a number to tell you what |
True. Perhaps a random 4-digit uuid is good enough? Then we just need a nice function that prints the whole evolution in a human-readable format ( |
what would we want to put in |
The idea of The
but we could provide much more information. |
Would an ordered dict perhaps be better than a list for a chain? That way we might pickle the |
I don't see the benefit of an ordered dict. Would you want to store the name in the key? I agree a keyworded argument for mutate is good. Currently it is |
The evolution will contain a chain of steps, which can in sequence be applied to a population. In principle these steps will need to be no more than functions - we could simply do
These step functions would simply look like:
but we shouldn't replace them by lambda's for the sake of pickling.
In order to provide arguments to the methods of the population inside such functions we could
re-define the functions with the proper arguments for each time we use them.
Now on the other hand it would be nice to be able to give a name to such a step, for example to identify the step in logging or to make it easier to debug. We could achieve that by creating a
namedtuple
with name and function fields. Once we have anamedtuple
, we could decide to put the arguments not baked into the function, but in their own field. The application of the steps would then look likeWe can take it one step further by defining an
EvolutionStep
class, and make classes for each of the step types inheriting from that class. This would look like:which has the very nice property that the arguments are well taken care off as the function is only defined once (as a method to the step class). In this case the
Evolution.evaluate
method canlook as simple as
On the other hand we will need to define a separate
Step
class for each operation.@koaning, any preference?
The text was updated successfully, but these errors were encountered: