SmartEngine  1.6.0
Public Member Functions | List of all members
SmartEngine::IGeneticAgentTrainer Class Referenceabstract

A genetic trainer that uses agents to automatically set the loss of each chromosome. Agents should be mapped to a chromosome after creation by calling MapAgentToChromosome() More...

#include <GeneticAgentTrainer.h>

Inheritance diagram for SmartEngine::IGeneticAgentTrainer:
SmartEngine::IGeneticTrainer SmartEngine::IAgentFactory SmartEngine::ILossTrainer SmartEngine::IObject SmartEngine::IObject SmartEngine::IResource SmartEngine::IObject SmartEngine::ISerializable SmartEngine::IObject

Public Member Functions

virtual void MapAgentToChromosome (IAgent *agent, int chromosomeIndex)=0
 Assigns an agent to a particular chromosome index. Agent rewards will automatically be given to this chromosome. More...
 
virtual float GetSumRawRewards (int chromosomeIndex, bool discounted=true) const =0
 Returns the sum of the raw agent rewards for a given chromosome. More...
 
virtual float GetCuriosityRewards (int chromosomeIndex, bool discounted=true) const =0
 Returns the sum of the curiosity rewards for a given chromosome. More...
 
virtual void ProcessAgentData (bool onlyCompletedEpisodes=true)=0
 Crunches and aggregates whatever data the agents have collected so far. This can be called at any time, but is not necessary to call. It should be called regularly if the trainer is taking up too much memory as this will clear all processed agent data from the store. More...
 
- Public Member Functions inherited from SmartEngine::IGeneticTrainer
virtual void Initialize (const GeneticTrainerInitializationInfo &info)=0
 Initializes the newtwork with a new population. Not necessary to call if deserializing from disk. More...
 
virtual void Step ()=0
 Steps the trainer, making the population learn through gene swapping and mutation. More...
 
virtual int GetPopulationCount () const =0
 Retrieves the total number of chromosomes (test subjects) in the population. More...
 
virtual void SortPopulation ()=0
 Sorts the population by loss in ascending order More...
 
virtual float GetMutationStandardDeviation () const =0
 Returns the current mutation standard deviation, taking into account adaptive behavior More...
 
virtual int GetChromosomeLastIndex (int index) const =0
 Debug method to help visualize how chromosomes are progressing through generations More...
 
virtual void SetChromosome (int index)=0
 Replaces the networks specified in the constructor with the specified chromosome index. Call this before evaluating a chromosome for its performance. More...
 
virtual void SetBestChromosome ()=0
 Sorts chromosomes by loss and then sets the networks specified in the constructor to the best chromosome. More...
 
virtual void CopyOutChromosome (int index, IGraph *graph)=0
 Copies out the specified chromosome to a graph. More...
 
virtual void CopyOutBestChromosome (IGraph *graph)=0
 Sorts chromosomes by loss and then copies out the best chromosome to the specified network list. More...
 
virtual void CopyOutTopAverage (float count, IGraph *graph, bool weightedAverage)=0
 Averages the top chromosome weights and copies the result to specified graph More...
 
virtual float GetLoss (int index)=0
 Returns the loss of the specified chromosome More...
 
virtual void SetLoss (int index, float loss)=0
 Sets the loss of the specified chromosome. This will replace the loss from the optionally specified Loss structure passed into the constructor. More...
 
virtual void SetTrainingInfo (const GeneticTrainingInfo &info)=0
 Sets the genetic parameters of the trainer. More...
 
virtual float GetLoss ()=0
 Returns the loss in the graph. More...
 
- Public Member Functions inherited from SmartEngine::ILossTrainer
virtual void SetTrainingMethod (const LossTrainingMethodInfo &info)=0
 Sets the training method and associated parameters More...
 
virtual uint32 GetGenerationCount () const =0
 Returns the number of generations we have been training for. More...
 
- Public Member Functions inherited from SmartEngine::IObject
virtual ObjectId GetId () const =0
 Returns the ID of this object. More...
 
virtual void AddRef () const =0
 Increments the internal reference count on this object. It is not common to use this method directly. More...
 
virtual void Release () const =0
 Decrements the internal reference count on this object. It is not common to use this method directly. More...
 
virtual int GetRefCount () const =0
 Returns the number of references to this object. More...
 
virtual void * QueryInterface (ObjectClassId id)=0
 Queries the object for an interface and returns a pointer to that interface if found. More...
 
void operator= (IObject const &x)=delete
 
- Public Member Functions inherited from SmartEngine::IResource
virtual const char * GetResourceName () const =0
 Returns the name of this resource passed to the constructor. More...
 
virtual SerializationResult GetLastLoadResult () const =0
 Returns the result of the last call to Load(). Useful for checking loaded data state after creation. More...
 
virtual SerializationResult Load (const char *appendName=nullptr)=0
 Load this object from disk. More...
 
virtual SerializationResult Save (const char *appendName=nullptr)=0
 Save this object to disk. More...
 
- Public Member Functions inherited from SmartEngine::ISerializable
virtual SerializationResult Serialize (IMemoryBuffer *buffer)=0
 Write the contents of this object to a buffer. More...
 
virtual SerializationResult Deserialize (IMemoryBuffer *buffer)=0
 Fill this object with contents from a buffer. More...
 
- Public Member Functions inherited from SmartEngine::IAgentFactory
virtual ObjectPtr< IAgentCreateAgent ()=0
 Creates an agent for a particular trainer. More...
 

Additional Inherited Members

- Public Attributes inherited from SmartEngine::IObject
 private
 
 __pad0__: IObject() {} IObject(IObject const&) = delete
 

Detailed Description

A genetic trainer that uses agents to automatically set the loss of each chromosome. Agents should be mapped to a chromosome after creation by calling MapAgentToChromosome()

Member Function Documentation

◆ GetCuriosityRewards()

virtual float SmartEngine::IGeneticAgentTrainer::GetCuriosityRewards ( int  chromosomeIndex,
bool  discounted = true 
) const
pure virtual

Returns the sum of the curiosity rewards for a given chromosome.

Parameters
chromosomeIndex
discountedTrue to apply gamma over time, false to use the raw sum over the episode.

◆ GetSumRawRewards()

virtual float SmartEngine::IGeneticAgentTrainer::GetSumRawRewards ( int  chromosomeIndex,
bool  discounted = true 
) const
pure virtual

Returns the sum of the raw agent rewards for a given chromosome.

Parameters
chromosomeIndex
discountedTrue to apply gamma over time, false to use the raw sum over the episode.
Returns

◆ MapAgentToChromosome()

virtual void SmartEngine::IGeneticAgentTrainer::MapAgentToChromosome ( IAgent agent,
int  chromosomeIndex 
)
pure virtual

Assigns an agent to a particular chromosome index. Agent rewards will automatically be given to this chromosome.

Remapping a mapped agent will route all new data to go to the new chromosome. Old data will not be erased.

Parameters
agent
chromosomeIndex

◆ ProcessAgentData()

virtual void SmartEngine::IGeneticAgentTrainer::ProcessAgentData ( bool  onlyCompletedEpisodes = true)
pure virtual

Crunches and aggregates whatever data the agents have collected so far. This can be called at any time, but is not necessary to call. It should be called regularly if the trainer is taking up too much memory as this will clear all processed agent data from the store.

Note that this will train the curiosity module, changing the rewards for future data processing.

Parameters
onlyCompletedEpisodesIf true, only the episodes that have been completed will be processed.