Empirical
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
emp::Processor< HARDWARE > Class Template Reference

#include <Processor.h>

Public Types

using this_t = Processor< HARDWARE >
 

Public Member Functions

bool UpdateScope (size_t new_scope, ScopeType type=ScopeType::BASIC)
 
void BypassScope (size_t scope)
 
 Processor (const genome_t &in_genome)
 Create a new AvidaGP seeding it with a genome. More...
 
 Processor ()
 Create a default AvidaGP (no genome sequence, default instruction set) More...
 
 Processor (Ptr< const inst_lib_t > inst_lib)
 Create an AvidaGP with a specified instruction set (but no genome sequence) More...
 
 Processor (const inst_lib_t &inst_lib)
 
 Processor (const Processor< HARDWARE > &)=default
 Copy constructor. More...
 
 Processor (Processor< HARDWARE > &&)=default
 Move constructor. More...
 
virtual ~Processor ()
 Destructor. More...
 
bool operator< (const this_t &other) const
 
void Reset ()
 Reset the entire CPU to a starting state, without a genome. More...
 
virtual void ResetHardware ()
 Reset just the CPU hardware, but keep the genome and traits. More...
 
void ResetIP ()
 Reset the instruction pointer to the beginning of the genome AND reset scope. More...
 
Ptr< const inst_lib_t > GetInstLib () const
 
inst_t GetInst (size_t pos) const
 
const genome_t & GetGenome () const
 
const size_t GetSize () const
 
double GetReg (size_t id) const
 
double GetInput (int id) const
 
const std::unordered_map< int, double > & GetInputs () const
 
size_t GetNumInputs () const
 
double GetOutput (int id) const
 
const std::unordered_map< int, double > & GetOutputs () const
 
size_t GetNumOutputs () const
 
const stack_t & GetStack (size_t id) const
 
int GetFunStart (size_t id) const
 
size_t GetIP () const
 
emp::vector< ScopeInfo > GetScopeStack () const
 
size_t CurScope () const
 
ScopeType CurScopeType () const
 
ScopeType GetScopeType (size_t id)
 
emp::vector< RegBackup > GetRegStack () const
 
emp::vector< size_t > GetCallStack () const
 
size_t GetNumErrors () const
 
double GetTrait (size_t id) const
 
const emp::vector< double > & GetTraits ()
 
size_t GetNumTraits () const
 
void SetInst (size_t pos, const inst_t &inst)
 
void SetInst (size_t pos, size_t id, size_t a0=0, size_t a1=0, size_t a2=0)
 
void SetGenome (const genome_t &g)
 
void SetReg (size_t id, double val)
 
void SetInput (int input_id, double value)
 
void SetInputs (const std::unordered_map< int, double > &vals)
 
void SetInputs (std::unordered_map< int, double > &&vals)
 
void SetOutput (int output_id, double value)
 
void SetOutputs (const std::unordered_map< int, double > &vals)
 
void SetOutputs (std::unordered_map< int, double > &&vals)
 
double PopStack (size_t id)
 
void PushStack (size_t id, double value)
 
void SetFunStart (size_t id, int value)
 
void SetIP (size_t pos)
 
void PushRegInfo (size_t scope_id, size_t reg_id)
 
void PushCallInfo (size_t pos)
 
void IncErrors ()
 
void SetTrait (size_t id, double val)
 
void PushTrait (double val)
 
inst_t GetRandomInst (Random &rand)
 
void RandomizeInst (size_t pos, Random &rand)
 
void PushInst (size_t id, size_t a0=0, size_t a1=0, size_t a2=0)
 
void PushInst (const std::string &name, size_t a0=0, size_t a1=0, size_t a2=0)
 
void PushInst (const Instruction &inst)
 
void PushInst (Instruction &&inst)
 
void PushRandom (Random &rand, const size_t count=1)
 
bool Load (std::istream &input)
 
void ProcessInst (const inst_t &inst)
 Process a specified instruction, provided by the caller. More...
 
size_t InstScope (const inst_t &inst) const
 Determine the scope associated with a particular instruction. More...
 
void SingleProcess ()
 Process the NEXT instruction pointed to be the instruction pointer. More...
 
void Process (size_t num_inst)
 Process the next SERIES of instructions, directed by the instruction pointer. More...
 
void PrintInst (const inst_t &inst, std::ostream &os=std::cout) const
 Print out a single instruction, with its arguments. More...
 
void PrintGenome (std::ostream &os=std::cout) const
 Print out this program. More...
 
void PrintGenome (const std::string &filename) const
 
size_t PredictNextInst () const
 Figure out which instruction is going to actually be run next SingleProcess() More...
 
void PrintState (std::ostream &os=std::cout) const
 Print out the state of the virtual CPU. More...
 
void Trace (size_t num_inst, std::ostream &os=std::cout)
 Trace the instructions being exectured, with full CPU details. More...
 
void Trace (size_t num_inst, const std::string &filename)
 

Static Public Member Functions

static void Inst_Inc (this_t &hw, const inst_t &inst)
 Instructions. More...
 
static void Inst_Dec (this_t &hw, const inst_t &inst)
 
static void Inst_Not (this_t &hw, const inst_t &inst)
 
static void Inst_SetReg (this_t &hw, const inst_t &inst)
 
static void Inst_Add (this_t &hw, const inst_t &inst)
 
static void Inst_Sub (this_t &hw, const inst_t &inst)
 
static void Inst_Mult (this_t &hw, const inst_t &inst)
 
static void Inst_Div (this_t &hw, const inst_t &inst)
 
static void Inst_Mod (this_t &hw, const inst_t &inst)
 
static void Inst_TestEqu (this_t &hw, const inst_t &inst)
 
static void Inst_TestNEqu (this_t &hw, const inst_t &inst)
 
static void Inst_TestLess (this_t &hw, const inst_t &inst)
 
static void Inst_If (this_t &hw, const inst_t &inst)
 
static void Inst_While (this_t &hw, const inst_t &inst)
 
static void Inst_Countdown (this_t &hw, const inst_t &inst)
 
static void Inst_Break (this_t &hw, const inst_t &inst)
 
static void Inst_Scope (this_t &hw, const inst_t &inst)
 
static void Inst_Define (this_t &hw, const inst_t &inst)
 
static void Inst_Call (this_t &hw, const inst_t &inst)
 
static void Inst_Push (this_t &hw, const inst_t &inst)
 
static void Inst_Pop (this_t &hw, const inst_t &inst)
 
static void Inst_Input (this_t &hw, const inst_t &inst)
 
static void Inst_Output (this_t &hw, const inst_t &inst)
 
static void Inst_CopyVal (this_t &hw, const inst_t &inst)
 
static void Inst_ScopeReg (this_t &hw, const inst_t &inst)
 
static const inst_lib_t & DefaultInstLib ()
 This static function can be used to access the generic AvidaGP instruction library. More...
 

Public Attributes

HARDWARE hw
 

Member Typedef Documentation

template<typename HARDWARE >
using emp::Processor< HARDWARE >::this_t = Processor<HARDWARE>

Constructor & Destructor Documentation

template<typename HARDWARE >
emp::Processor< HARDWARE >::Processor ( const genome_t &  in_genome)
inline

Create a new AvidaGP seeding it with a genome.

template<typename HARDWARE >
emp::Processor< HARDWARE >::Processor ( )
inline

Create a default AvidaGP (no genome sequence, default instruction set)

template<typename HARDWARE >
emp::Processor< HARDWARE >::Processor ( Ptr< const inst_lib_t >  inst_lib)
inline

Create an AvidaGP with a specified instruction set (but no genome sequence)

template<typename HARDWARE >
emp::Processor< HARDWARE >::Processor ( const inst_lib_t &  inst_lib)
inline
template<typename HARDWARE >
emp::Processor< HARDWARE >::Processor ( const Processor< HARDWARE > &  )
default

Copy constructor.

template<typename HARDWARE >
emp::Processor< HARDWARE >::Processor ( Processor< HARDWARE > &&  )
default

Move constructor.

template<typename HARDWARE >
virtual emp::Processor< HARDWARE >::~Processor ( )
inlinevirtual

Destructor.

Member Function Documentation

template<typename HARDWARE >
void emp::Processor< HARDWARE >::BypassScope ( size_t  scope)
inline
template<typename HARDWARE >
size_t emp::Processor< HARDWARE >::CurScope ( ) const
inline
template<typename HARDWARE >
ScopeType emp::Processor< HARDWARE >::CurScopeType ( ) const
inline
template<typename HARDWARE >
const InstLib< Processor< HARDWARE > > & emp::Processor< HARDWARE >::DefaultInstLib ( )
static

This static function can be used to access the generic AvidaGP instruction library.

template<typename HARDWARE >
emp::vector<size_t> emp::Processor< HARDWARE >::GetCallStack ( ) const
inline
template<typename HARDWARE >
int emp::Processor< HARDWARE >::GetFunStart ( size_t  id) const
inline
template<typename HARDWARE >
const genome_t& emp::Processor< HARDWARE >::GetGenome ( ) const
inline
template<typename HARDWARE >
double emp::Processor< HARDWARE >::GetInput ( int  id) const
inline
template<typename HARDWARE >
const std::unordered_map<int,double>& emp::Processor< HARDWARE >::GetInputs ( ) const
inline
template<typename HARDWARE >
inst_t emp::Processor< HARDWARE >::GetInst ( size_t  pos) const
inline
template<typename HARDWARE >
Ptr<const inst_lib_t> emp::Processor< HARDWARE >::GetInstLib ( ) const
inline
template<typename HARDWARE >
size_t emp::Processor< HARDWARE >::GetIP ( ) const
inline
template<typename HARDWARE >
size_t emp::Processor< HARDWARE >::GetNumErrors ( ) const
inline
template<typename HARDWARE >
size_t emp::Processor< HARDWARE >::GetNumInputs ( ) const
inline
template<typename HARDWARE >
size_t emp::Processor< HARDWARE >::GetNumOutputs ( ) const
inline
template<typename HARDWARE >
size_t emp::Processor< HARDWARE >::GetNumTraits ( ) const
inline
template<typename HARDWARE >
double emp::Processor< HARDWARE >::GetOutput ( int  id) const
inline
template<typename HARDWARE >
const std::unordered_map<int,double>& emp::Processor< HARDWARE >::GetOutputs ( ) const
inline
template<typename HARDWARE >
inst_t emp::Processor< HARDWARE >::GetRandomInst ( Random rand)
inline
template<typename HARDWARE >
double emp::Processor< HARDWARE >::GetReg ( size_t  id) const
inline
template<typename HARDWARE >
emp::vector<RegBackup> emp::Processor< HARDWARE >::GetRegStack ( ) const
inline
template<typename HARDWARE >
emp::vector<ScopeInfo> emp::Processor< HARDWARE >::GetScopeStack ( ) const
inline
template<typename HARDWARE >
ScopeType emp::Processor< HARDWARE >::GetScopeType ( size_t  id)
inline
template<typename HARDWARE >
const size_t emp::Processor< HARDWARE >::GetSize ( ) const
inline
template<typename HARDWARE >
const stack_t& emp::Processor< HARDWARE >::GetStack ( size_t  id) const
inline
template<typename HARDWARE >
double emp::Processor< HARDWARE >::GetTrait ( size_t  id) const
inline
template<typename HARDWARE >
const emp::vector<double>& emp::Processor< HARDWARE >::GetTraits ( )
inline
template<typename HARDWARE >
void emp::Processor< HARDWARE >::IncErrors ( )
inline
template<typename HARDWARE >
static void emp::Processor< HARDWARE >::Inst_Add ( this_t hw,
const inst_t &  inst 
)
inlinestatic
template<typename HARDWARE >
static void emp::Processor< HARDWARE >::Inst_Break ( this_t hw,
const inst_t &  inst 
)
inlinestatic
template<typename HARDWARE >
static void emp::Processor< HARDWARE >::Inst_Call ( this_t hw,
const inst_t &  inst 
)
inlinestatic
template<typename HARDWARE >
static void emp::Processor< HARDWARE >::Inst_CopyVal ( this_t hw,
const inst_t &  inst 
)
inlinestatic
template<typename HARDWARE >
static void emp::Processor< HARDWARE >::Inst_Countdown ( this_t hw,
const inst_t &  inst 
)
inlinestatic
template<typename HARDWARE >
static void emp::Processor< HARDWARE >::Inst_Dec ( this_t hw,
const inst_t &  inst 
)
inlinestatic
template<typename HARDWARE >
static void emp::Processor< HARDWARE >::Inst_Define ( this_t hw,
const inst_t &  inst 
)
inlinestatic
template<typename HARDWARE >
static void emp::Processor< HARDWARE >::Inst_Div ( this_t hw,
const inst_t &  inst 
)
inlinestatic
template<typename HARDWARE >
static void emp::Processor< HARDWARE >::Inst_If ( this_t hw,
const inst_t &  inst 
)
inlinestatic
template<typename HARDWARE >
static void emp::Processor< HARDWARE >::Inst_Inc ( this_t hw,
const inst_t &  inst 
)
inlinestatic

Instructions.

template<typename HARDWARE >
static void emp::Processor< HARDWARE >::Inst_Input ( this_t hw,
const inst_t &  inst 
)
inlinestatic
template<typename HARDWARE >
static void emp::Processor< HARDWARE >::Inst_Mod ( this_t hw,
const inst_t &  inst 
)
inlinestatic
template<typename HARDWARE >
static void emp::Processor< HARDWARE >::Inst_Mult ( this_t hw,
const inst_t &  inst 
)
inlinestatic
template<typename HARDWARE >
static void emp::Processor< HARDWARE >::Inst_Not ( this_t hw,
const inst_t &  inst 
)
inlinestatic
template<typename HARDWARE >
static void emp::Processor< HARDWARE >::Inst_Output ( this_t hw,
const inst_t &  inst 
)
inlinestatic
template<typename HARDWARE >
static void emp::Processor< HARDWARE >::Inst_Pop ( this_t hw,
const inst_t &  inst 
)
inlinestatic
template<typename HARDWARE >
static void emp::Processor< HARDWARE >::Inst_Push ( this_t hw,
const inst_t &  inst 
)
inlinestatic
template<typename HARDWARE >
static void emp::Processor< HARDWARE >::Inst_Scope ( this_t hw,
const inst_t &  inst 
)
inlinestatic
template<typename HARDWARE >
static void emp::Processor< HARDWARE >::Inst_ScopeReg ( this_t hw,
const inst_t &  inst 
)
inlinestatic
template<typename HARDWARE >
static void emp::Processor< HARDWARE >::Inst_SetReg ( this_t hw,
const inst_t &  inst 
)
inlinestatic
template<typename HARDWARE >
static void emp::Processor< HARDWARE >::Inst_Sub ( this_t hw,
const inst_t &  inst 
)
inlinestatic
template<typename HARDWARE >
static void emp::Processor< HARDWARE >::Inst_TestEqu ( this_t hw,
const inst_t &  inst 
)
inlinestatic
template<typename HARDWARE >
static void emp::Processor< HARDWARE >::Inst_TestLess ( this_t hw,
const inst_t &  inst 
)
inlinestatic
template<typename HARDWARE >
static void emp::Processor< HARDWARE >::Inst_TestNEqu ( this_t hw,
const inst_t &  inst 
)
inlinestatic
template<typename HARDWARE >
static void emp::Processor< HARDWARE >::Inst_While ( this_t hw,
const inst_t &  inst 
)
inlinestatic
template<typename HARDWARE >
size_t emp::Processor< HARDWARE >::InstScope ( const inst_t &  inst) const

Determine the scope associated with a particular instruction.

template<typename HARDWARE >
bool emp::Processor< HARDWARE >::Load ( std::istream &  input)
template<typename HARDWARE >
bool emp::Processor< HARDWARE >::operator< ( const this_t other) const
inline
template<typename HARDWARE >
double emp::Processor< HARDWARE >::PopStack ( size_t  id)
inline
template<typename HARDWARE >
size_t emp::Processor< HARDWARE >::PredictNextInst ( ) const

Figure out which instruction is going to actually be run next SingleProcess()

template<typename HARDWARE >
void emp::Processor< HARDWARE >::PrintGenome ( std::ostream &  os = std::cout) const

Print out this program.

template<typename HARDWARE >
void emp::Processor< HARDWARE >::PrintGenome ( const std::string &  filename) const
template<typename HARDWARE >
void emp::Processor< HARDWARE >::PrintInst ( const inst_t &  inst,
std::ostream &  os = std::cout 
) const

Print out a single instruction, with its arguments.

template<typename HARDWARE >
void emp::Processor< HARDWARE >::PrintState ( std::ostream &  os = std::cout) const

Print out the state of the virtual CPU.

template<typename HARDWARE >
void emp::Processor< HARDWARE >::Process ( size_t  num_inst)
inline

Process the next SERIES of instructions, directed by the instruction pointer.

template<typename HARDWARE >
void emp::Processor< HARDWARE >::ProcessInst ( const inst_t &  inst)
inline

Process a specified instruction, provided by the caller.

template<typename HARDWARE >
void emp::Processor< HARDWARE >::PushCallInfo ( size_t  pos)
inline
template<typename HARDWARE >
void emp::Processor< HARDWARE >::PushInst ( size_t  id,
size_t  a0 = 0,
size_t  a1 = 0,
size_t  a2 = 0 
)
inline
template<typename HARDWARE >
void emp::Processor< HARDWARE >::PushInst ( const std::string &  name,
size_t  a0 = 0,
size_t  a1 = 0,
size_t  a2 = 0 
)
inline
template<typename HARDWARE >
void emp::Processor< HARDWARE >::PushInst ( const Instruction inst)
inline
template<typename HARDWARE >
void emp::Processor< HARDWARE >::PushInst ( Instruction &&  inst)
inline
template<typename HARDWARE >
void emp::Processor< HARDWARE >::PushRandom ( Random rand,
const size_t  count = 1 
)
inline
template<typename HARDWARE >
void emp::Processor< HARDWARE >::PushRegInfo ( size_t  scope_id,
size_t  reg_id 
)
inline
template<typename HARDWARE >
void emp::Processor< HARDWARE >::PushStack ( size_t  id,
double  value 
)
inline
template<typename HARDWARE >
void emp::Processor< HARDWARE >::PushTrait ( double  val)
inline
template<typename HARDWARE >
void emp::Processor< HARDWARE >::RandomizeInst ( size_t  pos,
Random rand 
)
inline
template<typename HARDWARE >
void emp::Processor< HARDWARE >::Reset ( )
inline

Reset the entire CPU to a starting state, without a genome.

template<typename HARDWARE >
virtual void emp::Processor< HARDWARE >::ResetHardware ( )
inlinevirtual

Reset just the CPU hardware, but keep the genome and traits.

template<typename HARDWARE >
void emp::Processor< HARDWARE >::ResetIP ( )
inline

Reset the instruction pointer to the beginning of the genome AND reset scope.

template<typename HARDWARE >
void emp::Processor< HARDWARE >::SetFunStart ( size_t  id,
int  value 
)
inline
template<typename HARDWARE >
void emp::Processor< HARDWARE >::SetGenome ( const genome_t &  g)
inline
template<typename HARDWARE >
void emp::Processor< HARDWARE >::SetInput ( int  input_id,
double  value 
)
inline
template<typename HARDWARE >
void emp::Processor< HARDWARE >::SetInputs ( const std::unordered_map< int, double > &  vals)
inline
template<typename HARDWARE >
void emp::Processor< HARDWARE >::SetInputs ( std::unordered_map< int, double > &&  vals)
inline
template<typename HARDWARE >
void emp::Processor< HARDWARE >::SetInst ( size_t  pos,
const inst_t &  inst 
)
inline
template<typename HARDWARE >
void emp::Processor< HARDWARE >::SetInst ( size_t  pos,
size_t  id,
size_t  a0 = 0,
size_t  a1 = 0,
size_t  a2 = 0 
)
inline
template<typename HARDWARE >
void emp::Processor< HARDWARE >::SetIP ( size_t  pos)
inline
template<typename HARDWARE >
void emp::Processor< HARDWARE >::SetOutput ( int  output_id,
double  value 
)
inline
template<typename HARDWARE >
void emp::Processor< HARDWARE >::SetOutputs ( const std::unordered_map< int, double > &  vals)
inline
template<typename HARDWARE >
void emp::Processor< HARDWARE >::SetOutputs ( std::unordered_map< int, double > &&  vals)
inline
template<typename HARDWARE >
void emp::Processor< HARDWARE >::SetReg ( size_t  id,
double  val 
)
inline
template<typename HARDWARE >
void emp::Processor< HARDWARE >::SetTrait ( size_t  id,
double  val 
)
inline
template<typename HARDWARE >
void emp::Processor< HARDWARE >::SingleProcess ( )
inline

Process the NEXT instruction pointed to be the instruction pointer.

template<typename HARDWARE >
void emp::Processor< HARDWARE >::Trace ( size_t  num_inst,
std::ostream &  os = std::cout 
)
inline

Trace the instructions being exectured, with full CPU details.

template<typename HARDWARE >
void emp::Processor< HARDWARE >::Trace ( size_t  num_inst,
const std::string &  filename 
)
inline
template<typename HARDWARE >
bool emp::Processor< HARDWARE >::UpdateScope ( size_t  new_scope,
ScopeType  type = ScopeType::BASIC 
)
inline

Member Data Documentation

template<typename HARDWARE >
HARDWARE emp::Processor< HARDWARE >::hw

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