Skip to content

Class UNNEPolicy

Class UNNEPolicy

  • Defined in File NNEPolicy.h

Inheritance Relationships

Base Types

class UNNEPolicy : public UObject, public IPolicy

Source: Source/Schola/NNE/Public/Policies/NNEPolicy.h

Dependencies: FInteractionDefinition, FNNEPointBuffer, FNNEStateBuffer, FPoint, IModelInterface, IRuntimeInterface

Policy implementation that uses trained NNE models for decision-making.

This policy class integrates Unreal Engine’s Neural Network Engine (NNE) with the Schola reinforcement learning framework, enabling trained neural network models to control agents. Supports both CPU and GPU inference runtimes.


Public Functions

SymbolDetails
GetRuntimeNamesRetrieves all available NNE runtime names.
GetRuntimeGets the singleton runtime instance with the specified name.
ThinkBlueprint-callable wrapper for the Think function.
ThinkRuns neural network inference to compute an action from observations.
InitInitializes the policy with the given interaction definition.
IsInferenceBusyChecks if an inference operation is currently running.

GetRuntimeNames

TArray<FString> GetRuntimeNames() const

Retrieves all available NNE runtime names.

Returns:

Array of available runtime names that can be used for inference

Attributes: const

Source: Source/Schola/NNE/Public/Policies/NNEPolicy.h

Implementation: Source/Schola/NNE/Private/Policies/NNEPolicy.cpp

GetRuntime

IRuntimeInterface *GetRuntime(const FString &SelectedRuntimeName) const

Gets the singleton runtime instance with the specified name.

Parameters

SelectedRuntimeName – [in] The name of the runtime to retrieve

Returns:

Pointer to the runtime interface, or nullptr if not found

#DirectionNameTypeDescription
1SelectedRuntimeNameconst FString &The name of the runtime to retrieve

Attributes: const

Source: Source/Schola/NNE/Public/Policies/NNEPolicy.h

Implementation: Source/Schola/NNE/Private/Policies/NNEPolicy.cpp

Think

inline bool Think(const FInstancedStruct &InObservations,
FInstancedStruct &OutAction)

Blueprint-callable wrapper for the Think function.

Parameters

  • InObservations – [in] The observations to process (generic instanced struct)

  • OutAction – [out] The computed action (generic instanced struct)

Returns:

true if inference succeeded, false otherwise

#DirectionNameTypeDescription
1InObservationsconst FInstancedStruct &The observations to process (generic instanced struct)
2OutActionFInstancedStruct &The computed action (generic instanced struct)

Attributes: inline

Source: Source/Schola/NNE/Public/Policies/NNEPolicy.h

Think

virtual bool Think(const TInstancedStruct<FPoint> &InObservations,
TInstancedStruct<FPoint> &OutActions) override

Runs neural network inference to compute an action from observations.

Parameters

  • InObservations – [in] The observation point to process

  • OutActions – [out] The computed action point

Returns:

true if inference succeeded, false otherwise

#DirectionNameTypeDescription
1InObservationsconst FInstancedStruct &The observations to process (generic instanced struct)
2OutActionFInstancedStruct &The computed action (generic instanced struct)

Attributes: inline

Source: Source/Schola/NNE/Public/Policies/NNEPolicy.h

Init

virtual bool Init(const FInteractionDefinition &InPolicyDefinition) override

Initializes the policy with the given interaction definition.

Parameters

InPolicyDefinition – [in] The definition of observation and action spaces

Returns:

true if initialization succeeded, false otherwise

#DirectionNameTypeDescription
1InPolicyDefinitionconst FInteractionDefinition &The definition of observation and action spaces

Attributes: virtual

Source: Source/Schola/NNE/Public/Policies/NNEPolicy.h

Implementation: Source/Schola/NNE/Private/Policies/NNEPolicy.cpp

IsInferenceBusy

virtual bool IsInferenceBusy() const override

Checks if an inference operation is currently running.

Returns:

true if inference is in progress, false otherwise

Attributes: const, virtual

Source: Source/Schola/NNE/Public/Policies/NNEPolicy.h

Implementation: Source/Schola/NNE/Private/Policies/NNEPolicy.cpp


Public Members

SymbolDetails
PolicyDefinitionDefines the observation and action spaces for this policy.
ModelDataThe neural network model data asset used for inference.
RuntimeNameThe runtime name for inference execution.
bNetworkLoadedFlag indicating whether the neural network model loaded successfully.
ActionBufferBuffer storing action data for neural network output.
ObservationBufferBuffer storing observation data for neural network input.
StateBufferArray of buffers storing recurrent state for sequence-based models.

PolicyDefinition

FInteractionDefinition PolicyDefinition

Defines the observation and action spaces for this policy.


ModelData

TObjectPtr<UNNEModelData> ModelData

The neural network model data asset used for inference.


RuntimeName

FString RuntimeName

The runtime name for inference execution.

Enable NNE runtime plugins (e.g., NNERuntimeORT) to see options


bNetworkLoaded

bool bNetworkLoaded = false

Flag indicating whether the neural network model loaded successfully.


ActionBuffer

TInstancedStruct<FNNEPointBuffer> ActionBuffer

Buffer storing action data for neural network output.


ObservationBuffer

TInstancedStruct<FNNEPointBuffer> ObservationBuffer

Buffer storing observation data for neural network input.


StateBuffer

TArray<FNNEStateBuffer> StateBuffer

Array of buffers storing recurrent state for sequence-based models.


Protected Functions

SymbolDetails
InitInputTensorShapesInitializes the input tensor shapes for the model instance.
AllocateBindingArraysAllocates arrays for input and output tensor bindings.
InitStateBuffersAndBindingsInitializes state buffers and their bindings for recurrent models.
InitNonStateBuffersInitializes buffers for non-state data (observations and actions)
InitNonStateBindingsInitializes tensor bindings for non-state data.
SetupBuffersAndBindingsSets up all buffers and bindings for the policy.

InitInputTensorShapes

bool InitInputTensorShapes(TSharedPtr<IModelInstanceRunSync> InModelInstance)

Initializes the input tensor shapes for the model instance.

Parameters

InModelInstance – [in] The model instance to configure

Returns:

true if initialization succeeded, false otherwise

#DirectionNameTypeDescription
1InModelInstanceTSharedPtr< IModelInstanceRunSync >The model instance to configure

Source: Source/Schola/NNE/Public/Policies/NNEPolicy.h

Implementation: Source/Schola/NNE/Private/Policies/NNEPolicy.cpp

AllocateBindingArrays

bool AllocateBindingArrays(TSharedPtr<IModelInstanceRunSync> InModelInstance)

Allocates arrays for input and output tensor bindings.

Parameters

InModelInstance – [in] The model instance to allocate bindings for

Returns:

true if allocation succeeded, false otherwise

#DirectionNameTypeDescription
1InModelInstanceTSharedPtr< IModelInstanceRunSync >The model instance to allocate bindings for

Source: Source/Schola/NNE/Public/Policies/NNEPolicy.h

Implementation: Source/Schola/NNE/Private/Policies/NNEPolicy.cpp

InitStateBuffersAndBindings

bool InitStateBuffersAndBindings(
TSharedPtr<IModelInstanceRunSync> InModelInstance)

Initializes state buffers and their bindings for recurrent models.

Parameters

InModelInstance – [in] The model instance to initialize state for

Returns:

true if initialization succeeded, false otherwise

#DirectionNameTypeDescription
1InModelInstanceTSharedPtr< IModelInstanceRunSync >The model instance to initialize state for

Source: Source/Schola/NNE/Public/Policies/NNEPolicy.h

Implementation: Source/Schola/NNE/Private/Policies/NNEPolicy.cpp

InitNonStateBuffers

void InitNonStateBuffers(const FInteractionDefinition &InDefinition)

Initializes buffers for non-state data (observations and actions)

Parameters

InDefinition – [in] The interaction definition specifying buffer sizes

#DirectionNameTypeDescription
1InDefinitionconst FInteractionDefinition &The interaction definition specifying buffer sizes

Source: Source/Schola/NNE/Public/Policies/NNEPolicy.h

Implementation: Source/Schola/NNE/Private/Policies/NNEPolicy.cpp

InitNonStateBindings

bool InitNonStateBindings(const FInteractionDefinition &InDefinition)

Initializes tensor bindings for non-state data.

Parameters

InDefinition – [in] The interaction definition specifying binding structure

Returns:

true if initialization succeeded, false otherwise

#DirectionNameTypeDescription
1InDefinitionconst FInteractionDefinition &The interaction definition specifying binding structure

Source: Source/Schola/NNE/Public/Policies/NNEPolicy.h

Implementation: Source/Schola/NNE/Private/Policies/NNEPolicy.cpp

SetupBuffersAndBindings

bool SetupBuffersAndBindings(const FInteractionDefinition &PolicyDefinition,
TSharedPtr<IModelInstanceRunSync> ModelInstance)

Sets up all buffers and bindings for the policy.

Parameters

  • PolicyDefinition – [in] The interaction definition

  • ModelInstance – [in] The model instance to set up for

Returns:

true if setup succeeded, false otherwise

#DirectionNameTypeDescription
1PolicyDefinitionconst FInteractionDefinition &The interaction definition
2ModelInstanceTSharedPtr< IModelInstanceRunSync >The model instance to set up for

Source: Source/Schola/NNE/Public/Policies/NNEPolicy.h

Implementation: Source/Schola/NNE/Private/Policies/NNEPolicy.cpp