deepcave.runs.objective¶
# Objective
This module provides utilities to convert and create objectives. It also provides functions for merging and comparing objectives.
- ## Classes
Objective: Convert and create objectives.
Classes
|
Convert, create and merge objectives. |
- class deepcave.runs.objective.Objective(name, lower=None, upper=None, optimize='lower')[source]¶
Bases:
object
Convert, create and merge objectives.
Properties¶
- lowerOptional[Union[int, float]]
The lower bound of the objective.
- upperOptional[Union[int, float]]
The upper bound of the objective.
- optimizestr
Define whether to optimize lower or upper.
- lock_lowerbool
Whether to lock the lower bound.
- lock_upperbool
Whether to lock the upper bound.
- namestr
The name of the objective.
- __eq__(other)[source]¶
Compare if two instances are equal based on their attributes.
- Parameters:
other (Any) – The other instance to compare.
- Returns:
True if equal, else False.
- Return type:
bool
- __post_init__()[source]¶
Check if bounds should be locked.
Lock the lower bound if lower is not None. Lock the upper bound if upper is not None.
Additionally, sets self.lower to np.inf if it is None and self.upper to -np.inf if it is None, resulting in an empty bound. Therefore, the values will be updated as soon as configurations are added.
- Raises:
RuntimeError – If optimize is not lower or upper.
- Return type:
None
- static from_json(d)[source]¶
Create an objective from a JSON friendly dictionary format.
- Parameters:
d (Dict[str, Any]) – A dictionary in a JSON friendly format containing the attributes.
- Returns:
An objective created from the provided data.
- Return type:
- get_worst_value()[source]¶
Get the worst value based on the optimization setting.
- Returns:
The worst value based on the optimization setting.
- Return type:
float
- merge(other)[source]¶
Merge two Objectives over their attributes.
- Parameters:
other (Any) – The other Objective to merge.
- Raises:
NotMergeableError – If parts of the two Objectives are not mergeable.
ValueError – If the lower bound of one Objective is None. If the upper bound of one Objective is None.
- Return type:
None