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

Ensemble Object #1

Open
daub1 opened this issue Feb 5, 2021 · 0 comments
Open

Ensemble Object #1

daub1 opened this issue Feb 5, 2021 · 0 comments

Comments

@daub1
Copy link
Contributor

daub1 commented Feb 5, 2021

When working on an application, I wanted a method to easily combine multiple sampling strategies, one idea was to have an Ensemble object which matches the API of the sampler objects, but has multiple samplers. Partial pseudo-code below:

class Ensemble:
    """
    Class for multiple samplers.
    """
    def __init__(self, sampler_data):
        if not isinstance(sampler_data, list):
            sampler_data = [sampler_data]
        self._samplers = [new_sampler(data) for data in sampler_data]
    def check_validity(self):
        for sampler in self._samplers:
            sampler.check_validity()
       # check that all samplers have the same parameter names, etc.
    def get_samples(self):
        samples = []
        for sampler in self._samplers:
            samples.extend(sampler.get_samples())
       return samples

Then you could specify multiple samplers via the yaml interface:

sampler:
    - type: list
      parameters:
          X1: [5, 10]
          X2: [5, 10]
   - type: cross_product
     parameters:
          X1: [15, 20, 30]
          X2: [15, 20, 30]
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

No branches or pull requests

1 participant