Identity Observation Operators#
|
Identity observation operator added for compatibility. |
Create an identity observation operator from a simulation model. |
Class implementing identity observation operator. This is added for compatibility. All functions/methods return a copy of the states passed as arguments.
Note
If the experimental design is altered (not all ones), an instance of the
Identity observation operator becomes effectively a selection operator;
see pyoed.observation_operators.array.SelectionOperator.
- class IdentityConfigs(*, debug=False, verbose=False, output_dir='./_PYOED_RESULTS_', design=None, model=None)[source]#
Bases:
ObservationOperatorConfigsConfiguration class for the identity observation operator.
- Parameters:
verbose (bool) – a boolean flag to control verbosity of the object.
debug (bool) – a boolean flag that enables adding extra functionality in a debug mode
output_dir (str | Path) – the base directory where the output files will be saved.
design (None | bool | Sequence[bool] | ndarray[bool]) –
an experimental design to define active/inactive entries of the observation vector.
Note
An experimental design here is always binary (on/off) indicating which entries of the design space are active/inactive. This corresponds to turning on/off some of the observational sensors. Thus, if the design is None, it is set to all ones; that is everything is observed
model (SimulationModel | None) – an instance of a simulation model derived from
pyoed.models.SimulationModel.
- model: SimulationModel | None#
- __init__(*, debug=False, verbose=False, output_dir='./_PYOED_RESULTS_', design=None, model=None)#
- class Identity(configs=None)[source]#
Bases:
ObservationOperatorIdentity observation operator added for compatibility. All functions/methods return a copy of the states passed as arguments.
In addition to standard functionality, here we provide a specific attribute ‘design’ which enables modifying the observation space by projection/selection.
If the design is a binary vector (bool or int dtype attributes with 0/1 entries), the observation operator restricts observations to only entries identified by the 1/True entries. This acts like sensor placing/activation where 1 means ON/ACTIVE, and 0 means OFF.
If the design contains non-binary values, it is transformed to boolean flag; any entry in the design variable that’s not zero is set to 1.
- Raises:
PyOEDConfigsValidationError – if the passed model is not an instance of
pyoed.models.SimulationModel.
- validate_configurations(configs, raise_for_invalid=True)[source]#
Check the passed configuratios and make sure they are conformable with each other, and with current configurations once combined. This guarantees that any key-value pair passed in configs can be properly used
Note
Here only the locally-defined configurations in
IdentityConfigsare validated. Finally, super classes validators are called.- Parameters:
configs – full or partial (subset) configurations to be validated
raise_for_invalid – if True raise an error for invalid configrations type/key. Default True
- Returns:
flag indicating whether passed configurations dictionary is valid or not
- Raises:
AttributeError – if any (or a group) of the configurations does not exist in the model configurations
IdentityConfigs.PyOEDConfigsValidationError – if the configurations are invalid and raise_for_invalid is set to True.
- update_configurations(**kwargs)[source]#
Take any set of keyword arguments, and lookup each in the configurations, and update as nessesary/possible/valid
- Raises:
TypeError – if any of the passed keys in kwargs is invalid/unrecognized
- apply(state, eval_at_t=None)[source]#
Given a state vector (laid out as defined by the model grid passed upon instantiation), evaluate the observation vector by just mirroring, and potentialy restriction if the design is to be applied.
- Parameters:
state – instance of a model state with entries corresponding the model grid passed upon instantiation
eval_at_t – the time at which the observation operator is evaluated. Since some observation operators are time-dependent, this parameter is added for generality and for a unified interface.
- Returns:
an observation vector/instance
- Raises:
TypeError is raised if state has the wrong shape.
- Jacobian_T_matvec(observation, eval_at=None, eval_at_t=None)[source]#
Multiply (Matrix-free matrix-vector product) of transpose of the Jacobian/tangent-linear (TLM) of the observation operator by the passed observation; The Jacobian is evaluated (for nonlinear operators) at eval_at
- Parameters:
observation – observation instance/vector
eval_at – state around which observation operator is linearized; ignored here since the observation operator here is linear
eval_at_t – the time at which the observation operator is evaluated. Since some observation operators are time-dependent, this parameter is added for generality and for a unified interface.
- Returns:
result of multiplying the transpose of derivative of the observation operator by the passed observation
- Raises:
TypeError – if the passed observation is invalid (type/shape/etc.)
- get_active_observation_grid()[source]#
Return a copy of the active observational grid accounting for the experimental design.
- property shape#
A tuple holding the shape of the observation operator (model state size, model state size)
- property model#
The underlying simulation model
- create_Identity_observation_operator(model)[source]#
Create an identity observation operator from a simulation model. The observation operator is identity, so it just mirrors a model state.
- Parameters:
model – a simulation model object; instance of
SimulationModel- Returns:
an instance of
Identityinistantiated based on the passed simulation model