Loading...
Searching...
No Matches
HydroCouple::IDifferentiableAdaptedOutput Class Referenceabstract

IDifferentiableAdaptedOutput is an adapted output that can report the derivative of its most recent refresh(). More...

#include <hydrocouple.h>

Inheritance diagram for HydroCouple::IDifferentiableAdaptedOutput:
Collaboration diagram for HydroCouple::IDifferentiableAdaptedOutput:

Public Member Functions

virtual ~IDifferentiableAdaptedOutput ()=default
 ~IDifferentiableAdaptedOutput destructor.
 
virtual std::vector< IArgument * > differentiableArguments () const =0
 The arguments of this adapter a derivative reaches (may be empty).
 
virtual std::vector< IComponentDataItem * > differentiableStates () const =0
 The data items that carry state from one refresh() to the next and that the derivative follows; a subset of states().
 
virtual bool vjp (DifferentialSet seeds, DifferentialSet results, std::string *message=nullptr)=0
 Vector-Jacobian product of the most recent refresh().
 
virtual bool jvp (DifferentialSet seeds, DifferentialSet results, std::string *message=nullptr)=0
 Jacobian-vector product of the most recent refresh().
 
- Public Member Functions inherited from HydroCouple::IAdaptedOutput
virtual ~IAdaptedOutput ()=default
 IAdaptedOutput::~IAdaptedOutput is a virtual destructor.
 
virtual IAdaptedOutputFactory * adaptedOutputFactory () const =0
 IAdaptedOutputFactory that generated this IAdaptedOutput.
 
virtual std::vector< IArgument * > arguments () const =0
 IArgument represents input parameters needed for this IAdaptedOutput.
 
virtual void initialize ()=0
 Lets this IAdaptedOutput initialize() itself, based on the current values specified by the arguments.
 
virtual IOutput * adaptee () const =0
 IOutput that this IAdaptedOutput extracts content from.
 
virtual void refresh ()=0
 Requests the IAdaptedOutput to refresh itself and perform any necessary calculations.
 
virtual std::vector< IComponentDataItem * > states () const =0
 The data items that make up the state carried from one refresh() to the next.
 
- Public Member Functions inherited from HydroCouple::IOutput
virtual ~IOutput ()=default
 IOutput::~IOutput is a virtual destructor.
 
virtual std::vector< IInput * > consumers () const =0
 Input items that will consume the values by calling the IOutput::updateValues() method.
 
virtual void addConsumer (IInput *consumer, const IIdentity *providerRole=nullptr)=0
 Connects a consumer to this output item.
 
virtual bool removeConsumer (IInput *consumer)=0
 Disconnects a consumer.
 
virtual std::vector< IAdaptedOutput * > adaptedOutputs () const =0
 The adaptedOutputs that have this current output item as adaptee.
 
virtual void addAdaptedOutput (IAdaptedOutput *adaptedOutput)=0
 Add a IAdaptedOutput to this output item.
 
virtual bool removeAdaptedOutput (IAdaptedOutput *adaptedOutput)=0
 Removes an IAdaptedOutput.
 
virtual void updateValues (const IInput *querySpecifier)=0
 Brings this output's values up to what the querySpecifier requires.
 
- Public Member Functions inherited from HydroCouple::IExchangeItem
virtual ~IExchangeItem ()=default
 IExchangeItem::~IExchangeItem is a virtual destructor.
 
- Public Member Functions inherited from HydroCouple::IComponentDataItem
virtual ~IComponentDataItem ()=default
 IComponentDataItem::~IComponentDataItem is a virtual destructor.
 
virtual IModelComponent * modelComponent () const =0
 Gets the owner IModelComponent of this IComponentItem.
 
virtual std::vector< IDimension * > dimensions () const =0
 The axes of this item's index space, in storage order.
 
virtual std::vector< int64_t > shape () const =0
 The extent of each dimension of this data item's index space.
 
virtual DataKind dataKind () const =0
 The element type of this data item's values.
 
virtual IValueDefinition * valueDefinition () const =0
 IValueDefinition for this IComponentDataItem defines the variable type associated with this object.
 
virtual bool getValuesInto (const BufferDescriptor &destination, std::span< const int64_t > start, std::span< const int64_t > count, std::string *message=nullptr) const =0
 Copies a hyperslab of this item's values into a caller-described buffer.
 
virtual bool setValuesFrom (const BufferDescriptor &source, std::span< const int64_t > start, std::span< const int64_t > count, std::string *message=nullptr)=0
 Copies values from a caller-described buffer into a hyperslab of this item.
 
- Public Member Functions inherited from HydroCouple::IIdentity
virtual ~IIdentity ()=default
 IIdentity::~IIdentity is a virtual destructor.
 
virtual const std::string & id () const =0
 Gets a unique identifier for the entity.
 
- Public Member Functions inherited from HydroCouple::IDescription
virtual ~IDescription ()=default
 IDescription::~IDescription is a virtual destructor.
 
virtual const std::string & caption () const =0
 Gets caption for the entity.
 
virtual void setCaption (const std::string &caption)=0
 Sets caption for the entity.
 
virtual const std::string & description () const =0
 Gets additional descriptive information for the entity.
 
virtual void setDescription (const std::string &description)=0
 Gets additional descriptive information for the entity.
 
- Public Member Functions inherited from HydroCouple::IPropertyChanged
virtual ~IPropertyChanged ()=default
 IPropertyChanged::~IPropertyChanged is a virtual destructor.
 
- Public Member Functions inherited from HydroCouple::ISignal< std::string >
virtual ~ISignal ()=default
 ISignal::~ISignal is a virtual destructor.
 
virtual void connect (const std::shared_ptr< ISlot< Args... > > &slot)=0
 connect is used to connect a slot to the signal.
 
virtual void disconnect (const std::shared_ptr< ISlot< Args... > > &slot)=0
 disconnect is used to disconnect a slot from the signal.
 
virtual void blockSignals (bool block)=0
 blockSignals is used to block signals from being emitted.
 
- Public Member Functions inherited from HydroCouple::ISignal< const std::shared_ptr< IComponentDataItemValueChanged > & >
virtual ~ISignal ()=default
 ISignal::~ISignal is a virtual destructor.
 
virtual void connect (const std::shared_ptr< ISlot< Args... > > &slot)=0
 connect is used to connect a slot to the signal.
 
virtual void disconnect (const std::shared_ptr< ISlot< Args... > > &slot)=0
 disconnect is used to disconnect a slot from the signal.
 
virtual void blockSignals (bool block)=0
 blockSignals is used to block signals from being emitted.
 

Additional Inherited Members

- Protected Member Functions inherited from HydroCouple::ISignal< std::string >
virtual void emit (Args... args)=0
 emit is used to emit the signal.
 
- Protected Member Functions inherited from HydroCouple::ISignal< const std::shared_ptr< IComponentDataItemValueChanged > & >
virtual void emit (Args... args)=0
 emit is used to emit the signal.
 

Detailed Description

IDifferentiableAdaptedOutput is an adapted output that can report the derivative of its most recent refresh().

The adapter's counterpart of IDifferentiableModelComponent, so that a derivative can cross an adapted connection (a unit conversion, a regridding, a rescaling) on its way from a consumer back to a provider. An adapter maps its adaptee's values, its own arguments and – when it has one – the state it held before the refresh to its own values and the state it holds after it. In a DifferentialEntry:

Buffers, seeds and results follow IDifferentiableModelComponent exactly: whole-item buffers, results written rather than accumulated, absent seeds zero, and the linearization point is the most recent refresh(). vjp() and jvp() do not change the adapter's values or its state.

State. An adapter whose values depend on its previous refreshes (under-relaxation, say) lists the items carrying that dependence in differentiableStates(), exactly as a component does, so a state cotangent can be carried from one refresh to the previous one by whoever composes the derivative. A state item keeps its shape across a refresh; an adapter that must change it (its adaptee changed shape, say) starts its state afresh, and that refresh's derivative reaches nothing before it. An orchestrator that must differentiate more than one refresh restores the earlier ones through ICheckpointableAdaptedOutput, which a stateful differentiable adapter should therefore also implement. An adapter whose state the derivative cannot follow (one whose state changes shape as it grows) must not implement this interface, and an orchestrator treats a connection through it as non-differentiable rather than guess.

Constructor & Destructor Documentation

◆ ~IDifferentiableAdaptedOutput()

virtual HydroCouple::IDifferentiableAdaptedOutput::~IDifferentiableAdaptedOutput ( )
virtualdefault

~IDifferentiableAdaptedOutput destructor.

Member Function Documentation

◆ differentiableArguments()

virtual std::vector< IArgument * > HydroCouple::IDifferentiableAdaptedOutput::differentiableArguments ( ) const
nodiscardpure virtual

The arguments of this adapter a derivative reaches (may be empty).

◆ differentiableStates()

virtual std::vector< IComponentDataItem * > HydroCouple::IDifferentiableAdaptedOutput::differentiableStates ( ) const
nodiscardpure virtual

The data items that carry state from one refresh() to the next and that the derivative follows; a subset of states().

Empty for an adapter whose values depend only on its adaptee's current values and its arguments (the common case).

◆ jvp()

virtual bool HydroCouple::IDifferentiableAdaptedOutput::jvp ( DifferentialSet seeds,
DifferentialSet results,
std::string * message = nullptr )
nodiscardpure virtual

Jacobian-vector product of the most recent refresh().

Parameters
[in]seedsholds tangents of the adaptee (role Input), of arguments (role Argument) and of states before the refresh (role StateBefore).
[in]resultsholds buffers to overwrite with this adapter's tangent (role Output) and the tangents of its states after the refresh (role StateAfter).
[out]messageoptionally receives a failure description.
Returns
True on success.

◆ vjp()

virtual bool HydroCouple::IDifferentiableAdaptedOutput::vjp ( DifferentialSet seeds,
DifferentialSet results,
std::string * message = nullptr )
nodiscardpure virtual

Vector-Jacobian product of the most recent refresh().

Parameters
[in]seedsholds cotangents of this adapter (role Output) and of its states after the refresh (role StateAfter).
[in]resultsholds buffers to overwrite with cotangents of the adaptee (role Input), of arguments (role Argument) and of states before the refresh (role StateBefore).
[out]messageoptionally receives a failure description.
Returns
True on success.

The documentation for this class was generated from the following file: