From 74b7f329e426afb943eafcbe0d8be152c0df3f7d Mon Sep 17 00:00:00 2001 From: Kevin Stone Date: Thu, 19 Sep 2024 15:00:09 -0400 Subject: [PATCH] Added warning for combinatorial explosion --- obsidian/exceptions.py | 5 +++++ obsidian/optimizer/bayesian.py | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/obsidian/exceptions.py b/obsidian/exceptions.py index 5412da1..7ae5372 100644 --- a/obsidian/exceptions.py +++ b/obsidian/exceptions.py @@ -24,3 +24,8 @@ class UnfitError(Exception): class DataWarning(UserWarning): """Warning that gets raised if there is an issue with input data""" pass + + +class OptimizerWarning(UserWarning): + """Warning that gets raised if there is an issue with optimization configuration""" + pass diff --git a/obsidian/optimizer/bayesian.py b/obsidian/optimizer/bayesian.py index dff4fc5..a05f456 100644 --- a/obsidian/optimizer/bayesian.py +++ b/obsidian/optimizer/bayesian.py @@ -8,7 +8,7 @@ from obsidian.surrogates import model_class_dict from obsidian.objectives import Index_Objective, Objective_Sequence from obsidian.constraints import Linear_Constraint, Nonlinear_Constraint, Output_Constraint -from obsidian.exceptions import IncompatibleObjectiveError, UnsupportedError, UnfitError, DataWarning +from obsidian.exceptions import IncompatibleObjectiveError, UnsupportedError, UnfitError, DataWarning, OptimizerWarning from obsidian.config import TORCH_DTYPE from botorch.acquisition.objective import MCAcquisitionObjective @@ -713,6 +713,10 @@ def suggest(self, # Compute static variable inputs fixed_features_list = self._fixed_features(fixed_var) + if len(fixed_features_list) > 25: + warnings.warn(f'The combinations of discrete features is large at {len(fixed_features_list)}.' + + ' Optimization will proceed very slowly due to the combinatorial explosion.' + + ' Recommend reducing the number of discrete parameters used.', OptimizerWarning) # Set up the sampler, for MC-based optimization of acquisition functions if not isinstance(model, ModelListGP):