-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #169 from optimas-org/feature/expose_ax_plots
Expose `AxModelManager` methods in Service API generators and add new plotting methods
- Loading branch information
Showing
14 changed files
with
260 additions
and
57 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,3 @@ Diagnostics | |
:toctree: _autosummary | ||
|
||
ExplorationDiagnostics | ||
AxModelManager |
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 |
---|---|---|
|
@@ -11,3 +11,4 @@ This reference manual details all classes included in optimas. | |
evaluators | ||
exploration | ||
diagnostics | ||
utils |
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,9 @@ | ||
Utilities | ||
========= | ||
|
||
.. currentmodule:: optimas.utils | ||
|
||
.. autosummary:: | ||
:toctree: _autosummary | ||
|
||
AxModelManager |
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
from .exploration_diagnostics import ExplorationDiagnostics | ||
from .ax_model_manager import AxModelManager | ||
|
||
__all__ = ["ExplorationDiagnostics", "AxModelManager"] | ||
__all__ = ["ExplorationDiagnostics"] |
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
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,3 @@ | ||
from .ax import AxModelManager | ||
|
||
__all__ = ["AxModelManager"] |
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,3 @@ | ||
from .ax_model_manager import AxModelManager | ||
|
||
__all__ = ["AxModelManager"] |
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,49 @@ | ||
"""Contains the definition of various utilities for using Ax.""" | ||
|
||
from typing import List, Dict | ||
|
||
import numpy as np | ||
from ax.service.utils.instantiation import ObjectiveProperties | ||
|
||
from optimas.core import VaryingParameter, Objective | ||
|
||
|
||
def convert_optimas_to_ax_parameters( | ||
varying_parameters: List[VaryingParameter], | ||
) -> List[Dict]: | ||
"""Create list of Ax parameters from optimas varying parameters.""" | ||
parameters = [] | ||
for var in varying_parameters: | ||
# Determine parameter type. | ||
value_dtype = np.dtype(var.dtype) | ||
if value_dtype.kind == "f": | ||
value_type = "float" | ||
elif value_dtype.kind == "i": | ||
value_type = "int" | ||
else: | ||
raise ValueError( | ||
"Ax range parameter can only be of type 'float'ot 'int', " | ||
f"not {var.dtype}." | ||
) | ||
# Create parameter dict and append to list. | ||
parameters.append( | ||
{ | ||
"name": var.name, | ||
"type": "range", | ||
"bounds": [var.lower_bound, var.upper_bound], | ||
"is_fidelity": var.is_fidelity, | ||
"target_value": var.fidelity_target_value, | ||
"value_type": value_type, | ||
} | ||
) | ||
return parameters | ||
|
||
|
||
def convert_optimas_to_ax_objectives( | ||
objectives: List[Objective], | ||
) -> Dict[str, ObjectiveProperties]: | ||
"""Create list of Ax objectives from optimas objectives.""" | ||
ax_objectives = {} | ||
for obj in objectives: | ||
ax_objectives[obj.name] = ObjectiveProperties(minimize=obj.minimize) | ||
return ax_objectives |
Oops, something went wrong.