UNNEPolicy
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.
class UNNEPolicy : public UObject, public IPolicyMethods
Public
GetRuntimeNames
TArray<FString> GetRuntimeNames() constRetrieves all available NNE runtime names.
GetRuntime
IRuntimeInterface *GetRuntime(const FString &SelectedRuntimeName) constGets the singleton runtime instance with the specified name.
Parameters
SelectedRuntimeName(const FString)
Think
inline bool Think(const FInstancedStruct &InObservations, FInstancedStruct &OutAction)Blueprint-callable wrapper for the Think function.
Parameters
-
InObservations(const FInstancedStruct) -
OutAction(FInstancedStruct)
Think
virtual bool Think(const TInstancedStruct<FPoint> &InObservations, TInstancedStruct<FPoint> &OutActions) overrideRuns neural network inference to compute an action from observations.
Parameters
-
InObservations(const TInstancedStruct<FPoint>) -
OutActions(TInstancedStruct<FPoint>)
Init
virtual bool Init(const FInteractionDefinition &InPolicyDefinition) overrideInitializes the policy with the given interaction definition.
Parameters
InPolicyDefinition(const FInteractionDefinition)
IsInferenceBusy
virtual bool IsInferenceBusy() const overrideChecks if an inference operation is currently running.
Protected
InitInputTensorShapes
bool InitInputTensorShapes(TSharedPtr<IModelInstanceRunSync> InModelInstance)Initializes the input tensor shapes for the model instance.
Parameters
InModelInstance(TSharedPtr<IModelInstanceRunSync>)
AllocateBindingArrays
bool AllocateBindingArrays(TSharedPtr<IModelInstanceRunSync> InModelInstance)Allocates arrays for input and output tensor bindings.
Parameters
InModelInstance(TSharedPtr<IModelInstanceRunSync>)
InitStateBuffersAndBindings
bool InitStateBuffersAndBindings( TSharedPtr<IModelInstanceRunSync> InModelInstance)Initializes state buffers and their bindings for recurrent models.
Parameters
InModelInstance(TSharedPtr<IModelInstanceRunSync>)
InitNonStateBuffers
void InitNonStateBuffers(const FInteractionDefinition &InDefinition)Initializes buffers for non-state data (observations and actions)
Parameters
InDefinition(const FInteractionDefinition)
InitNonStateBindings
bool InitNonStateBindings(const FInteractionDefinition &InDefinition)Initializes tensor bindings for non-state data.
Parameters
InDefinition(const FInteractionDefinition)
SetupBuffersAndBindings
bool SetupBuffersAndBindings(const FInteractionDefinition &PolicyDefinition, TSharedPtr<IModelInstanceRunSync> ModelInstance)Sets up all buffers and bindings for the policy.
Parameters
-
PolicyDefinition(const FInteractionDefinition) -
ModelInstance(TSharedPtr<IModelInstanceRunSync>)
Attributes
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.
MaxStateSequenceLength
int MaxStateSequenceLength = 1Maximum sequence length for state buffers with a sequence dimension.
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.