-
Notifications
You must be signed in to change notification settings - Fork 263
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
New meta strategies #777
New meta strategies #777
Conversation
There are a number of tests failing (that at a glance look genuine) but I took a quick look at why the docs weren't building. It seems to be because we mock I'm not entirely sure why this is breaking for this particular strategy (we have other strategies that make use of |
I'm working on the tests... I need to rerun the strategy timing notebook to check the long run time values. One of the new strategies, MWERandom, is going to be hard to test as fully since it picks a random team each time. |
Yeah I thought that. As long as the lines get hit and we have some cases covered I'm happy... |
The issue with MWERandom is that it ends up in a classifier filter test and it's classifier changes based on the instantiation. So while the classification is correct, the test that compares the two strategy sets fails randomly if the teams cause different classifiers in the meta strategy. |
Help on the last two tests is appreciated. I suspect one is due to the MetaWinner reset bug I fixed and the other is MWERandom, we'll need a strategy to exclude it somehow. |
I've pushed some code to I've fixed the filterset test, not by dropping
I'm just going to take a look at the other failing test now :) EDIT: At some stage I thought that my fix on #782 would have helped with this so my |
I didn't quite follow what the bug was and what the fix is. Looks like you've removed the |
Adaptive still has its reset method, I just thought it was bad form to call it in the constructor. The MetaWinner bug was that the cumulative scores were being recorded in the attributes of the players in the team and not being reset. This tripped your test on repeated deterministic matches for MetaWinnerDeterministic (being the only deterministic meta strategy) and has gone unnoticed for the other MetaWinner variants until now. In other words retaining state made the outcomes not repeatable. The fix is reseting the scores in MetaWinner's reset function, and making the test reset method better to try to prevent this in the future. |
The second commit doesn't want to cherry-pick, if you're able to do it feel free to push directly to this branch. |
I've just pushed that. Looking at the second test now :) |
b157d91 fixes the doc build. This is actually an interesting precedent. This triggered problems with the doc build:
I swapped |
Maybe because MWERandom uses random values in its initialization? |
The docs are failing to build, I'm taking a look at that
I thought that but the way it was before was seeding after creating the players... Although maybe something I'm forgetting in the tournament initialization was initializing |
@marcharper I've merged in #782 so perhaps that will let you tweak some of the fixes you have here? |
They used to take a strategy class but this ended up initialising players multiples times.
Using numpy causes problems for building the docs. Building the docs mocks numpy (I believe this is because readthedocs can't handle numpy), which in turn broke when importing axelrod (for the auto documentation) as various filtered lists are created when importing. MWE Random is the first strategy that initialises and classifies itself stochasticly...
Ok I removed the classification workaround and all the tests passed locally. I also rebased onto the new master (which required a force push). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks ok to me. I've left a couple of questions more than anything else (and 1 minor change to a comment that I should have done in one of my commits).
I pushed the tiny fix to the inline comment myself: 07caf8f
Changing this to a positive review from me (my other two comments are just questions).
@@ -99,7 +99,7 @@ def _is_valid_key(self, key): | |||
if len(key) != 3: | |||
return False | |||
|
|||
# The triplet should be a pair of axelrod.Player sublclasses and an | |||
# The triplet should be a pair of axelrod.Player subclasses and an |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been changed: should be axelrod.Player instances
MetaMajorityFiniteMemory, MetaWinnerFiniteMemory, | ||
MetaMajorityLongMemory, MetaWinnerLongMemory, MetaMixer, | ||
MetaWinnerEnsemble]) | ||
all_strategies += [MetaHunter, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this just a stylistic change?
(I don't mind at all, not requesting a change here, just curious.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
@@ -37,11 +45,12 @@ def __init__(self): | |||
self.team = [t() for t in self.team] | |||
|
|||
# This player inherits the classifiers of its team. | |||
# Note that memory_depth is not simply the max memory_depth of the team. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really, why not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For e.g. MetaWinner it's saving the cumulative scores of each strategy even if the strategies themselves are not.
The filtering was being done at class level in order for the API to work - instances aren't available at the point it's used. Have the changes here stopped the filtering working on a class? |
No, they still work on a class, the main filtering function FYI This is the commit that implemented it: e9273ef and no actual tests were changed for this. |
This does point to another slightly sticky problem with I think I would prefer if the classification should just be hard coded to take extreme values: My main thinking is reproducibility... If we wanted |
We could of course seed, but we're then talking about seeding every single init of the strategy (for example inside the tournament play itself!). I think my current thoughts would suggest that as a general rule of thumb, classification should be 'set' by the input parameters (if any). So for example |
Cancelling: see comment about classification of MWERandom.
We can remove MWERandom from the default set of strategies, I'm not super attached to it. But it did help reveal some issues as I'm sure you've noticed. |
Absolutely! Found some great stuff :) Would still be nice to have in, just a question of classifying it. I'm going to remove it for now and push. |
I've removed |
Caught some other classification related issues, and a cache issue that I haven't yet addressed (see Cache Bug Lurking #779)now fixed