BoFire Refactoring #138
Pinned
jduerholt
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
BoFire - refactoring
In the last 2 weeks, mainly @evo-bschiller performed a major refactoring of the whole bofire code base and also wrote this documentation. Our goal was to improve the overall structure, readability, and usability of bofire's components. Most importantly, we separated data models from functionality.
In the following, we list the most important changes:
Model
toSurrogate
bofire.data_models.base.DataModel
)bofire.data_models.<entity>
domain
,kernels
,features
,objectives
api.py
bofire.surrogates
bofire.strategies
api.py
AnyX
type unions are available frombofire.data_models.api
bofire.data_model.<entity>.api
data models vs. functional components
All data models in
bofire.data_models
, are specified as pydantic models and inherit frombofire.data_models.base.BaseModel
. These data models can be (de)serialized via.dict()
and.json()
(provided by pydantic). A json schema of each data model can be obtained using.schema()
.The data models of most entities have not been changed. We only moved their definitions to the respective package in
bofire.data_models.<entity>
, split the class definitions into multiple modules, and addedapi.py
.For surrogates and strategies, we removed the functional parts from the data models and moved them to
bofire.surrogates
andbofire.strategies
. These functionalities include theask
andtell
as well asfit
andpredict
methods. All class attributes (used by these method) are also removed from the data models. Each functional entity is initialized using the corresponding data model. As an example, consider the following data model of aRandomStrategy
:Such a data model can be (de)serialized as follows:
Using this data model of a strategy, we can create an instance of a (functional) strategy:
As each strategy data model should be mapped to a specific (functional) strategy, we provide such a mapping:
Surrogates (formerly known as models) have been split in the same manner into data models (
bofire.data_models.surrogates
) and functional components (bofire.surrogates
).Beta Was this translation helpful? Give feedback.
All reactions