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

Ask & Tell for DE #92

Open
Bronzila opened this issue Jun 26, 2024 · 0 comments
Open

Ask & Tell for DE #92

Bronzila opened this issue Jun 26, 2024 · 0 comments
Labels
enhancement New feature or request refactoring Improving code quality

Comments

@Bronzila
Copy link
Collaborator

Currently, we only support ask & tell for DEHB. However, our package also offers to run DE itself. While it does have a run function, it would make sense to implement ask & tell to offer a unified interface for both DE and DEHB.

While ask & tell was relatively straight forward for DEHB, DE needs a little restructuring for making ask & tell work. In the following I will briefly talk about the required changes to DE and how I would tackle them.

1. Current DE implementation evolves per generation and not per individual

Since ask aims to provide single configurations to evaluate, we would need to adjust the current DE implementation to work on a per individual basis, as currently the whole generation evolved at once. The easiest way to allow for individual control would be simply adding a current_indiv_pointer as a property for DE which would be incremented after every ask and point at the next population index to create a trial from.

2. Selection happens after the whole generation has been evolved and evaluated (exception: AsyncDE with immediate, worst or random async strategy)

Since we would generally need to adjust DE to work on an individual level, we would also need to adjust the selction process as we cannot perform selection after every tell. Please note, that this is only the case for plain DE and AsyncDE with the deferred mutation strategy. The other async strategies (immediate, worst and random) already perform selection right after evolving and evaluating a single individual. Since we probably want to keep track of the number of tells by the user anyways (to give a warning if there have been more tells than asks), we could simply add a check for n_tells % population_size == 0 after incrementing n_tells in tell(..) and only perform selection then. A rough sketch of the code:

# For DE
def tell(trial, result):
    self.n_tells += 1
    self.waiting_trials.append((trial, result))

    # Only perform selection after whole population has been evolved
    if self.n_tells % self.pop_size == 0:
        for trial, res in self.waiting_trials:
            self.selection(trial, res)

# For AsyncDE
def tell(trial, result):
    self.n_tells += 1
    if self.async_strategy == "deferrred":
        self.waiting_trials.append((trial, result))

        # Only perform selection after whole population has been evolved
        if self.n_tells % self.pop_size == 0:
            for trial, res in self.waiting_trials:
                self.selection(trial, res)
    elif self.async_strategy == "immediate":
        # perform immediate selection
    else:
        # perform worst/random selection

Please note, that this should only be a sketch to give an idea on how to implement tell. There would also need to be some changes e.g. to the selection routine.

@Bronzila Bronzila added enhancement New feature or request refactoring Improving code quality labels Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request refactoring Improving code quality
Projects
None yet
Development

No branches or pull requests

1 participant