Power Observation Operators#

Power([configs])

Power observation operator takes as input the model state and raise it to a given power.

Exponential([configs])

Exponential observation operator takes as input the model state and return the natural exponent of this state, projected onto the active observation space (or not) based on how PyOED is configured.

create_Power_observation_operator(model, power)

Create a power observation operator from a simulation model.

create_Exponential_observation_operator(model)

Create a power observation operator from a simulation model.

Class for implementing oversimplified non-linear observation operators.

class PowerConfigs(*, debug=False, verbose=False, output_dir='./_PYOED_RESULTS_', design=None, model=None, power=2.0)[source]#

Bases: IdentityConfigs

Configuration class for the Power 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

  • power (float) – the power to raise the model state to.

power: float#
__init__(*, debug=False, verbose=False, output_dir='./_PYOED_RESULTS_', design=None, model=None, power=2.0)#
class Power(configs=None)[source]#

Bases: Identity

Power observation operator takes as input the model state and raise it to a given power.

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.

__init__(configs=None)[source]#
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 PowerConfigs are 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:
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 applying the power observation operator, and potentially restriction if the design (active/inactive) 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; this is ignored here because the operator 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.)

property power#

The power used for defining the observation operator

class ExponentialConfigs(*, debug=False, verbose=False, output_dir='./_PYOED_RESULTS_', design=None, model=None)[source]#

Bases: IdentityConfigs

Configuration class for the Power 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

  • power – the power to raise the model state to.

__init__(*, debug=False, verbose=False, output_dir='./_PYOED_RESULTS_', design=None, model=None)#
class Exponential(configs=None)[source]#

Bases: Identity

Exponential observation operator takes as input the model state and return the natural exponent of this state, projected onto the active observation space (or not) based on how PyOED is configured.

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.

__init__(configs=None)[source]#
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 applying the power observation operator, and potentially restriction if the design (active/inactive) 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.

  • 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.)

create_Power_observation_operator(model, power)[source]#

Create a power observation operator from a simulation model. The observation operator raises a model state values to a specified power.

Parameters:
  • model – a simulation model object; instance of SimulationModel

  • power – the power (scalar) used to define the observation operator

Returns:

an instance of Power instantiated based on the passed simulation model

create_Exponential_observation_operator(model)[source]#

Create a power observation operator from a simulation model. The observation operator raises a model state values to a specified power.

Parameters:

model – a simulation model object; instance of SimulationModel

Returns:

an instance of Power instantiated based on the passed simulation model