Domains¶
Domains represent the variables and constraints of an optimisation space. Each reaction optimisation problem will have an associated domain.
-
class
summit.domain.
CategoricalVariable
(name, description, **kwargs)[source]¶ -
add_level
(level)[source]¶ Add a level to the discrete variable
- Parameters
level – Value to add to the levels of the discrete variable
- Raises
ValueError – If the level is already in the list of levels
-
property
levels
¶ Potential values of the discrete variable
- Type
numpy.ndarray
-
property
num_descriptors
¶ Returns the number of descriptors
-
-
class
summit.domain.
Constraint
(lhs, constraint_type='<=')[source]¶ A constraint for an optimization domain
- Parameters
lhs (str) – The left hand side of a constraint equation
constraint_type (str) – The type of constraint. Must be <, <=, ==, > or >=. Default: “<=”
- Raises
ValueError –
Examples
These should be constraints in the form “lhs constraint_type constraint 0” So for example, x+y=3 should be rewritten as x+y-3=0 and therefore:
>>> domain = Domain() >>> domain += Constraint(lhs="x+y-3", constraint_type="==")
Or x+y<0 would be:
>>> domain = Domain() >>> domain += Constraint(lhs="x+y", constraint_type="<")
-
class
summit.domain.
ContinuousVariable
(name: str, description: str, bounds: list, **kwargs)[source]¶ Representation of a continuous variable
- Parameters
name (str) – The name of the variable
description (str) – A short description of the variable
bounds (list of float or int) – The lower and upper bounds (respectively) of the variable
is_objective (bool, optional) – If True, this variable is an output. Defaults to False (i.e., an input variable)
maximize (bool, optional) – If True, the output will be maximized; if False, it will be minimized. Defaults to True.
-
name
¶
-
description
¶
-
bounds
¶
-
lower_bound
¶
-
upper_bound
¶
Examples
>>> var = ContinuousVariable('temperature', 'reaction temperature', [1, 100])
-
property
bounds
¶ Lower and upper bound of the variable
- Type
numpy.ndarray
-
property
lower_bound
¶ lower bound of the variable
- Type
float or int
-
property
upper_bound
¶ upper bound of the variable
- Type
float or int
-
class
summit.domain.
Domain
(variables=[], constraints=[])[source]¶ Representation of the optimization domain
- Parameters
variables (
Variable
or list ofVariable
like objects, optional) – list of variable objects (i.e., ContinuousVariable, CategoricalVariable)constraints (
Constraint
or list ofConstraint
objects, optional) – list of constraints on the problem
-
variables
¶
- Raises
TypeError – If variables or constraints are not lists or a single instance of the object
ValueError – If variable names are not unique
Examples
>>> domain = Domain() >>> domain += ContinuousVariable('temperature', 'reaction temperature', [1, 100])
-
get_categorical_combinations
()[source]¶ Get all combinations of categoricals using full factorial design
- Returns
ds – A dataset containing the combinations of all categorical cvariables.
- Return type
-
num_continuous_dimensions
(include_descriptors=False, include_outputs=False) → int[source]¶ The number of continuous dimensions
- Parameters
include_descriptors (bool, optional) – If True, the number of descriptors columns are considered. Defaults to False.
include_outputs (bool, optional) – If True include output variables in the count. Defaults to False.
- Returns
num_variables – Number of variables in the domain
- Return type
int
-
class
summit.domain.
Variable
(name: str, description: str, variable_type: str, **kwargs)[source]¶ A base class for variables
- Parameters
name (str) – The name of the variable
description (str) – A short description of the variable
is_objective (bool, optional) – If True, this variable is an output. Defaults to False (i.e., an input variable)
maximize (bool, optional) – If True, the output will be maximized; if False, it will be minimized. Defaults to True.
units (str, optional) – Units of the variable. Defaults to None.
-
name
¶
-
description
¶
-
property
description
¶ description of the variable
- Type
str
-
property
name
¶ name of the variable
- Type
str