Skip to content

Commit

Permalink
Add heuristic for reference point and allow manual spec
Browse files Browse the repository at this point in the history
  • Loading branch information
ruicoelhopedro committed Apr 17, 2024
1 parent cb9cdb6 commit 1643d2a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions piglot/optimisers/botorch/bayes.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ def __init__(
load_file: str = None,
export: str = None,
device: str = 'cpu',
reference_point: List[float] = None,
) -> None:
if not isinstance(objective, GenericObjective):
raise RuntimeError("Bayesian optimiser requires a GenericObjective")
Expand All @@ -166,7 +167,8 @@ def __init__(
self.n_test = n_test
self.device = device
self.partitioning: FastNondominatedPartitioning = None
self.ref_point: torch.Tensor = None
self.adjusted_ref_point = reference_point is None
self.ref_point = None if reference_point is None else -torch.tensor(reference_point)
if acquisition is None:
self.acquisition = default_acquisition(
objective.composition,
Expand Down Expand Up @@ -301,10 +303,11 @@ def _composition(self, vals: torch.Tensor, params: torch.Tensor) -> torch.Tensor
return -self.objective.composition.composition_torch(vals, params)

def _update_mo_data(self, dataset: BayesDataset) -> float:
# Compute reference point
# TODO: check how to properly handle the ref_point and best_value
y_points = self._composition(dataset.values, dataset.params)
self.ref_point = torch.min(y_points, dim=0).values
# Compute reference point if needed
if self.adjusted_ref_point:
nadir = torch.min(y_points, dim=0).values
self.ref_point = nadir - 0.1 * (torch.max(y_points, dim=0).values - nadir)
# Update partitioning and Pareto front
self.partitioning = FastNondominatedPartitioning(self.ref_point, Y=y_points)
hypervolume = self.partitioning.compute_hypervolume().item()
Expand Down

0 comments on commit 1643d2a

Please sign in to comment.