Skip to content

Commit 4b0b7eb

Browse files
author
Sarah Krebs
committed
Remove unnecessary get_costs function, rename example log files
1 parent f03d02a commit 4b0b7eb

File tree

13 files changed

+10
-67
lines changed

13 files changed

+10
-67
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- Allow to load multi-objective SMAC3v2 and add example (#69).
1212
- Allow to load runs with multiple seeds and add examples (#70).
1313
- Correct incumbent calculation when single objective should be maximized.
14+
- Correct range of configuration cube slider for number of configs.
1415
- Do not disable existing loggers.
1516
- Update author email.
1617
- Add exit button which first deletes running jobs and then terminates DeepCave.

deepcave/plugins/summary/configurations.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -213,17 +213,15 @@ def process(run, inputs) -> Dict[str, Any]: # type: ignore
213213
seeds_evaluated = 0
214214
cost = []
215215
for seed in seeds:
216-
try:
217-
cost.append(
218-
run.get_costs(
219-
config_id=selected_config_id,
220-
budget=budget,
221-
seed=seed,
222-
statuses=[Status.SUCCESS],
223-
)[seed][objective_id]
224-
)
216+
all_costs = run.get_all_costs(
217+
budget=budget,
218+
seed=seed,
219+
statuses=[Status.SUCCESS],
220+
)
221+
if selected_config_id in all_costs:
222+
cost.append(all_costs[selected_config_id][seed][objective_id])
225223
seeds_evaluated += 1
226-
except Exception:
224+
else:
227225
continue
228226

229227
# Add table data

deepcave/runs/__init__.py

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ def get_avg_costs(
722722
objectives = self.get_objectives()
723723

724724
# Budget might not be evaluated
725-
config_costs = self.get_costs(config_id, budget, statuses=statuses)
725+
config_costs = self.get_all_costs(budget=budget, statuses=statuses)[config_id]
726726

727727
avg_costs, std_costs = [], []
728728
for idx in range(len(objectives)):
@@ -731,62 +731,6 @@ def get_avg_costs(
731731
std_costs.append(float(np.std(costs)))
732732
return avg_costs, std_costs
733733

734-
def get_costs(
735-
self,
736-
config_id: int,
737-
budget: Optional[Union[int, float]] = None,
738-
seed: Optional[int] = None,
739-
statuses: Optional[Union[Status, List[Status]]] = None,
740-
) -> Dict[int, List[float]]:
741-
"""
742-
Return the costs of a configuration.
743-
744-
Optionally, only configurations which were evaluated on the passed budget, seed, and stati
745-
are considered.
746-
747-
In case of multi-objective, multiple costs are returned in the form of a list.
748-
749-
Parameters
750-
----------
751-
config_id : int
752-
Configuration id to get the costs for.
753-
budget : Optional[Union[int, float]]
754-
Budget to get the costs from the configuration id for. If budget is
755-
None, the highest budget is chosen. By default None.
756-
seed : Optional[int], optional
757-
Seed to get the costs from the configuration id for. If no seed is
758-
given, all seeds are considered. By default None.
759-
statuses : Optional[Union[Status, List[Status]]]
760-
Only selected stati are considered. If no status is given, all stati are considered.
761-
By default None.
762-
763-
Returns
764-
-------
765-
Dict[int, List[float]]
766-
Seeds with their corresponding list of costs for the associated configuration.
767-
768-
Raises
769-
------
770-
ValueError
771-
If the configuration id is not found.
772-
RuntimeError
773-
If the budget was not evaluated for the passed config id.
774-
"""
775-
if budget is None:
776-
budget = self.get_highest_budget()
777-
778-
if config_id not in self.configs:
779-
raise ValueError("Configuration id was not found.")
780-
costs = self.get_all_costs(budget=budget, seed=seed, statuses=statuses)
781-
if config_id not in costs:
782-
if seed is not None:
783-
raise RuntimeError(
784-
f"Budget {budget} with seed {seed} was not evaluated for config id {config_id}."
785-
)
786-
else:
787-
raise RuntimeError(f"Budget {budget} was not evaluated for config id {config_id}.")
788-
return costs[config_id]
789-
790734
def get_all_costs(
791735
self,
792736
budget: Optional[Union[int, float]] = None,

logs/SMAC3v2/mlp-nondeterministic/run_1/0/configspace.json renamed to logs/SMAC3v2/mlp-nondeterministic/run_1/configspace.json

File renamed without changes.

logs/SMAC3v2/mlp-nondeterministic/run_1/0/intensifier.json renamed to logs/SMAC3v2/mlp-nondeterministic/run_1/intensifier.json

File renamed without changes.

logs/SMAC3v2/mlp-nondeterministic/run_1/0/optimization.json renamed to logs/SMAC3v2/mlp-nondeterministic/run_1/optimization.json

File renamed without changes.

logs/SMAC3v2/mlp-nondeterministic/run_1/0/runhistory.json renamed to logs/SMAC3v2/mlp-nondeterministic/run_1/runhistory.json

File renamed without changes.

logs/SMAC3v2/mlp-nondeterministic/run_1/0/scenario.json renamed to logs/SMAC3v2/mlp-nondeterministic/run_1/scenario.json

File renamed without changes.

logs/SMAC3v2/mlp-nondeterministic/run_2/0/configspace.json renamed to logs/SMAC3v2/mlp-nondeterministic/run_2/configspace.json

File renamed without changes.

logs/SMAC3v2/mlp-nondeterministic/run_2/0/intensifier.json renamed to logs/SMAC3v2/mlp-nondeterministic/run_2/intensifier.json

File renamed without changes.

0 commit comments

Comments
 (0)