Empirical
Public Types | Public Member Functions | Public Attributes | List of all members
emp::EventDrivenGP_AW< AFFINITY_WIDTH >::Program Struct Reference

#include <EventDrivenGP.h>

Public Types

using program_t = emp::vector< Function >
 

Public Member Functions

 Program (Ptr< const inst_lib_t > _ilib, const program_t &_prgm=program_t())
 
 Program (const Program &)=default
 
void Clear ()
 
Functionoperator[] (size_t id)
 
const Functionoperator[] (size_t id) const
 
bool operator== (const Program &in) const
 
bool operator!= (const Program &in) const
 
bool operator< (const Program &other) const
 
size_t GetSize () const
 Get number of functions that make up this program. More...
 
size_t GetInstCnt () const
 Get the total number of instructions across all functions that make up this program. More...
 
Ptr< const inst_lib_tGetInstLib () const
 
bool ValidPosition (size_t fID, size_t pos) const
 
bool ValidFunction (size_t fID) const
 
void SetProgram (const program_t &_program)
 
void PushFunction (const Function &_function)
 
void PushFunction (const affinity_t &_aff=affinity_t(), const inst_seq_t &_seq=inst_seq_t())
 
void PushInst (size_t id, arg_t a0=0, arg_t a1=0, arg_t a2=0, const affinity_t &aff=affinity_t(), int fID=-1)
 
void PushInst (const std::string &name, arg_t a0=0, arg_t a1=0, arg_t a2=0, const affinity_t &aff=affinity_t(), int fID=-1)
 
void PushInst (const inst_t &inst, int fID=-1)
 
void SetInst (size_t fID, size_t pos, size_t id, arg_t a0=0, arg_t a1=0, arg_t a2=0, const affinity_t &aff=affinity_t())
 
void SetInst (size_t fID, size_t pos, const inst_t &inst)
 
void Load (std::istream &input)
 
void PrintInst (const inst_t &inst, std::ostream &os=std::cout)
 Print out a single instruction with its arguments. More...
 
void PrintInstFull (const inst_t &inst, std::ostream &os=std::cout)
 Fully print out a single instruction with its arguments/affinity. More...
 
void PrintProgram (std::ostream &os=std::cout)
 Print out entire program. More...
 
void PrintProgramFull (std::ostream &os=std::cout)
 Print out entire program. More...
 

Public Attributes

Ptr< const inst_lib_tinst_lib
 
program_t program
 

Detailed Description

template<size_t AFFINITY_WIDTH>
struct emp::EventDrivenGP_AW< AFFINITY_WIDTH >::Program

Program struct. Defines an EventDrivenGP program. A programs consists of a set of functions where each function is a named sequence of instructions. Function names are bit strings (stored as a BitSet). Programs require an associated instruction library to give meaning to the instructions that make up their functions.

Member Typedef Documentation

template<size_t AFFINITY_WIDTH>
using emp::EventDrivenGP_AW< AFFINITY_WIDTH >::Program::program_t = emp::vector<Function>

Constructor & Destructor Documentation

template<size_t AFFINITY_WIDTH>
emp::EventDrivenGP_AW< AFFINITY_WIDTH >::Program::Program ( Ptr< const inst_lib_t _ilib,
const program_t _prgm = program_t() 
)
inline
template<size_t AFFINITY_WIDTH>
emp::EventDrivenGP_AW< AFFINITY_WIDTH >::Program::Program ( const Program )
default

Member Function Documentation

template<size_t AFFINITY_WIDTH>
void emp::EventDrivenGP_AW< AFFINITY_WIDTH >::Program::Clear ( )
inline
template<size_t AFFINITY_WIDTH>
size_t emp::EventDrivenGP_AW< AFFINITY_WIDTH >::Program::GetInstCnt ( ) const
inline

Get the total number of instructions across all functions that make up this program.

template<size_t AFFINITY_WIDTH>
Ptr<const inst_lib_t> emp::EventDrivenGP_AW< AFFINITY_WIDTH >::Program::GetInstLib ( ) const
inline
template<size_t AFFINITY_WIDTH>
size_t emp::EventDrivenGP_AW< AFFINITY_WIDTH >::Program::GetSize ( ) const
inline

Get number of functions that make up this program.

template<size_t AFFINITY_WIDTH>
void emp::EventDrivenGP_AW< AFFINITY_WIDTH >::Program::Load ( std::istream &  input)
inline

Load entire program from input stream. Warning: This function accepts a slightly different than what the Program's PrintProgram function prints out (for now, will add a PrintProgram variant that prints in this load function's accepted format). Program format: Fn-AFFINITY: INST_NAMEAFFINITY ... Fn-AFFINITY: ...

template<size_t AFFINITY_WIDTH>
bool emp::EventDrivenGP_AW< AFFINITY_WIDTH >::Program::operator!= ( const Program in) const
inline
template<size_t AFFINITY_WIDTH>
bool emp::EventDrivenGP_AW< AFFINITY_WIDTH >::Program::operator< ( const Program other) const
inline
template<size_t AFFINITY_WIDTH>
bool emp::EventDrivenGP_AW< AFFINITY_WIDTH >::Program::operator== ( const Program in) const
inline
template<size_t AFFINITY_WIDTH>
Function& emp::EventDrivenGP_AW< AFFINITY_WIDTH >::Program::operator[] ( size_t  id)
inline
template<size_t AFFINITY_WIDTH>
const Function& emp::EventDrivenGP_AW< AFFINITY_WIDTH >::Program::operator[] ( size_t  id) const
inline
template<size_t AFFINITY_WIDTH>
void emp::EventDrivenGP_AW< AFFINITY_WIDTH >::Program::PrintInst ( const inst_t inst,
std::ostream &  os = std::cout 
)
inline

Print out a single instruction with its arguments.

template<size_t AFFINITY_WIDTH>
void emp::EventDrivenGP_AW< AFFINITY_WIDTH >::Program::PrintInstFull ( const inst_t inst,
std::ostream &  os = std::cout 
)
inline

Fully print out a single instruction with its arguments/affinity.

template<size_t AFFINITY_WIDTH>
void emp::EventDrivenGP_AW< AFFINITY_WIDTH >::Program::PrintProgram ( std::ostream &  os = std::cout)
inline

Print out entire program.

template<size_t AFFINITY_WIDTH>
void emp::EventDrivenGP_AW< AFFINITY_WIDTH >::Program::PrintProgramFull ( std::ostream &  os = std::cout)
inline

Print out entire program.

template<size_t AFFINITY_WIDTH>
void emp::EventDrivenGP_AW< AFFINITY_WIDTH >::Program::PushFunction ( const Function _function)
inline
template<size_t AFFINITY_WIDTH>
void emp::EventDrivenGP_AW< AFFINITY_WIDTH >::Program::PushFunction ( const affinity_t _aff = affinity_t(),
const inst_seq_t _seq = inst_seq_t() 
)
inline
template<size_t AFFINITY_WIDTH>
void emp::EventDrivenGP_AW< AFFINITY_WIDTH >::Program::PushInst ( size_t  id,
arg_t  a0 = 0,
arg_t  a1 = 0,
arg_t  a2 = 0,
const affinity_t aff = affinity_t(),
int  fID = -1 
)
inline

Push new instruction to program. If no function pointer is provided and no functions exist yet, add new function to program and push to that. If no function pointer is provided and functions exist, push to last function in program. If function pointer is provided, push to that function.

template<size_t AFFINITY_WIDTH>
void emp::EventDrivenGP_AW< AFFINITY_WIDTH >::Program::PushInst ( const std::string &  name,
arg_t  a0 = 0,
arg_t  a1 = 0,
arg_t  a2 = 0,
const affinity_t aff = affinity_t(),
int  fID = -1 
)
inline

Push new instruction to program. If no function pointer is provided and no functions exist yet, add new function to program and push to that. If no function pointer is provided and functions exist, push to last function in program. If function pointer is provided, push to that function.

template<size_t AFFINITY_WIDTH>
void emp::EventDrivenGP_AW< AFFINITY_WIDTH >::Program::PushInst ( const inst_t inst,
int  fID = -1 
)
inline

Push new instruction to program. If no function pointer is provided and no functions exist yet, add new function to program and push to that. If no function pointer is provided and functions exist, push to last function in program. If function pointer is provided, push to that function.

template<size_t AFFINITY_WIDTH>
void emp::EventDrivenGP_AW< AFFINITY_WIDTH >::Program::SetInst ( size_t  fID,
size_t  pos,
size_t  id,
arg_t  a0 = 0,
arg_t  a1 = 0,
arg_t  a2 = 0,
const affinity_t aff = affinity_t() 
)
inline
template<size_t AFFINITY_WIDTH>
void emp::EventDrivenGP_AW< AFFINITY_WIDTH >::Program::SetInst ( size_t  fID,
size_t  pos,
const inst_t inst 
)
inline
template<size_t AFFINITY_WIDTH>
void emp::EventDrivenGP_AW< AFFINITY_WIDTH >::Program::SetProgram ( const program_t _program)
inline
template<size_t AFFINITY_WIDTH>
bool emp::EventDrivenGP_AW< AFFINITY_WIDTH >::Program::ValidFunction ( size_t  fID) const
inline
template<size_t AFFINITY_WIDTH>
bool emp::EventDrivenGP_AW< AFFINITY_WIDTH >::Program::ValidPosition ( size_t  fID,
size_t  pos 
) const
inline

Member Data Documentation

template<size_t AFFINITY_WIDTH>
Ptr<const inst_lib_t> emp::EventDrivenGP_AW< AFFINITY_WIDTH >::Program::inst_lib
template<size_t AFFINITY_WIDTH>
program_t emp::EventDrivenGP_AW< AFFINITY_WIDTH >::Program::program

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