NeuralEngine
A Game Engine with embeded Machine Learning algorithms based on Gaussian Processes.
NeuralEngine::MachineLearning::GPNode< Scalar > Class Template Reference

This class represents grouping nodes in a hiearchy. More...

#include <FgGPNode.h>

Inheritance diagram for NeuralEngine::MachineLearning::GPNode< Scalar >:
Collaboration diagram for NeuralEngine::MachineLearning::GPNode< Scalar >:

Public Member Functions

 GPNode ()
 Default constructor. More...
 
virtual ~GPNode ()
 Destructor. More...
 
int GetNumChildren () const
 Gets the number of children of this item. More...
 
int AttachChild (std::shared_ptr< GPNode< Scalar > > const &child)
 Attaches a child. More...
 
int DetachChild (std::shared_ptr< GPNode< Scalar > > const &child)
 Detaches a child. More...
 
std::shared_ptr< GPNode< Scalar > > DetachChildAt (int i)
 Detaches a child at index. More...
 
void DetachAllChildren ()
 Detach all children from this node. More...
 
std::shared_ptr< GPNode< Scalar > > SetChild (int i, std::shared_ptr< GPNode< Scalar > > const &child)
 Sets a child. More...
 
std::shared_ptr< GPNode< Scalar > > GetChild (int i)
 Gets a child at index. More...
 
GPNode< Scalar > * GetParent ()
 Access to the parent object, which is null for the root of the hierarchy. More...
 
void SetParent (GPNode< Scalar > *parent)
 
Access to the parent object. Node calls this during attach/detach of children. More...
 

Protected Attributes

std::vector< std::shared_ptr< GPNode< Scalar > > > mChild
 
GPNode< Scalar > * mParent
 

Private Member Functions

template<class Archive >
void serialize (Archive &ar, unsigned int version)
 

Friends

class boost::serialization::access
 
class GPModels::AEP::SDGPLVM< Scalar >
 
class GPModels::AEP::SGPLVM< Scalar >
 

Detailed Description

template<typename Scalar>
class NeuralEngine::MachineLearning::GPNode< Scalar >

This class represents grouping nodes in a hiearchy.

, 19.07.2018.

Definition at line 41 of file FgGPNode.h.

Constructor & Destructor Documentation

◆ GPNode()

template<typename Scalar >
NeuralEngine::MachineLearning::GPNode< Scalar >::GPNode ( )

Default constructor.

Hmetal T, 03/04/2020.

◆ ~GPNode()

template<typename Scalar >
virtual NeuralEngine::MachineLearning::GPNode< Scalar >::~GPNode ( )
virtual

Destructor.

Hmetal T, 04/04/2020.

Member Function Documentation

◆ GetNumChildren()

template<typename Scalar >
int NeuralEngine::MachineLearning::GPNode< Scalar >::GetNumChildren ( ) const

Gets the number of children of this item.


This is the current number of elements in the child array. These elements are not all guaranteed to be non-null. Thus, when you
iterate over the array and access children with GetChild(...), you should verify the child pointer is not null before dereferencing it.

, 19.07.2018.

Returns
The number children.

◆ AttachChild()

template<typename Scalar >
int NeuralEngine::MachineLearning::GPNode< Scalar >::AttachChild ( std::shared_ptr< GPNode< Scalar > > const &  child)

Attaches a child.


Attach a child to this node. If the function succeeds, the return value is the index i of the array where the child was stored, in which case 0 <= i < GetNumChildren(). The first available empty slot of the child array is used for storage. If all slots are filled, the child is appended to the array (potentially causing a reallocation of the array).

The function fails when 'child' is null or when 'child' already has a parent, in which case the return value is -1. The nodes form a tree, not a more general directed acyclic graph. A consequence is that a node cannot have more than one parent. For example, Node* node0 = <some node>; Spatial* child = <some child> int index = node0->AttachChild(child); Node* node1 = <some node>

// This asserts because 'child' already has a parent (node0). node1->AttachChild(child);

// The following is the correct way to give 'child' a new parent. node0->DetachChild(child); // or node0->DetachChildAt(index); node1->AttachChild(child);

// In the last example before the DetachChild call, if 'child' is // referenced only by node0, the detach will cause 'child' to be // deleted (Node internally reference counts its children). If // you want to keep 'child' around for later use, do the following. Spatial::SP saveChild = SPCreate(node0->GetChild(0)); node0->DetachChild(saveChild); node1->AttachChild(saveChild);

, 19.07.2018.

Parameters
childThe child.
Returns
An int.

◆ DetachChild()

template<typename Scalar >
int NeuralEngine::MachineLearning::GPNode< Scalar >::DetachChild ( std::shared_ptr< GPNode< Scalar > > const &  child)

Detaches a child.


Detach a child from this node. If the 'child' is non-null and in the array, the return value is the index in the array that had stored the child. Otherwise, the function returns -1.

, 19.07.2018.

Parameters
childThe child.
Returns
An int.

◆ DetachChildAt()

template<typename Scalar >
std::shared_ptr< GPNode< Scalar > > NeuralEngine::MachineLearning::GPNode< Scalar >::DetachChildAt ( int  i)

Detaches a child at index.

Detach a child from this node. If 0 <= i < GetNumChildren(), the return value is the child at index i; otherwise, the function returns null.

, 19.07.2018.

Parameters
iZero-based index of the child.
Returns
A std::shared_ptr<Spatial>

◆ DetachAllChildren()

template<typename Scalar >
void NeuralEngine::MachineLearning::GPNode< Scalar >::DetachAllChildren ( )

Detach all children from this node.

, 19.07.2018.

◆ SetChild()

template<typename Scalar >
std::shared_ptr< GPNode< Scalar > > NeuralEngine::MachineLearning::GPNode< Scalar >::SetChild ( int  i,
std::shared_ptr< GPNode< Scalar > > const &  child 
)

Sets a child.


The same comments for AttachChild apply here regarding the inability to have multiple parents. If 0 <= i < GetNumChildren(), the function succeeds and returns i. If i is out of range, the function still succeeds, appending the child to the end of the array. The return value is the previous child stored at index i.

, 19.07.2018.

Parameters
iZero-based index of the.
childThe child.
Returns
A std::shared_ptr<Spatial>

◆ GetChild()

template<typename Scalar >
std::shared_ptr< GPNode< Scalar > > NeuralEngine::MachineLearning::GPNode< Scalar >::GetChild ( int  i)

Gets a child at index.


Get the child at the specified index. If 0 <= i < GetNumChildren(), the function succeeds and returns the child at that index. Keep in mind that child[i] could very well be null. If i is out of range, the function returns null.

, 19.07.2018.

Parameters
iZero-based index of the.
Returns
The child.

◆ GetParent()

template<typename Scalar >
GPNode< Scalar > * NeuralEngine::MachineLearning::GPNode< Scalar >::GetParent ( )

Access to the parent object, which is null for the root of the hierarchy.

Hmetal T, 10.08.2016.

Returns
null if it fails, else the parent.

◆ SetParent()

template<typename Scalar >
void NeuralEngine::MachineLearning::GPNode< Scalar >::SetParent ( GPNode< Scalar > *  parent)


Access to the parent object. Node calls this during attach/detach of children.

Hmetal T, 04/04/2020.

Parameters
parent[in,out] If non-null, the parent.

◆ serialize()

template<typename Scalar >
template<class Archive >
void NeuralEngine::MachineLearning::GPNode< Scalar >::serialize ( Archive &  ar,
unsigned int  version 
)
inlineprivate

Definition at line 233 of file FgGPNode.h.

Friends And Related Function Documentation

◆ boost::serialization::access

template<typename Scalar >
friend class boost::serialization::access
friend

Definition at line 228 of file FgGPNode.h.

◆ GPModels::AEP::SDGPLVM< Scalar >

template<typename Scalar >
friend class GPModels::AEP::SDGPLVM< Scalar >
friend

Definition at line 228 of file FgGPNode.h.

◆ GPModels::AEP::SGPLVM< Scalar >

template<typename Scalar >
friend class GPModels::AEP::SGPLVM< Scalar >
friend

Definition at line 228 of file FgGPNode.h.

Member Data Documentation

◆ mChild

template<typename Scalar >
std::vector<std::shared_ptr<GPNode<Scalar> > > NeuralEngine::MachineLearning::GPNode< Scalar >::mChild
protected

Definition at line 225 of file FgGPNode.h.

◆ mParent

template<typename Scalar >
GPNode<Scalar>* NeuralEngine::MachineLearning::GPNode< Scalar >::mParent
protected

Definition at line 226 of file FgGPNode.h.


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