Empirical
|
#include <AvidaGP.h>
Classes | |
struct | Genome |
struct | Instruction |
struct | RegBackup |
struct | ScopeInfo |
Public Types | |
using | this_t = AvidaCPU_Base< HARDWARE > |
using | hardware_t = HARDWARE |
using | inst_t = Instruction |
using | genome_t = Genome |
using | arg_t = size_t |
using | inst_lib_t = AvidaCPU_InstLib< hardware_t, arg_t, INST_ARGS > |
using | stack_t = emp::vector< double > |
using | arg_set_t = emp::array< arg_t, INST_ARGS > |
Public Member Functions | |
void | ExitScope () |
bool | UpdateScope (size_t new_scope, ScopeType type=ScopeType::BASIC) |
void | BypassScope (size_t scope) |
AvidaCPU_Base (const genome_t &in_genome) | |
Create a new AvidaCPU seeding it with a genome. More... | |
AvidaCPU_Base () | |
Create a default AvidaCPU (no genome sequence, default instruction set) More... | |
AvidaCPU_Base (Ptr< const inst_lib_t > inst_lib) | |
Create an AvidaCPU with a specified instruction set (but no genome sequence) More... | |
AvidaCPU_Base (const inst_lib_t &inst_lib) | |
AvidaCPU_Base (const AvidaCPU_Base &)=default | |
Copy constructor. More... | |
AvidaCPU_Base (AvidaCPU_Base &&)=default | |
Move constructor. More... | |
virtual | ~AvidaCPU_Base () |
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 | PushInstString (std::string info) |
void | PushRandom (Random &rand, const size_t count=1) |
bool | Load (std::istream &input) |
bool | Load (const std::string &filename) |
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) |
Public Attributes | |
genome_t | genome |
emp::array< double, CPU_SIZE > | regs |
std::unordered_map< int, double > | inputs |
std::unordered_map< int, double > | outputs |
emp::array< stack_t, CPU_SIZE > | stacks |
emp::array< int, CPU_SIZE > | fun_starts |
size_t | inst_ptr |
emp::vector< ScopeInfo > | scope_stack |
emp::vector< RegBackup > | reg_stack |
emp::vector< size_t > | call_stack |
size_t | errors |
emp::vector< double > | traits |
Static Public Attributes | |
static constexpr size_t | CPU_SIZE = 16 |
static constexpr size_t | INST_ARGS = 3 |
static constexpr size_t | STACK_CAP = 16 |
using emp::AvidaCPU_Base< HARDWARE >::arg_set_t = emp::array<arg_t, INST_ARGS> |
using emp::AvidaCPU_Base< HARDWARE >::arg_t = size_t |
using emp::AvidaCPU_Base< HARDWARE >::genome_t = Genome |
using emp::AvidaCPU_Base< HARDWARE >::hardware_t = HARDWARE |
using emp::AvidaCPU_Base< HARDWARE >::inst_lib_t = AvidaCPU_InstLib<hardware_t, arg_t, INST_ARGS> |
using emp::AvidaCPU_Base< HARDWARE >::inst_t = Instruction |
using emp::AvidaCPU_Base< HARDWARE >::stack_t = emp::vector<double> |
using emp::AvidaCPU_Base< HARDWARE >::this_t = AvidaCPU_Base<HARDWARE> |
|
inline |
Create a new AvidaCPU seeding it with a genome.
|
inline |
Create a default AvidaCPU (no genome sequence, default instruction set)
|
inline |
Create an AvidaCPU with a specified instruction set (but no genome sequence)
|
inline |
|
default |
Copy constructor.
|
default |
Move constructor.
|
inlinevirtual |
Destructor.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
size_t emp::AvidaCPU_Base< HARDWARE >::InstScope | ( | const inst_t & | inst | ) | const |
Determine the scope associated with a particular instruction.
bool emp::AvidaCPU_Base< HARDWARE >::Load | ( | std::istream & | input | ) |
|
inline |
|
inline |
|
inline |
size_t emp::AvidaCPU_Base< HARDWARE >::PredictNextInst | ( | ) | const |
Figure out which instruction is going to actually be run next SingleProcess()
void emp::AvidaCPU_Base< HARDWARE >::PrintGenome | ( | std::ostream & | os = std::cout | ) | const |
Print out this program.
void emp::AvidaCPU_Base< HARDWARE >::PrintGenome | ( | const std::string & | filename | ) | const |
void emp::AvidaCPU_Base< HARDWARE >::PrintInst | ( | const inst_t & | inst, |
std::ostream & | os = std::cout |
||
) | const |
Print out a single instruction, with its arguments.
void emp::AvidaCPU_Base< HARDWARE >::PrintState | ( | std::ostream & | os = std::cout | ) | const |
Print out the state of the virtual CPU.
|
inline |
Process the next SERIES of instructions, directed by the instruction pointer.
|
inline |
Process a specified instruction, provided by the caller.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Reset the entire CPU to a starting state, without a genome.
|
inlinevirtual |
Reset just the CPU hardware, but keep the genome and traits.
|
inline |
Reset the instruction pointer to the beginning of the genome AND reset scope.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Process the NEXT instruction pointed to be the instruction pointer.
|
inline |
Trace the instructions being exectured, with full CPU details.
|
inline |
|
inline |
emp::vector<size_t> emp::AvidaCPU_Base< HARDWARE >::call_stack |
|
static |
size_t emp::AvidaCPU_Base< HARDWARE >::errors |
emp::array< int, CPU_SIZE > emp::AvidaCPU_Base< HARDWARE >::fun_starts |
genome_t emp::AvidaCPU_Base< HARDWARE >::genome |
std::unordered_map<int, double> emp::AvidaCPU_Base< HARDWARE >::inputs |
|
static |
size_t emp::AvidaCPU_Base< HARDWARE >::inst_ptr |
std::unordered_map<int, double> emp::AvidaCPU_Base< HARDWARE >::outputs |
emp::vector<RegBackup> emp::AvidaCPU_Base< HARDWARE >::reg_stack |
emp::array<double, CPU_SIZE> emp::AvidaCPU_Base< HARDWARE >::regs |
emp::vector<ScopeInfo> emp::AvidaCPU_Base< HARDWARE >::scope_stack |
|
static |
emp::array< stack_t, CPU_SIZE > emp::AvidaCPU_Base< HARDWARE >::stacks |
emp::vector<double> emp::AvidaCPU_Base< HARDWARE >::traits |