Asset#
- class eclypse.graph.assets.asset.Asset[source]#
Bases:
objectThe Asset class.
An Asset represents a resource of the infrastructure, such as CPU, GPU, RAM or node availability.
It provides the inteface for the basic algebraic functions between assets.
Methods
__init__(lower_bound, upper_bound[, ...])Initialize the asset with the lower and upper bounds.
aggregate(*assets)Aggregate the assets into a single asset.
flip()Flip the asset.
is_consistent(asset)Check if the asset has a feasible value.
satisfies(asset, constraint)Check if the asset satisfies the constraint.
- __init__(lower_bound, upper_bound, init_fn_or_value=None, functional=True)[source]#
Initialize the asset with the lower and upper bounds.
The lower and the upper bounds represent the element which is always contained in and the element the always contains the asset, respectively. Thus, they must respect the total ordering of the asset.
The init_fn_or_value parameter is the function to initialize the asset. It can be a primitive type, a callable with no arguments or an AssetSpace object. If it is not provided, the asset will be initialized with the lower bound.
The functional parameter indicates if the asset is functional or not, thus if it must be checked during the validation of a placement or not.
- Parameters:
lower_bound (Any) – The lower bound of the asset.
upper_bound (Any) – The upper bound of the asset.
init_fn_or_value (PrimitiveType | AssetSpace | Callable[[], Any] | None) – The function to initialize the asset. It can be a primitive type, a callable with no arguments or an AssetSpace object. If it is not provided, the asset will be initialized with the lower bound. Defaults to None.
functional (bool, optional) – If True, the asset is functional. Defaults to True.
- Raises:
ValueError – If the lower bound is not contained in the upper bound.
TypeError – If the init_fn is not a callable or an AssetSpace object.
- abstractmethod aggregate(*assets)[source]#
Aggregate the assets into a single asset.
- Parameters:
assets (Any) – The assets to aggregate.
- Return type:
Any
- abstractmethod satisfies(asset, constraint)[source]#
Check if the asset satisfies the constraint.
- Parameters:
asset (Any) – The asset to check.
constraint (Any) – The constraint to check.
- Returns:
True if the asset satisfies the constraint, False otherwise.
- Return type:
bool