leaspy.io.realizations
.AbstractRealization
- class AbstractRealization(name: str, shape: Tuple[int, ...], *, tensor: Tensor | None = None, tensor_copy: bool = True, **kwargs)
Bases:
object
Abstract class for Realization.
- Parameters:
- nameParamType
The name of the variable associated with the realization.
- shapeTuple[int, …]
The shape of the tensor realization.
- tensortorch.Tensor, optional
If not None, the tensor realization to be stored.
- tensor_copybool (default True)
Whether the tensor provided is copied or not.
- **kwargsdict
Additional parameters.
- Attributes:
- nameParamType
The name of the variable associated with the realization.
- shapeTuple[int, …]
The shape of the tensor realization.
- tensortorch.Tensor
The tensor realization.
Methods
initialize
(model, **kwargs)Initialize realization from a given model.
Set autograd for tensor of realizations.
set_tensor_realizations_element
(element, dim)Manually change the value (in-place) of tensor_realizations at dimension dim.
to_dict
()Return a serialized dictionary of realization attributes.
Unset autograd for tensor of realizations
- abstract initialize(model: AbstractModel, **kwargs: KwargsType)
Initialize realization from a given model.
- Parameters:
- model
AbstractModel
The model you want realizations for.
- **kwargsKwargsType
Additional parameters for initialization.
- model
- Raises:
LeaspyModelInputError
if unknown variable type
- set_autograd() None
Set autograd for tensor of realizations.
TODO remove? only in legacy code
- Raises:
ValueError
if inconsistent internal request
See also
- set_tensor_realizations_element(element: Tensor, dim: tuple[int, ...]) None
Manually change the value (in-place) of tensor_realizations at dimension dim.
- Parameters:
- elementtorch.Tensor
The element to put in the tensor realization.
- dimTuple[int, …]
The dimension where to put the element.
- unset_autograd() None
Unset autograd for tensor of realizations
TODO remove? only in legacy code
- Raises:
ValueError
if inconsistent internal request
See also