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

[WIP] Remove custom parameters #245

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions optimas/core/trial.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ class Trial:
parameter).
index : int, optional
Index of the trial.
custom_parameters : list of TrialParameter, optional
Additional parameters needed to identify or carry out the trial, and
which will be included in the optimization history.

"""

def __init__(
Expand All @@ -50,7 +46,6 @@ def __init__(
parameter_values: Optional[List[float]] = None,
evaluations: Optional[List[Evaluation]] = None,
index: Optional[int] = None,
custom_parameters: Optional[List[TrialParameter]] = None,
) -> None:
# Process inputs.
self._varying_parameters = varying_parameters
Expand All @@ -63,16 +58,9 @@ def __init__(
)
evaluations = [] if evaluations is None else evaluations
self._index = index
self._custom_parameters = (
[] if custom_parameters is None else custom_parameters
)
self._ignored = False
self._ignored_reason = None

# Add custom parameters as trial attributes.
for param in self._custom_parameters:
setattr(self, param.name, None)

# Create map of evaluations to objectives and analyzed parameters.
self._mapped_evaluations = {}
for par in self._objectives + self._analyzed_parameters:
Expand Down Expand Up @@ -139,11 +127,6 @@ def ignored_reason(self) -> str:
"""Get the reason why the trial is ignored by the generator."""
return self._ignored_reason

@property
def custom_parameters(self) -> List[TrialParameter]:
"""Get the list of custom trial parameters."""
return self._custom_parameters

@property
def status(self) -> TrialStatus:
"""Get current trial status."""
Expand Down
3 changes: 0 additions & 3 deletions optimas/gen_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@ def persistent_generator(H, persis_info, gen_specs, libE_info):
if "task" in H_o.dtype.names:
H_o["task"][i] = trial.trial_type
run_params = run_params[trial.trial_type]
if trial.custom_parameters is not None:
for par in trial.custom_parameters:
H_o[par.save_name][i] = getattr(trial, par.name)
H_o["trial_index"][i] = trial.index
H_o["num_procs"][i] = run_params["num_procs"]
H_o["num_gpus"][i] = run_params["num_gpus"]
Expand Down
2 changes: 0 additions & 2 deletions optimas/generators/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ def ask(self, n_trials: int) -> List[Trial]:
varying_parameters=self._varying_parameters,
objectives=self._objectives,
analyzed_parameters=self._analyzed_parameters,
custom_parameters=self._custom_trial_parameters,
)
)
# Ask the generator to fill them.
Expand Down Expand Up @@ -489,7 +488,6 @@ def _create_trials_from_external_data(
],
objectives=self._objectives,
analyzed_parameters=self._analyzed_parameters,
custom_parameters=self._custom_trial_parameters,
)
for par in self._custom_trial_parameters:
setattr(trial, par.name, trial_data[par.save_name][i])
Expand Down
Loading