-
Notifications
You must be signed in to change notification settings - Fork 18
Attempt to make optimas generators compatible with generator standard
#249
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
Merged
Merged
Changes from all commits
Commits
Show all changes
70 commits
Select commit
Hold shift + click to select a range
fbd8b0a
Rename tell to tell_trials
RemiLehe 2fc7992
Rename _tell to tell
RemiLehe db6e2bc
Rename ask to ask_trials
RemiLehe 522dd9c
Rename _ask to ask
RemiLehe 2445546
Convert ask to new format for simple generators
RemiLehe 0487226
Convert to tell format for simple generators
RemiLehe 55400dd
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] a879df1
Merge branch 'main' into standardization
RemiLehe cee853e
Fix bug
RemiLehe b29c7b5
Fix another bug
RemiLehe cb7a90e
Merge branch 'main' into standardization
RemiLehe d361865
Use new to_dict method
RemiLehe 2a8053e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] db32626
Update the ask method of the Ax service API
RemiLehe 687fe52
Merge branch 'standardization' of github.com:RemiLehe/optimas into st…
RemiLehe c233aa9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 38438bf
Add new `from_dict` method
RemiLehe d33ccb0
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] cd01075
Fix bug when trials have failed
RemiLehe e1022a3
Update optimas/core/trial.py
RemiLehe 2d72c63
Merge branch 'main' into standardization
RemiLehe 6a3d111
Merge branch 'standardization' of github.com:RemiLehe/optimas into st…
RemiLehe e7e1d5b
Add function `custom_parameters_as_dict`
RemiLehe 7cfa798
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] f66c716
Add function `custom_parameters_as_dict`
RemiLehe 3668aaf
Merge branch 'standardization' of github.com:RemiLehe/optimas into st…
RemiLehe 4dc2a95
Pass dicts to tell for Ax generator
RemiLehe 3494360
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] ac7c618
Better handling of objectives and analyzed parameters
RemiLehe 318d7f0
Update initialization of trials
RemiLehe 4fc1f49
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 695cb5a
Merge branch 'standardization' of github.com:RemiLehe/optimas into st…
RemiLehe d1f11ff
Declare ax_trail_id as custom parameter for Ax generators
RemiLehe 682f7d1
Merge branch 'declare_custom_parameter' into standardization
RemiLehe f5045cd
Merge branch 'standardization' of github.com:RemiLehe/optimas into st…
RemiLehe 8df32a6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] fb4bfbc
Handle custom parameters properly
RemiLehe 31fa71b
Fix bug with order of coordinates
RemiLehe 72fce60
Add external gen wrapper
shuds13 f58ab4e
Pass all trials to tell_trials
shuds13 298772c
Add required docstrings
shuds13 a735cdd
Make plural
shuds13 7660387
Merge branch 'main' into standardization
RemiLehe d6ff991
Merge branch 'main' into standardization
RemiLehe 6037af8
Correct formatting error message
RemiLehe df59180
Revert "Declare ax_trail_id as custom parameter for Ax generators"
RemiLehe 907003f
Merge pull request #250 from optimas-org/feature/interface_updates
shuds13 0ce0ec2
Update ask/tell to suggest/ingest
shuds13 56ea9ec
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 4bf8c28
Merge branch 'main' into standardization
shuds13 427bcdd
Fix ax_trial_id
shuds13 c105ef2
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] fbeaec3
Use getter/setter
shuds13 e747542
Hoist ignore of invalid parameters
shuds13 01f712b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] e516585
Update multitask test for standard
shuds13 939aea0
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 48c83e8
Allow save after complete batch
shuds13 c66e09f
Fix to use ax_trial_id from history points
shuds13 8d9bc44
Remove line
shuds13 af2b0d4
Refactor Ax service generator
shuds13 4a3f0c7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] f14f3c5
Move Ax service gen to use _id
shuds13 cd694e0
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] e858bae
Prevent duplicate point return
shuds13 b7ae657
Revert to telling one point at a time
shuds13 bfc4fad
Move test code to match run order
shuds13 082bded
Remove redundant code
shuds13 5b9d514
Apply suggestions from code review
RemiLehe 3dc27c6
Merge branch 'main' into standardization
RemiLehe 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -196,10 +196,13 @@ def __init__( | |
| model_save_period: Optional[int] = 5, | ||
| model_history_dir: Optional[str] = "model_history", | ||
| ) -> None: | ||
| # As trial parameters these get written to history array | ||
| # Ax trial_index and arm toegther locate a point | ||
| # Multiple points (Optimas trials) can share the same Ax trial_index | ||
| custom_trial_parameters = [ | ||
| TrialParameter("arm_name", "ax_arm_name", dtype="U32"), | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As a follow-up PR, let us consider how to fit this in the VOCS format and/or whether to convert |
||
| TrialParameter("trial_type", "ax_trial_type", dtype="U32"), | ||
| TrialParameter("trial_index", "ax_trial_index", dtype=int), | ||
| TrialParameter("ax_trial_id", "ax_trial_index", dtype=int), | ||
| ] | ||
| self._check_inputs(varying_parameters, objectives, lofi_task, hifi_task) | ||
| super().__init__( | ||
|
|
@@ -260,23 +263,38 @@ def _check_inputs( | |
| "to the number of high-fidelity trials" | ||
| ) | ||
|
|
||
| def _ask(self, trials: List[Trial]) -> List[Trial]: | ||
| """Fill in the parameter values of the requested trials.""" | ||
| for trial in trials: | ||
| def suggest(self, num_points: Optional[int]) -> List[dict]: | ||
| """Request the next set of points to evaluate.""" | ||
| points = [] | ||
| for _ in range(num_points): | ||
| next_trial = self._get_next_trial_arm() | ||
| if next_trial is not None: | ||
| arm, trial_type, trial_index = next_trial | ||
| trial.parameter_values = [ | ||
| arm.parameters.get(var.name) | ||
| point = { | ||
| var.name: arm.parameters.get(var.name) | ||
| for var in self._varying_parameters | ||
| ] | ||
| trial.trial_type = trial_type | ||
| trial.arm_name = arm.name | ||
| trial.trial_index = trial_index | ||
| return trials | ||
|
|
||
| def _tell(self, trials: List[Trial]) -> None: | ||
| } | ||
| # SH for VOCS standard these will need to be 'variables' | ||
| # For now much match the trial parameter names. | ||
| point["ax_trial_id"] = trial_index | ||
| point["arm_name"] = arm.name | ||
| point["trial_type"] = trial_type | ||
| points.append(point) | ||
| return points | ||
|
|
||
| def ingest(self, results: List[dict]) -> None: | ||
| """Incorporate evaluated trials into experiment.""" | ||
| # reconstruct Optimas trials | ||
| trials = [] | ||
| for result in results: | ||
| trial = Trial.from_dict( | ||
| trial_dict=result, | ||
| varying_parameters=self._varying_parameters, | ||
| objectives=self._objectives, | ||
| analyzed_parameters=self._analyzed_parameters, | ||
| custom_parameters=self._custom_trial_parameters, | ||
| ) | ||
| trials.append(trial) | ||
| if self.gen_state == NOT_STARTED: | ||
| self._incorporate_external_data(trials) | ||
| else: | ||
|
|
@@ -285,17 +303,18 @@ def _tell(self, trials: List[Trial]) -> None: | |
| def _incorporate_external_data(self, trials: List[Trial]) -> None: | ||
| """Incorporate external data (e.g., from history) into experiment.""" | ||
| # Get trial indices. | ||
| # SH should have handling if ax_trial_ids are None... | ||
| trial_indices = [] | ||
| for trial in trials: | ||
| trial_indices.append(trial.trial_index) | ||
| trial_indices.append(trial.ax_trial_id) | ||
| trial_indices = np.unique(np.array(trial_indices)) | ||
|
|
||
| # Group trials by index. | ||
| grouped_trials = {} | ||
| for index in trial_indices: | ||
| grouped_trials[index] = [] | ||
| for trial in trials: | ||
| grouped_trials[trial.trial_index].append(trial) | ||
| grouped_trials[trial.ax_trial_id].append(trial) | ||
|
|
||
| # Add trials to experiment. | ||
| for index in trial_indices: | ||
|
|
||
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.
Would it make sense to add a test for this object in the CI?
(This could potentially be a follow-up PR.)
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