Skip to content
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

Introduced the Ranker object, responsible for ranking the solutions based on different objectives #209

Merged
merged 32 commits into from
Jun 23, 2022

Conversation

itsdawei
Copy link
Collaborator

@itsdawei itsdawei commented Jun 20, 2022

Description

This PR is a split from #207

This PR introduces major API changes for the Emitter class. Emitter class now requires a Ranker object and a Selector object.

The Ranker object will define a rank function which returns the index of the solutions in the descending order that they should be in. It will also define a reset function which resets the internal states of the object.

RandomDirectionEmitter, OptimizingEmitter, and ImprovementEmitter are now all combined into EvolutionStrategyEmitter, which can be configured to use different Ranker's.

We also introduce FilterSelector and MuSelector objects which defines a select() function that decides how many parents to select from the potential parents.

EvolutionStrategyEmitter(x0, sigma0, ranker=Ranker, string, selector, ES, restart_rule, bounds, batch_size, seed)
If ranker=str, then we create the object for you

TODO

  • Implement ImprovementRanker
  • Implement TwoStageImprovementRanker
  • Implement RandomDirectionRanker
  • Implement TwoStageRandomDirectionRanker
  • Implement ObjectiveRanker
  • Implement TwoStageObjectiveRanker
  • Implement get_ranker(str) -> Ranker

Others

Status

  • I have read the guidelines in CONTRIBUTING.md.
  • I have formatted my code using yapf
  • I have tested my code by running pytest
  • I have linted my code with pylint
  • I have added a one-line description of my change to the changelog in HISTORY.md.
  • This PR is ready to go

ribs/_docstrings.py Outdated Show resolved Hide resolved
ribs/_docstrings.py Outdated Show resolved Hide resolved
Copy link
Collaborator Author

@itsdawei itsdawei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-review.

@itsdawei itsdawei marked this pull request as ready for review June 21, 2022 21:15
@itsdawei itsdawei requested a review from btjanaka June 21, 2022 21:15
@itsdawei itsdawei linked an issue Jun 21, 2022 that may be closed by this pull request
@btjanaka btjanaka changed the title Split Emitters API for Rankers Implement rankers for use in emitters Jun 21, 2022
HISTORY.md Outdated Show resolved Hide resolved
ribs/_docstrings.py Outdated Show resolved Hide resolved
ribs/_docstrings.py Outdated Show resolved Hide resolved
ribs/_docstrings.py Outdated Show resolved Hide resolved
ribs/emitters/rankers.py Outdated Show resolved Hide resolved
ribs/emitters/rankers.py Show resolved Hide resolved
ribs/emitters/rankers.py Outdated Show resolved Hide resolved
ribs/emitters/rankers.py Outdated Show resolved Hide resolved
tests/emitters/rankers_test.py Outdated Show resolved Hide resolved
tests/emitters/rankers_test.py Outdated Show resolved Hide resolved
ribs/emitters/rankers.py Outdated Show resolved Hide resolved
@itsdawei itsdawei changed the title Implement rankers for use in emitters Introduced the Ranker object, responsible for ranking the solutions basic on different objectives Jun 22, 2022
@itsdawei itsdawei requested a review from btjanaka June 22, 2022 20:34
HISTORY.md Outdated Show resolved Hide resolved
ribs/emitters/rankers.py Outdated Show resolved Hide resolved
ribs/emitters/rankers.py Outdated Show resolved Hide resolved
ribs/emitters/rankers.py Outdated Show resolved Hide resolved
ribs/emitters/rankers.py Show resolved Hide resolved
ribs/emitters/rankers.py Show resolved Hide resolved
ribs/emitters/rankers.py Outdated Show resolved Hide resolved
ribs/emitters/rankers.py Outdated Show resolved Hide resolved
@itsdawei itsdawei changed the title Introduced the Ranker object, responsible for ranking the solutions basic on different objectives Introduced the Ranker object, responsible for ranking the solutions based on different objectives Jun 22, 2022
@itsdawei itsdawei requested a review from btjanaka June 22, 2022 22:32
Copy link
Member

@btjanaka btjanaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor change. I also tweaked get_ranker.

@@ -59,44 +77,27 @@ class RankerBase(ABC):
Child classes are only required to override :meth:`rank`.
"""

def __init__(self, seed=None):
pass

@abstractmethod
def rank(self, emitter, archive, solution_batch, objective_batch,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you put rng after archive so that the signature is similar to reset?

@itsdawei itsdawei merged commit e256231 into master Jun 23, 2022
@itsdawei itsdawei deleted the add-rankers-emitters-api branch June 23, 2022 01:02
@itsdawei itsdawei mentioned this pull request Jun 30, 2022
19 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reduce duplicate code between CMA-ME emitters
2 participants