-
Notifications
You must be signed in to change notification settings - Fork 15
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
Feature/interface updates #250
Open
shuds13
wants to merge
4
commits into
standardization
Choose a base branch
from
feature/interface_updates
base: standardization
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
"""Contains the definition of an external generator.""" | ||
|
||
from .base import Generator | ||
|
||
|
||
class ExternalGenerator(Generator): | ||
"""Supports a generator in the CAMPA generator standard.""" | ||
|
||
def __init__( | ||
self, | ||
ext_gen, | ||
**kwargs, | ||
): | ||
super().__init__( | ||
**kwargs, | ||
) | ||
self.gen = ext_gen | ||
|
||
def ask(self, n_trials): | ||
"""Request the next set of points to evaluate.""" | ||
return self.gen.ask(n_trials) | ||
|
||
def tell(self, trials): | ||
"""Send the results of evaluations to the generator.""" | ||
self.gen.tell(trials) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The reason this wrapper is necessary is that Optimas generators contain a number of variables that are not present in our generators such as varying_parameters etc... (basically everything in the Optimas generator constructors). By wrapping the generator like this, we can allow Optimas functions to make the necessary updates to those data structures (e.g., in ask_trials/tell_trials), while the actual ask/tell() functions only deal with the standard.
As libEnsemble generators do not inherit from Optimas generators, we don't have those, so there has to be some way to give Optimas VaryingParameters etc...
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.
The only other thing I can think would be to pass VaryingParameters etc.. into Optimas as a separate config, alongside the standard (or libE) generator. And Optimas could create the wrapper internally, maybe. I'm not sure thats preferable though.
I guess for Optimas to be fully supportive of the generator standard, the constructors still need updating. So
Variables
is converted toVaryingParameters
, but there is still a lot of extra options for Optimas gens (e.gcustom_trial_parameters
orallow_fixed_parameters
)