Free-text context providing additional information about the optimization problem. Useful for agentic optimization where an LLM agent can leverage this description to better understand the overall problem, its goals, and any domain-specific knowledge.
Duplicates are identified based on the experiments with the same input features. Continuous input features are rounded before identifying the duplicates. Aggregation is performed by taking the average of the involved output features.
Parameters
Name
Type
Description
Default
experiments
pd.DataFrame
Dataframe containing experimental data
required
prec
int
Precision of the rounding of the continuous input features
required
delimiter
str
Delimiter used when combining the orig. labcodes to a new one. Defaults to “-”.
'-'
method
Literal['mean', 'median']
Which aggregation method to use. Defaults to “mean”.
'mean'
Returns
Name
Type
Description
Tuple[pd.DataFrame, list]
Tuple[pd.DataFrame, list]: Dataframe holding the aggregated experiments, list of lists holding the labcodes of the duplicates
Check if all constraints are fulfilled on all rows of the provided dataframe both constraints and inputs are checked.
Parameters
Name
Type
Description
Default
experiments
pd.DataFrame
Dataframe with data, the constraint validity should be tested on
required
tol
float
Tolerance for checking the constraints. Defaults to 1e-6.
1e-06
exlude_interpoint
bool
If True, InterpointConstraints are excluded from the check. Defaults to True.
True
Returns
Name
Type
Description
pd.Series
Boolean series indicating if all constraints are fulfilled for all rows.
to_description
data_models.domain.domain.Domain.to_description()
Render a human-readable description of the optimization problem.
Covers problem context, objectives, and constraints. Feature details are handled separately by Inputs.to_pydantic_model() which embeds bounds, types, and context into the dynamic output schema.
Validates if provided input and output feature keys are unique
Parameters
Name
Type
Description
Default
v
Outputs
List of all output features of the domain.
required
value
Dict[str, Inputs]
Dict containing a list of input features as single entry.
required
Raises
Name
Type
Description
ValueError
Feature keys are not unique.
Returns
Name
Type
Description
Outputs
Keeps output features as given.
Source Code
# data_models.domain.domain.Domain { #bofire.data_models.domain.domain.Domain }```pythondata_models.domain.domain.Domain()```Representation of the optimization problem/domain## Attributes {.doc-section .doc-section-attributes}| Name | Type | Description ||-------------|--------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|| inputs | List\[Input\]| List of input features. Defaults to []. || outputs | List\[Output\]| List of output features. Defaults to []. || constraints | List\[Constraint\]| List of constraints. Defaults to []. || context | str | Free-text context providing additional information about the optimization problem. Useful for agentic optimization where an LLM agent can leverage this description to better understand the overall problem, its goals, and any domain-specific knowledge. |## Methods| Name | Description || ---| ---||[aggregate_by_duplicates](#bofire.data_models.domain.domain.Domain.aggregate_by_duplicates)| Aggregate the dataframe by duplicate experiments ||[coerce_invalids](#bofire.data_models.domain.domain.Domain.coerce_invalids)| Coerces all invalid output measurements to np.nan ||[describe_experiments](#bofire.data_models.domain.domain.Domain.describe_experiments)| Method to get a tabular overview of how many measurements and how many valid entries are included in the input data for each output feature ||[is_fulfilled](#bofire.data_models.domain.domain.Domain.is_fulfilled)| Check if all constraints are fulfilled on all rows of the provided dataframe ||[to_description](#bofire.data_models.domain.domain.Domain.to_description)| Render a human-readable description of the optimization problem. ||[validate_candidates](#bofire.data_models.domain.domain.Domain.validate_candidates)| Method to check the validty of proposed candidates ||[validate_constraints](#bofire.data_models.domain.domain.Domain.validate_constraints)| Validate that the constraints defined in the domain fit to the input features. ||[validate_experiments](#bofire.data_models.domain.domain.Domain.validate_experiments)| Checks the experimental data on validity ||[validate_unique_feature_keys](#bofire.data_models.domain.domain.Domain.validate_unique_feature_keys)| Validates if provided input and output feature keys are unique |### aggregate_by_duplicates { #bofire.data_models.domain.domain.Domain.aggregate_by_duplicates }```pythondata_models.domain.domain.Domain.aggregate_by_duplicates( experiments, prec, delimiter='-', method='mean',)```Aggregate the dataframe by duplicate experimentsDuplicates are identified based on the experiments with the same inputfeatures. Continuous input features are rounded before identifying theduplicates. Aggregation is performed by taking the average of theinvolved output features.#### Parameters {.doc-section .doc-section-parameters}| Name | Type | Description | Default ||-------------|---------------------------------|---------------------------------------------------------------------------------|------------|| experiments | pd.DataFrame | Dataframe containing experimental data | _required_ || prec | int | Precision of the rounding of the continuous input features | _required_ || delimiter | str | Delimiter used when combining the orig. labcodes to a new one. Defaults to "-". |`'-'`|| method | Literal\[\'mean\', \'median\'\]| Which aggregation method to use. Defaults to "mean". |`'mean'`|#### Returns {.doc-section .doc-section-returns}| Name | Type | Description ||--------|-----------------------------|-------------------------------------------------------------------------------------------------------------------------------||| Tuple\[pd.DataFrame, list\]| Tuple[pd.DataFrame, list]: Dataframe holding the aggregated experiments, list of lists holding the labcodes of the duplicates |### coerce_invalids { #bofire.data_models.domain.domain.Domain.coerce_invalids }```pythondata_models.domain.domain.Domain.coerce_invalids(experiments)```Coerces all invalid output measurements to np.nan#### Parameters {.doc-section .doc-section-parameters}| Name | Type | Description | Default ||-------------|--------------|----------------------------------------|------------|| experiments | pd.DataFrame | Dataframe containing experimental data | _required_ |#### Returns {.doc-section .doc-section-returns}| Name | Type | Description ||--------|--------------|---------------------------------||| pd.DataFrame | pd.DataFrame: coerced dataframe |### describe_experiments { #bofire.data_models.domain.domain.Domain.describe_experiments }```pythondata_models.domain.domain.Domain.describe_experiments(experiments)```Method to get a tabular overview of how many measurements and how many valid entries are included in the input data for each output feature#### Parameters {.doc-section .doc-section-parameters}| Name | Type | Description | Default ||-------------|--------------|----------------------------------|------------|| experiments | pd.DataFrame | Dataframe with experimental data | _required_ |#### Returns {.doc-section .doc-section-returns}| Name | Type | Description ||--------|--------------|---------------------------------------------------------------------------------------------------------------------------------------------||| pd.DataFrame | pd.DataFrame: Dataframe with counts how many measurements and how many valid entries are included in the input data for each output feature |### is_fulfilled { #bofire.data_models.domain.domain.Domain.is_fulfilled }```pythondata_models.domain.domain.Domain.is_fulfilled( experiments, tol=1e-06, exlude_interpoint=True,)```Check if all constraints are fulfilled on all rows of the provided dataframeboth constraints and inputs are checked.#### Parameters {.doc-section .doc-section-parameters}| Name | Type | Description | Default ||-------------------|--------------|-------------------------------------------------------------------------------|------------|| experiments | pd.DataFrame | Dataframe with data, the constraint validity should be tested on | _required_ || tol | float | Tolerance for checking the constraints. Defaults to 1e-6. |`1e-06`|| exlude_interpoint | bool | If True, InterpointConstraints are excluded from the check. Defaults to True. |`True`|#### Returns {.doc-section .doc-section-returns}| Name | Type | Description ||--------|-----------|--------------------------------------------------------------------------||| pd.Series | Boolean series indicating if all constraints are fulfilled for all rows. |### to_description { #bofire.data_models.domain.domain.Domain.to_description }```pythondata_models.domain.domain.Domain.to_description()```Render a human-readable description of the optimization problem.Covers problem context, objectives, and constraints. Feature detailsare handled separately by ``Inputs.to_pydantic_model()`` which embedsbounds, types, and context into the dynamic output schema.### validate_candidates { #bofire.data_models.domain.domain.Domain.validate_candidates }```pythondata_models.domain.domain.Domain.validate_candidates( candidates, only_inputs=False, tol=1e-05, raise_validation_error=True,)```Method to check the validty of proposed candidates#### Parameters {.doc-section .doc-section-parameters}| Name | Type | Description | Default ||------------------------|-------------------|-----------------------------------------------------------------------------------------------------------------------------------------|------------|| candidates | pd.DataFrame | Dataframe with suggested new experiments (candidates) | _required_ || only_inputs | (bool, optional) | If True, only the input columns are validated. Defaults to False. |`False`|| tol | (float, optional) | tolerance parameter for constraints. A constraint is considered as not fulfilled if the violation is larger than tol. Defaults to 1e-6. |`1e-05`|| raise_validation_error | bool | If true an error will be raised if candidates violate constraints, otherwise only a warning will be displayed. Defaults to True. |`True`|#### Raises {.doc-section .doc-section-raises}| Name | Type | Description ||--------|-----------------------------|----------------------------------------------------------------------------||| ValueError | when a column is missing for a defined input feature ||| ValueError | when a column is missing for a defined output feature ||| ValueError | when a non-numerical value is proposed ||| ValueError | when an additional column is found ||| ConstraintNotFulfilledError | when the constraints are not fulfilled and `raise_validation_error = True`|#### Returns {.doc-section .doc-section-returns}| Name | Type | Description ||--------|--------------|-----------------------------------------------------------------||| pd.DataFrame | pd.DataFrame: dataframe with suggested experiments (candidates) |### validate_constraints { #bofire.data_models.domain.domain.Domain.validate_constraints }```pythondata_models.domain.domain.Domain.validate_constraints()```Validate that the constraints defined in the domain fit to the input features.#### Parameters {.doc-section .doc-section-parameters}| Name | Type | Description | Default ||--------|--------------------|------------------------------------------------------------|------------|| v | List\[Constraint\]| List of constraints or empty if no constraints are defined | _required_ || values | List\[Input\]| List of input features of the domain | _required_ |#### Raises {.doc-section .doc-section-raises}| Name | Type | Description ||--------|------------|---------------------------------------||| ValueError | Feature key in constraint is unknown. |#### Returns {.doc-section .doc-section-returns}| Name | Type | Description ||--------|--------|--------------------------------------------------------------|||| List[Constraint]: List of constraints defined for the domain |### validate_experiments { #bofire.data_models.domain.domain.Domain.validate_experiments }```pythondata_models.domain.domain.Domain.validate_experiments(experiments, strict=False)```Checks the experimental data on validity#### Parameters {.doc-section .doc-section-parameters}| Name | Type | Description | Default ||-------------|--------------|---------------------------------------------------------------------------------------------------------------------------|------------|| experiments | pd.DataFrame | Dataframe with experimental data | _required_ || strict | bool | Boolean to distinguish if the occurrence of fixed features in the dataset should be considered or not. Defaults to False. |`False`|#### Raises {.doc-section .doc-section-raises}| Name | Type | Description ||--------|------------|----------------------------------------------------------------||| ValueError | empty dataframe ||| ValueError | the column for a specific feature is missing the provided data ||| ValueError | there are labcodes with null value ||| ValueError | there are labcodes with nan value ||| ValueError | labcodes are not unique ||| ValueError | the provided columns do no match to the defined domain ||| ValueError | the provided columns do no match to the defined domain ||| ValueError | Input with null values ||| ValueError | Input with nan values |#### Returns {.doc-section .doc-section-returns}| Name | Type | Description ||--------|--------------|-------------------------------------------------------------||| pd.DataFrame | pd.DataFrame: The provided dataframe with experimental data |### validate_unique_feature_keys { #bofire.data_models.domain.domain.Domain.validate_unique_feature_keys }```pythondata_models.domain.domain.Domain.validate_unique_feature_keys()```Validates if provided input and output feature keys are unique#### Parameters {.doc-section .doc-section-parameters}| Name | Type | Description | Default ||--------|---------------------|-----------------------------------------------------------|------------|| v | Outputs | List of all output features of the domain. | _required_ || value | Dict\[str, Inputs\]| Dict containing a list of input features as single entry. | _required_ |#### Raises {.doc-section .doc-section-raises}| Name | Type | Description ||--------|------------|------------------------------||| ValueError | Feature keys are not unique. |#### Returns {.doc-section .doc-section-returns}| Name | Type | Description ||---------|--------|---------------------------------|| Outputs || Keeps output features as given. |