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

Implement ENTMOOT in Bofire #278

Merged
merged 43 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
492ef46
Convert features and constraints to entmoot
TobyBoyne Sep 6, 2023
0f4c28b
EntingStrategy functional and datamodel
TobyBoyne Sep 7, 2023
2f37e9a
Ask implemented for Enting with example
TobyBoyne Sep 7, 2023
6090738
Convert Enting to Predictive
TobyBoyne Sep 8, 2023
8c8127e
Implement multi objective and maximization
TobyBoyne Sep 8, 2023
be01f0d
Refactor, move files to appropriate directories
TobyBoyne Sep 8, 2023
345d1d8
Enting docstrings and test for domain conversion
TobyBoyne Sep 11, 2023
3497610
Multiple candidates generated in ask
TobyBoyne Sep 14, 2023
e8c6468
Implement new entmoot constraints
TobyBoyne Oct 11, 2023
726532f
Implement new entmoot Maximize objective
TobyBoyne Oct 11, 2023
69f83e6
Implement new entmoot EntingParams
TobyBoyne Oct 11, 2023
bb0543d
Implement entmoot.ConstraintList
TobyBoyne Nov 7, 2023
5fb2900
Create data models for Enting parameters
TobyBoyne Feb 27, 2024
6eea8d0
Update field default factory for entingparams
TobyBoyne Feb 27, 2024
4d6e842
Merge branch 'main' of https://github.com/TobyBoyne/bofire
TobyBoyne Feb 27, 2024
ca0f39f
Test serialization for enting
TobyBoyne Feb 27, 2024
e6e2c55
Intial Enting tests, add to bofire api
TobyBoyne Feb 27, 2024
9dab62a
Add tests for functionality of Enting Stratey
TobyBoyne Feb 28, 2024
93f1bf5
Merge remote-tracking branch 'upstream/main'
TobyBoyne Feb 28, 2024
6bfeca8
Update bofire/data_models/strategies/predictives/enting.py
TobyBoyne Feb 29, 2024
53d2d9a
Typing updates to enting
TobyBoyne Feb 29, 2024
5579c32
Merge entmoot utils into enting
TobyBoyne Mar 1, 2024
fdf42b8
Fix assumed ordering of features in tests
TobyBoyne Mar 1, 2024
275ddca
Create entmoot extra
TobyBoyne Mar 1, 2024
c846a48
Flatten Enting parameters
TobyBoyne Mar 1, 2024
3c658fd
Enting tests for parameter consistency
TobyBoyne Mar 1, 2024
daaab33
Add specs test for entmoot
TobyBoyne Mar 2, 2024
7c69a52
Clarified behaviour of kappa_fantasy in enting
TobyBoyne Mar 2, 2024
d8eb2b6
Clean up batch proposals for enting
TobyBoyne Mar 2, 2024
c4b6ee9
Safer imports in test_enting
TobyBoyne Mar 5, 2024
ca2bb10
Move enting helper methods
TobyBoyne Mar 5, 2024
2250576
Fix enting imports/installs; minor bugs in tests
TobyBoyne Mar 8, 2024
d6b6451
Fix import-dependent type hints
TobyBoyne Mar 11, 2024
b5bc43c
Commit to trigger workflow
TobyBoyne Mar 11, 2024
b44b7e8
Fix problematic imports in test_enting
TobyBoyne Mar 11, 2024
bb9eb9f
Add entmoot to tests that need it
TobyBoyne Mar 11, 2024
4682cba
More changes to fix pipeline
TobyBoyne Mar 11, 2024
a0253ba
Add ignores for pyright
TobyBoyne Mar 11, 2024
dcedd09
Check if gurobi license is available; remove notebook
TobyBoyne Mar 11, 2024
a5dae0b
Mark tests requiring Gurobi as slow
TobyBoyne Mar 14, 2024
659b133
Merge branch 'main' of https://github.com/experimental-design/bofire
TobyBoyne Mar 14, 2024
2ec9a71
Add EntingStrategy to types
TobyBoyne Mar 14, 2024
ebb288f
Add Enting to mapper
TobyBoyne Mar 14, 2024
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
3 changes: 3 additions & 0 deletions bofire/data_models/strategies/api.py
TobyBoyne marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from bofire.data_models.strategies.doe import DoEStrategy
from bofire.data_models.strategies.factorial import FactorialStrategy
from bofire.data_models.strategies.predictives.botorch import LSRBO, BotorchStrategy
from bofire.data_models.strategies.predictives.enting import EntingStrategy
from bofire.data_models.strategies.predictives.mobo import MoboStrategy
from bofire.data_models.strategies.predictives.multiobjective import (
MultiobjectiveStrategy,
Expand Down Expand Up @@ -47,6 +48,7 @@
QnehviStrategy,
QparegoStrategy,
SpaceFillingStrategy,
EntingStrategy,
RandomStrategy,
DoEStrategy,
StepwiseStrategy,
Expand All @@ -63,6 +65,7 @@
QehviStrategy,
QnehviStrategy,
QparegoStrategy,
EntingStrategy,
MoboStrategy,
]

Expand Down
116 changes: 116 additions & 0 deletions bofire/data_models/strategies/predictives/enting.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
from typing import Any, Dict, Literal, Type

from pydantic import PositiveFloat, PositiveInt

from bofire.data_models.constraints.api import (
Constraint,
LinearEqualityConstraint,
LinearInequalityConstraint,
NChooseKConstraint,
)
from bofire.data_models.features.api import (
CategoricalDescriptorInput,
CategoricalInput,
ContinuousInput,
ContinuousOutput,
DiscreteInput,
Feature,
)
from bofire.data_models.objectives.api import (
MaximizeObjective,
MinimizeObjective,
Objective,
)
from bofire.data_models.strategies.predictives.predictive import PredictiveStrategy


class EntingStrategy(PredictiveStrategy):
type: Literal["EntingStrategy"] = "EntingStrategy"

# uncertainty model parameters
beta: PositiveFloat = 1.96
bound_coeff: PositiveFloat = 0.5
acq_sense: Literal["exploration", "penalty"] = "exploration"
dist_trafo: Literal["normal", "standard"] = "normal"
dist_metric: Literal["euclidean_squared", "l1", "l2"] = "euclidean_squared"
cat_metric: Literal["overlap", "of", "goodall4"] = "overlap"

# lightgbm training hyperparameters
# see https://lightgbm.readthedocs.io/en/latest/Parameters.html
num_boost_round: PositiveInt = 100
max_depth: PositiveInt = 3
min_data_in_leaf: PositiveInt = 1
min_data_per_group: PositiveInt = 1
verbose: Literal[-1, 0, 1, 2] = -1

# pyomo parameters
solver_name: str = "gurobi"
solver_verbose: bool = False
solver_params: Dict[str, Any] = {}

# kappa_fantasy determines a bound on the predicted value of an unseen point
# used for making batch predictions, y* = mean + kappa_fantasy * std
# for a both min and max problems, a positive value is 'pesimistic'
# and a negative value is 'optimistic'
# a value of zero implies future observations will be exactly the mean
kappa_fantasy: float = 1.96

@classmethod
def is_constraint_implemented(cls, my_type: Type[Constraint]) -> bool:
return my_type in [
LinearEqualityConstraint,
LinearInequalityConstraint,
NChooseKConstraint,
]

@classmethod
def is_feature_implemented(cls, my_type: Type[Feature]) -> bool:
return my_type in [
CategoricalInput,
DiscreteInput,
CategoricalDescriptorInput,
ContinuousInput,
ContinuousOutput,
]

@classmethod
def is_objective_implemented(cls, my_type: Type[Objective]) -> bool:
return my_type in [MinimizeObjective, MaximizeObjective]

def dump_enting_params(self) -> dict:
TobyBoyne marked this conversation as resolved.
Show resolved Hide resolved
"""Dump the model in the nested structure required for ENTMOOT.

Returns:
dict: the nested dictionary of entmoot params.
"""
return {
"unc_params": {
"beta": self.beta,
"bound_coeff": self.bound_coeff,
"acq_sense": self.acq_sense,
"dist_trafo": self.dist_trafo,
"dist_metric": self.dist_metric,
"cat_metric": self.cat_metric,
},
"tree_train_params": {
"train_params": {
"num_boost_round": self.num_boost_round,
"max_depth": self.max_depth,
"min_data_in_leaf": self.min_data_in_leaf,
"min_data_per_group": self.min_data_per_group,
"verbose": self.verbose,
},
},
}

def dump_solver_params(self) -> dict:
"""Dump the solver parameters for pyomo.

Returns:
dict: the nested dictionary of solver params.
"""
return {
"solver_name": self.solver_name,
"verbose": self.solver_verbose,
**self.solver_params,
}
1 change: 1 addition & 0 deletions bofire/strategies/api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from bofire.strategies.doe_strategy import DoEStrategy
from bofire.strategies.mapper import map
from bofire.strategies.predictives.botorch import BotorchStrategy
from bofire.strategies.predictives.enting import EntingStrategy
from bofire.strategies.predictives.predictive import PredictiveStrategy
from bofire.strategies.predictives.qehvi import QehviStrategy
from bofire.strategies.predictives.qnehvi import QnehviStrategy
Expand Down
2 changes: 2 additions & 0 deletions bofire/strategies/mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from bofire.strategies.doe_strategy import DoEStrategy
from bofire.strategies.factorial import FactorialStrategy
from bofire.strategies.predictives.botorch import BotorchStrategy
from bofire.strategies.predictives.enting import EntingStrategy
from bofire.strategies.predictives.mobo import MoboStrategy
from bofire.strategies.predictives.predictive import PredictiveStrategy
from bofire.strategies.predictives.qehvi import QehviStrategy
Expand Down Expand Up @@ -34,6 +35,7 @@
data_models.DoEStrategy: DoEStrategy,
data_models.StepwiseStrategy: StepwiseStrategy,
data_models.FactorialStrategy: FactorialStrategy,
data_models.EntingStrategy: EntingStrategy,
data_models.MoboStrategy: MoboStrategy,
data_models.ShortestPathStrategy: ShortestPathStrategy,
}
Expand Down
Loading
Loading