Class UNNEPolicy
Class UNNEPolicy
- Defined in File NNEPolicy.h
Inheritance Relationships
Base Types
-
public UObject -
public IPolicy(Class IPolicy)
class UNNEPolicy : public UObject, public IPolicySource: 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
| Symbol | Details |
|---|---|
GetRuntimeNames | Retrieves all available NNE runtime names. |
GetRuntime | Gets the singleton runtime instance with the specified name. |
Think | Blueprint-callable wrapper for the Think function. |
Think | Runs neural network inference to compute an action from observations. |
Init | Initializes the policy with the given interaction definition. |
IsInferenceBusy | Checks if an inference operation is currently running. |
GetRuntimeNames
TArray<FString> GetRuntimeNames() constRetrieves 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) constGets 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
| # | Direction | Name | Type | Description |
|---|---|---|---|---|
| 1 | — | SelectedRuntimeName | const 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
| # | Direction | Name | Type | Description |
|---|---|---|---|---|
| 1 | — | InObservations | const FInstancedStruct & | The observations to process (generic instanced struct) |
| 2 | — | OutAction | FInstancedStruct & | 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) overrideRuns 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
| # | Direction | Name | Type | Description |
|---|---|---|---|---|
| 1 | — | InObservations | const FInstancedStruct & | The observations to process (generic instanced struct) |
| 2 | — | OutAction | FInstancedStruct & | The computed action (generic instanced struct) |
Attributes: inline
Source: Source/Schola/NNE/Public/Policies/NNEPolicy.h
Init
virtual bool Init(const FInteractionDefinition &InPolicyDefinition) overrideInitializes the policy with the given interaction definition.
Parameters
InPolicyDefinition – [in] The definition of observation and action spaces
Returns:
true if initialization succeeded, false otherwise
| # | Direction | Name | Type | Description |
|---|---|---|---|---|
| 1 | — | InPolicyDefinition | const 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 overrideChecks 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
| Symbol | Details |
|---|---|
PolicyDefinition | Defines the observation and action spaces for this policy. |
ModelData | The neural network model data asset used for inference. |
RuntimeName | The runtime name for inference execution. |
bNetworkLoaded | Flag indicating whether the neural network model loaded successfully. |
ActionBuffer | Buffer storing action data for neural network output. |
ObservationBuffer | Buffer storing observation data for neural network input. |
StateBuffer | Array of buffers storing recurrent state for sequence-based models. |
PolicyDefinition
FInteractionDefinition PolicyDefinitionDefines the observation and action spaces for this policy.
ModelData
TObjectPtr<UNNEModelData> ModelDataThe neural network model data asset used for inference.
RuntimeName
FString RuntimeNameThe runtime name for inference execution.
Enable NNE runtime plugins (e.g., NNERuntimeORT) to see options
bNetworkLoaded
bool bNetworkLoaded = falseFlag indicating whether the neural network model loaded successfully.
ActionBuffer
TInstancedStruct<FNNEPointBuffer> ActionBufferBuffer storing action data for neural network output.
ObservationBuffer
TInstancedStruct<FNNEPointBuffer> ObservationBufferBuffer storing observation data for neural network input.
StateBuffer
TArray<FNNEStateBuffer> StateBufferArray of buffers storing recurrent state for sequence-based models.
Protected Functions
| Symbol | Details |
|---|---|
InitInputTensorShapes | Initializes the input tensor shapes for the model instance. |
AllocateBindingArrays | Allocates arrays for input and output tensor bindings. |
InitStateBuffersAndBindings | Initializes state buffers and their bindings for recurrent models. |
InitNonStateBuffers | Initializes buffers for non-state data (observations and actions) |
InitNonStateBindings | Initializes tensor bindings for non-state data. |
SetupBuffersAndBindings | Sets 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
| # | Direction | Name | Type | Description |
|---|---|---|---|---|
| 1 | — | InModelInstance | TSharedPtr< 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
| # | Direction | Name | Type | Description |
|---|---|---|---|---|
| 1 | — | InModelInstance | TSharedPtr< 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
| # | Direction | Name | Type | Description |
|---|---|---|---|---|
| 1 | — | InModelInstance | TSharedPtr< 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
| # | Direction | Name | Type | Description |
|---|---|---|---|---|
| 1 | — | InDefinition | const 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
| # | Direction | Name | Type | Description |
|---|---|---|---|---|
| 1 | — | InDefinition | const 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
| # | Direction | Name | Type | Description |
|---|---|---|---|---|
| 1 | — | PolicyDefinition | const FInteractionDefinition & | The interaction definition |
| 2 | — | ModelInstance | TSharedPtr< IModelInstanceRunSync > | The model instance to set up for |
Source: Source/Schola/NNE/Public/Policies/NNEPolicy.h
Implementation: Source/Schola/NNE/Private/Policies/NNEPolicy.cpp