Other Tools¶
Alert¶
-
namespace
emp
¶ If we are in emscripten, make sure to include the header.
This file contains extra analysis tools to use with systematics managers that have non-null DATA_TYPES.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
This file contains functions for adding additional data files to Worlds.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
Functions
-
void
Alert
(const std::string &msg)¶ Send msg to cerr if in C++, or show msg in an alert box if compiled to Javascript Input can be any number of arguments of any types as long as the can be converted to strings with emp::to_string().
-
template <typename... TYPE_SET>
static voidCappedAlert
(size_t cap, TYPE_SET... inputs)¶ A version of Alert that will cap how many times it can go off.
-
struct
AlertObj
¶ - #include <alert.h>
An object that will automatically output a message during construction or destruction, usually for use in debugging to disentangle timings.
BitMatrix¶
A COL x ROW matrix of bits and provides easy indexing and manipulation.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2016-2017
- Note
- Status: BETA
-
namespace
emp
¶ If we are in emscripten, make sure to include the header.
This file contains extra analysis tools to use with systematics managers that have non-null DATA_TYPES.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
This file contains functions for adding additional data files to Worlds.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
-
template <size_t COLS, size_t ROWS>
classBitMatrix
¶ - #include <BitMatrix.h>
A simple class to manage a COLS x ROWS matrix of bits.
Bits are translated to a bitset with 0 in the upper left and moving through bits from left to right and top to bottom. For example, the indecies in a 3x3 bit matrix would be organized as such:
0 1 2 3 4 5 6 7 8
Public Functions
-
template <size_t START_POS, size_t STEP_POS, size_t END_POS>
constexpr BitSet<COLS*ROWS>Mask
() const¶
-
BitMatrix
()¶
-
~BitMatrix
()¶
-
constexpr size_t
NumRows
() const¶ How many rows are in this matrix?
-
constexpr size_t
NumCols
() const¶ How many columns are in this matrix?
-
constexpr size_t
GetSize
() const¶ How many total cells are in this matrix?
-
bool
Any
() const¶
-
bool
None
() const¶
-
bool
All
() const¶
-
bool
Get
(size_t col, size_t row) const¶
-
bool
Get
(size_t id) const¶
-
void
Set
(size_t col, size_t row, bool val = true)¶
-
void
Set
(size_t id)¶
-
void
Unset
(size_t col, size_t row)¶
-
void
Unset
(size_t id)¶
-
void
Flip
(size_t col, size_t row)¶
-
void
Flip
(size_t id)¶
-
void
SetAll
()¶
-
void
SetCol
(size_t col)¶
-
void
SetRow
(size_t row)¶
-
void
Clear
()¶
-
void
ClearCol
(size_t col)¶
-
void
ClearRow
(size_t row)¶
-
size_t
CountOnes
() const¶
-
int
FindBit
() const¶
-
bool
IsConnected
() const¶
-
bool
Has2x2
() const¶
Public Static Functions
-
template <size_t COL_ID>
static const BitSet<COLS*ROWS> &MaskCol
()¶ Keep only a single column of values, reducing all others to zeros.
-
template <size_t ROW_ID>
static const BitSet<COLS*ROWS> &MaskRow
()¶ Keep only a single row of values, reducing all others to zeros.
-
static size_t
ToCol
(size_t id)¶ Identify which column a specific ID is part of.
-
static size_t
ToRow
(size_t id)¶ Identify which row a specific ID is part of.
-
static size_t
ToID
(size_t col, size_t row)¶ Identify the ID associated with a specified row and column.
-
template <size_t START_POS, size_t STEP_POS, size_t END_POS>
BitSet¶
A drop-in replacement for std::bitset, with additional bit magic features.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2016-2017
- Note
- Status: RELEASE
- Note
- Like std::bitset, bit zero is on the right side. Unlike std::bitset, emp::BitSet gives access to bit fields for easy access to different sized chucnk of bits and implementation new bit-magic tricks.
Functions
-
namespace
emp
If we are in emscripten, make sure to include the header.
This file contains extra analysis tools to use with systematics managers that have non-null DATA_TYPES.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
This file contains functions for adding additional data files to Worlds.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
Functions
-
template <size_t NUM_BITS1, size_t NUM_BITS2>
BitSet<NUM_BITS1+NUM_BITS2>join
(const BitSet<NUM_BITS1> &in1, const BitSet<NUM_BITS2> &in2)¶
-
template <size_t NUM_BITS>
doubleSimpleMatchCoeff
(const BitSet<NUM_BITS> &in1, const BitSet<NUM_BITS> &in2)¶ Computes simple matching coefficient (https://en.wikipedia.org/wiki/Simple_matching_coefficient).
-
template <size_t NUM_BITS>
classBitSet
¶ - #include <BitSet.h>
A fixed-sized (but arbitrarily large) array of bits, and optimizes operations on those bits to be as fast as possible.
Public Functions
-
BitSet
()¶ Constructor: Assume all zeroes in set.
-
~BitSet
()¶ Destructor.
-
void
Randomize
(Random &random, const double p1 = 0.5)¶ Set all bits randomly, with a given probability of being a 1.
-
template <size_t NUM_BITS2>
BitSet &Import
(const BitSet<NUM_BITS2> &in_set)¶ Assign from a BitSet of a different size.
-
template <size_t NUM_BITS2>
BitSet<NUM_BITS2>Export
() const¶ Convert to a Bitset of a different size.
-
bool
operator<
(const BitSet &in_set) const¶ Compare two BitSet objects, based on the associated binary value.
-
bool
operator<=
(const BitSet &in_set) const¶ Compare two BitSet objects, based on the associated binary value.
-
bool
operator>
(const BitSet &in_set) const¶ Compare two BitSet objects, based on the associated binary value.
-
bool
operator>=
(const BitSet &in_set) const¶ Compare two BitSet objects, based on the associated binary value.
-
bool
Get
(size_t index) const¶ Retrieve the bit as a specified index.
-
void
Set
(size_t index, bool value)¶ Set the bit as a specified index.
-
uint8_t
GetByte
(size_t index) const¶ Get the full byte starting from the bit at a specified index.
-
void
SetByte
(size_t index, uint8_t value)¶ Set the full byte starting at the bit at the specified index.
-
uint32_t
GetUInt
(size_t index) const¶ Get the 32-bit unsigned int; index in in 32-bit jumps (i.e., this is a field ID not bit id)
-
void
SetUInt
(size_t index, uint32_t value)¶ Set the 32-bit unsigned int; index in in 32-bit jumps (i.e., this is a field ID not bit id)
-
uint32_t
GetUIntAtBit
(size_t index)¶ Get the full 32-bit unsigned int starting from the bit at a specified index.
-
template <size_t OUT_BITS>
uint32_tGetValueAtBit
(size_t index)¶ Get OUT_BITS bits starting from the bit at a specified index (max 32)
-
BitProxy
operator[]
(size_t index)¶ Index into a BitSet, returning a proxy that will allow bit assignment to work.
-
void
Clear
()¶ Set all bits to zero.
-
void
SetAll
()¶ Set all bits to one.
-
void
PrintArray
(std::ostream &out = std::cout) const¶ Print all bits from smallest to largest, as if this were an array, not a bit representation.
-
void
PrintOneIDs
(std::ostream &out = std::cout, char spacer = ' ') const¶ Print the locations of all one bits, using the provided spacer (default is a single space)
-
size_t
CountOnes_Sparse
() const¶ Count 1’s by looping through once for each bit equal to 1.
-
size_t
CountOnes_Mixed
() const¶ Count 1’s in semi-parallel; fastest for even 0’s & 1’s.
-
int
FindBit
() const¶ Return the index of the first one in the sequence; return -1 if no ones are available.
-
int
PopBit
()¶ Return index of first one in sequence (or -1 if no ones); change this position to zero.
-
int
FindBit
(const size_t start_pos) const¶ Return index of first one in sequence AFTER start_pos (or -1 if no ones)
-
emp::vector<size_t>
GetOnes
() const¶ Return a vector indicating the posistions of all ones in the BitSet.
-
BitSet
AND
(const BitSet &set2) const¶ Perform a Boolean AND with a second BitSet and return the result.
-
BitSet
OR
(const BitSet &set2) const¶ Perform a Boolean OR with a second BitSet and return the result.
-
BitSet
NAND
(const BitSet &set2) const¶ Perform a Boolean NAND with a second BitSet and return the result.
-
BitSet
NOR
(const BitSet &set2) const¶ Perform a Boolean NOR with a second BitSet and return the result.
-
BitSet
XOR
(const BitSet &set2) const¶ Perform a Boolean XOR with a second BitSet and return the result.
-
BitSet
EQU
(const BitSet &set2) const¶ Perform a Boolean EQU with a second BitSet and return the result.
-
BitSet &
NOT_SELF
()¶ Perform a Boolean NOT on this BitSet, store result here, and return this object.
-
BitSet &
AND_SELF
(const BitSet &set2)¶ Perform a Boolean AND with a second BitSet, store result here, and return this object.
-
BitSet &
OR_SELF
(const BitSet &set2)¶ Perform a Boolean OR with a second BitSet, store result here, and return this object.
-
BitSet &
NAND_SELF
(const BitSet &set2)¶ Perform a Boolean NAND with a second BitSet, store result here, and return this object.
-
BitSet &
NOR_SELF
(const BitSet &set2)¶ Perform a Boolean NOR with a second BitSet, store result here, and return this object.
-
BitSet &
XOR_SELF
(const BitSet &set2)¶ Perform a Boolean XOR with a second BitSet, store result here, and return this object.
-
BitSet &
EQU_SELF
(const BitSet &set2)¶ Perform a Boolean EQU with a second BitSet, store result here, and return this object.
-
BitSet
SHIFT
(const int shift_size) const¶ Positive shifts go left and negative go right (0 does nothing); return result.
-
BitSet &
SHIFT_SELF
(const int shift_size)¶ Positive shifts go left and negative go right; store result here, and return this object.
-
bool
all
() const¶ Function to allow drop-in replacement with std::bitset.
-
bool
any
() const¶ Function to allow drop-in replacement with std::bitset.
-
bool
none
() const¶ Function to allow drop-in replacement with std::bitset.
-
size_t
count
() const¶ Function to allow drop-in replacement with std::bitset.
Public Static Functions
-
static constexpr size_t
size
()¶ Function to allow drop-in replacement with std::bitset.
Private Functions
-
void
Copy
(const uint32_t in_set[NUM_FIELDS])¶
-
void
ShiftLeft
(const uint32_t shift_size)¶ Helper: call SHIFT with positive number instead.
-
void
ShiftRight
(const uint32_t shift_size)¶ Helper for calling SHIFT with negative number.
Private Members
Private Static Functions
-
static size_t
FieldID
(const size_t index)¶
-
static size_t
FieldPos
(const size_t index)¶
-
static size_t
Byte2Field
(const size_t index)¶
-
static size_t
Byte2FieldPos
(const size_t index)¶
Private Static Attributes
-
const uint32_t
NUM_FIELDS
= 1 + ((NUM_BITS - 1) >> 5)¶ Fields hold bits in groups of 32 (as uint32_t); how many feilds do we need?
-
const uint32_t
LAST_BIT
= NUM_BITS & 31¶ End position of the stored bits in the last field; 0 if perfect fit.
-
const uint32_t
NUM_BYTES
= 1 + ((NUM_BITS - 1) >> 3)¶ How many total bytes are needed to represent these bits? (rounded up to full bytes)
Friends
-
friend
emp::BitProxy
-
BitSet Utilities¶
A set of simple functions to manipulate bitsets.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2016-2017
- Note
- Status: BETA
-
namespace
emp
If we are in emscripten, make sure to include the header.
This file contains extra analysis tools to use with systematics managers that have non-null DATA_TYPES.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
This file contains functions for adding additional data files to Worlds.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
Functions
-
template <int NUM_BITS>
constexpr uint32_tUIntMaskFirst
()¶ Create a series of a specified number of ones (at compile time) in a uint.
-
template <>
template<>
constexpr uint32_tUIntMaskFirst
<0>()¶ Create an empty bit mask (all zeros)
-
constexpr size_t
count_bits
(uint64_t val)¶ Count the number of bits in a 64-bit unsigned integer.
-
constexpr size_t
count_bits
(uint32_t val)¶ Count the number of bits in a 32-bit unsigned integer.
-
constexpr size_t
find_bit
(const uint64_t &val)¶ Return the position of the first one bit (in a 64-bit unsigned int)
-
constexpr size_t
find_bit
(const uint32_t &val)¶ Return the position of the first one bit (in a 32-bit unsigned int)
Variables
-
constexpr size_t
ByteCount
[256]= {
0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8
}
¶ How many bits are set to one in each possible byte?
BitVector¶
A drop-in replacement for std::vector<bool>, with additional bitwise logic features.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2016-2017
- Note
- Status: RELEASE
- Note
- This class is 15-20% slower than emp::BitSet, but more flexible & run-time configurable.
-
template <>
template<>
structhash
<emp::BitVector>¶ - #include <BitVector.h>
Hash function to allow BitVector to be used with maps and sets (must be in std).
-
namespace
emp
If we are in emscripten, make sure to include the header.
This file contains extra analysis tools to use with systematics managers that have non-null DATA_TYPES.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
This file contains functions for adding additional data files to Worlds.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
-
class
BitVector
¶ - #include <BitVector.h>
A drop-in replacement for std::vector<bool>, but with extra bitwise logic features.
This class stores an arbirary number of bits in a set of “fields” (either 32-bit or 64-bit, depending on which should be faster.) Individual bits can be extracted, -or- bitwise logic (or bit magic) can be used on the groups of bits,
Public Functions
-
BitVector
(size_t in_num_bits = 0, bool init_val = false)¶ Build a new BitVector with specified bit count (default 0) and initialization (default 0)
-
~BitVector
()¶ Destructor.
-
bool
operator<
(const BitVector &in_set) const¶ Compare the would-be numerical values of two bit vectors.
-
bool
operator<=
(const BitVector &in_set) const¶ Compare the would-be numerical values of two bit vectors.
-
bool
operator>
(const BitVector &in_set) const¶ Compare the would-be numerical values of two bit vectors.
-
bool
operator>=
(const BitVector &in_set) const¶ Compare the would-be numerical values of two bit vectors.
-
size_t
GetSize
() const¶ How many bits do we currently have?
-
bool
Get
(size_t index) const¶ Retrive the bit value from the specified index.
-
void
Set
(size_t index, bool value = true)¶ Update the bit value at the specified index.
-
uint8_t
GetByte
(size_t index) const¶ Retrive the byte at the specified byte index.
-
void
SetByte
(size_t index, uint8_t value)¶ Update the byte at the specified byte index.
-
uint32_t
GetUInt
(size_t index) const¶ Retrive the 32-bit uint from the specifeid uint index.
-
void
SetUInt
(size_t index, uint32_t value)¶ Update the 32-bit uint at the specified uint index.
-
uint32_t
GetUIntAtBit
(size_t index)¶ Retrive the 32-bit uint at the specified BIT index.
-
template <size_t OUT_BITS>
field_tGetValueAtBit
(size_t index)¶ Retrieve the specified number of bits (stored in the field type) at the target bit index.
-
bool
Any
() const¶ Return true if ANY bits are set to 1, otherwise return false.
-
bool
None
() const¶ Return true if NO bits are set to 1, otherwise return false.
-
bool
All
() const¶ Return true if ALL bits are set to 1, otherwise return false.
-
operator bool
() const¶ Casting a bit array to bool identifies if ANY bits are set to 1.
-
bool
operator[]
(size_t index) const¶ Const index operator return the bit at the specified position.
-
BitProxy
operator[]
(size_t index)¶ Index operator return a proxy to the bit at the specified position so it can be an lvalue.
-
void
Clear
()¶ Set all bits to 0.
-
void
SetAll
()¶ Set all bits to 1.
-
void
Print
(std::ostream &out = std::cout) const¶ Regular print function (from most significant bit to least)
-
void
PrintFields
(std::ostream &out = std::cout, const std::string spacer = " ") const¶ Print a space between each field (or other provided spacer)
-
void
PrintOneIDs
(std::ostream &out = std::cout, std::string spacer = " ") const¶ Print the positions of all one bits, spaces are the default separator.
-
size_t
CountOnes_Sparse
() const¶ Count 1’s by looping through once for each bit equal to 1.
-
size_t
CountOnes_Mixed
() const¶ Count 1’s in semi-parallel; fastest for even 0’s & 1’s.
-
int
FindBit
() const¶ Return the position of the first one; return -1 if no ones in vector.
-
int
PopBit
()¶ Return the position of the first one and change it to a zero. Return -1 if no ones.
-
int
FindBit
(const size_t start_pos) const¶ Return the position of the first one after start_pos; return -1 if no ones in vector. You can loop through all 1-bit positions of a BitVector “bv” with:
for (int pos = bv.FindBit(); pos >= 0; pos = bv.FindBit(pos+1)) { … }
-
BitVector
AND
(const BitVector &set2) const¶ Perform a Boolean AND on this BitVector and return the result.
-
BitVector
OR
(const BitVector &set2) const¶ Perform a Boolean OR on this BitVector and return the result.
-
BitVector
NAND
(const BitVector &set2) const¶ Perform a Boolean NAND on this BitVector and return the result.
-
BitVector
NOR
(const BitVector &set2) const¶ Perform a Boolean NOR on this BitVector and return the result.
-
BitVector
XOR
(const BitVector &set2) const¶ Perform a Boolean XOR on this BitVector and return the result.
-
BitVector
EQU
(const BitVector &set2) const¶ Perform a Boolean EQU on this BitVector and return the result.
-
BitVector &
NOT_SELF
()¶ Perform a Boolean NOT with this BitVector, store result here, and return this object.
-
BitVector &
AND_SELF
(const BitVector &set2)¶ Perform a Boolean AND with this BitVector, store result here, and return this object.
-
BitVector &
OR_SELF
(const BitVector &set2)¶ Perform a Boolean OR with this BitVector, store result here, and return this object.
-
BitVector &
NAND_SELF
(const BitVector &set2)¶ Perform a Boolean NAND with this BitVector, store result here, and return this object.
-
BitVector &
NOR_SELF
(const BitVector &set2)¶ Perform a Boolean NOR with this BitVector, store result here, and return this object.
-
BitVector &
XOR_SELF
(const BitVector &set2)¶ Perform a Boolean XOR with this BitVector, store result here, and return this object.
-
BitVector &
EQU_SELF
(const BitVector &set2)¶ Perform a Boolean EQU with this BitVector, store result here, and return this object.
-
BitVector
SHIFT
(const int shift_size) const¶ Positive shifts go left and negative go right (0 does nothing); return result.
-
BitVector &
SHIFT_SELF
(const int shift_size)¶ Positive shifts go left and negative go right; store result here, and return this object.
-
size_t
size
() const¶ Function to allow drop-in replacement with std::vector<bool>.
-
bool
all
() const¶ Function to allow drop-in replacement with std::vector<bool>.
-
bool
any
() const¶ Function to allow drop-in replacement with std::vector<bool>.
-
bool
none
() const¶ Function to allow drop-in replacement with std::vector<bool>.
-
size_t
count
() const¶ Function to allow drop-in replacement with std::vector<bool>.
Private Types
-
using
field_t
= uint64_t¶ Field sizes are 64 bits in native.
Private Functions
-
size_t
LastBitID
() const¶ End position of the stored bits in the last field; 0 if perfect fit.
-
size_t
NumFields
() const¶ How many feilds do we need?
-
size_t
NumBytes
() const¶ How many bytes are used in the current vector (round up to whole bytes.)
-
size_t
NumSizeFields
() const¶ How many fields would we need if they had the same number of bits as size_t?
-
void
RawCopy
(const Ptr<field_t> in_set)¶ Assume that the size of the bit_set has already been adjusted to be the size of the one being copied and only the fields need to be copied over.
-
void
ShiftLeft
(const size_t shift_size)¶ Helper: call SHIFT with positive number.
-
void
ShiftRight
(const size_t shift_size)¶ Helper for calling SHIFT with negative number.
Private Members
-
size_t
num_bits
¶ How many total bits are we using?
Private Static Functions
-
static constexpr size_t
FieldID
(const size_t index)¶ Identify the field that a specified bit is in.
-
static constexpr size_t
FieldPos
(const size_t index)¶ Identify the position in a field where a specified bit is.
-
static constexpr size_t
Byte2Field
(const size_t index)¶ Identify which field a specified byte position would be in.
Private Static Attributes
-
constexpr size_t
FIELD_BITS
= sizeof(field_t)*8¶ How many bits are in a field?
-
struct
BitProxy
¶ BitProxy lets us use operator[] on with BitVector as an lvalue.
Public Functions
-
BitProxy &
operator=
(bool b)¶ Assignment operator to the bit associated with this proxy (as an lvalue).
-
operator bool
() const¶ Conversion of this proxy to Boolean (as an rvalue)
-
BitProxy &
operator&=
(bool b)¶ Compound assignement operator AND using BitProxy as lvalue.
- Note
- Implemented in BitProxy since it needs to work, but may not be efficient.
-
BitProxy &
operator|=
(bool b)¶ Compound assignement operator OR using BitProxy as lvalue.
- Note
- Implemented in BitProxy since it needs to work, but may not be efficient.
-
BitProxy &
operator^=
(bool b)¶ Compound assignement operator XOR using BitProxy as lvalue.
- Note
- Implemented in BitProxy since it needs to work, but may not be efficient.
-
BitProxy &
operator+=
(bool b)¶ Compound assignement operator PLUS using BitProxy as lvalue.
- Note
- Implemented in BitProxy since it needs to work, but may not be efficient.
-
BitProxy &
operator-=
(bool b)¶ Compound assignement operator MINUS using BitProxy as lvalue.
- Note
- Implemented in BitProxy since it needs to work, but may not be efficient.
-
BitProxy &
-
-
namespace
std
¶ Functions
Cache¶
similar to an std::unordered_map, but all lookups come with a function to generate the result should the lookup fail.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2016-2018
- Note
- Status: BETA
-
namespace
emp
If we are in emscripten, make sure to include the header.
This file contains extra analysis tools to use with systematics managers that have non-null DATA_TYPES.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
This file contains functions for adding additional data files to Worlds.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
-
template <class KEY, class T, class HASH = std::hash<KEY>, class PRED = std::equal_to<KEY>, class ALLOC = std::allocator< std::pair<const KEY,T> >>
classCache
¶ - #include <Cache.h>
Public Types
-
template<>
usingkey_type
= KEY¶ Type we are using to look up values.
-
template<>
usingmapped_type
= T¶ Contents of the value we look up.
-
template<>
usinghasher
= HASH¶ Hash method to use.
-
template<>
usingkey_equal
= PRED¶ Function to test if two values are identical.
-
template<>
usingallocator_type
= ALLOC¶ Function to allocate new space.
Public Functions
-
Cache
()¶
-
size_t
size
() const¶ How many entries are stored in the cache?
-
bool
Has
(const KEY &k) const¶ Determine if a specific key is already in the cache.
-
void
Clear
()¶ Erase contents of cache.
-
void
Erase
(const KEY &k)¶ Erase a specific entry from cache.
-
template<>
Combinations¶
Tools to step through combinations of items.
Step through all combinations of size K from a set of N values. For ComboIDs just return the indecies (the specific of the container don’t matter). Other versions will directly wrapper containers.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2017
-
namespace
emp
If we are in emscripten, make sure to include the header.
This file contains extra analysis tools to use with systematics managers that have non-null DATA_TYPES.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
This file contains functions for adding additional data files to Worlds.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
-
class
ComboIDs
¶ - #include <combos.h>
Public Functions
-
ComboIDs
(size_t in_max, size_t combo_size)¶
-
~ComboIDs
()¶
-
size_t
GetComboSize
() const¶
-
size_t
GetNumCombos
() const¶
-
size_t &
operator[]
(const size_t index)¶
-
const size_t &
operator[]
(const size_t index) const¶
-
bool
NextCombo
()¶
-
void
ResizeCombos
(size_t new_size)¶
-
size_t
size
()¶
Private Static Functions
-
size_t
CountCombos
(size_t max_count, size_t combo_size)¶
-
Constants¶
Commonly used constant values.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2015-2017
- Note
- Status: RELEASE
-
namespace
emp
If we are in emscripten, make sure to include the header.
This file contains extra analysis tools to use with systematics managers that have non-null DATA_TYPES.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
This file contains functions for adding additional data files to Worlds.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
Functions
-
template <typename T>
constexpr TMaxValue
()¶ Determine the maximum value for any type.
-
template <typename T>
constexpr doubleInterpolateTable
(T &&table, double pos, double tsize)¶ The following function takes a table and a position [0.0, 1.0) and intepolates a value.
Variables
-
constexpr const double
E
= 2.71828¶ e
-
constexpr const double
PHI
= 1.61803398874¶ Golden ratio.
-
constexpr const double
PI
= 3.14159265358979¶ pi
-
constexpr const double
SQRT2
= 1.41421356237310¶ sqrt(2)
-
constexpr const uint32_t
MAX_BYTE
= 255¶ (2^8 - 1)
-
constexpr const uint32_t
MAX_2BYTE
= 65535¶ (2^16 - 1)
-
constexpr const uint32_t
MAX_WORD
= 65535¶ (2^16 - 1)
-
constexpr const uint32_t
MAX_3BYTE
= 16777215¶ (2^24 - 1)
-
constexpr const uint32_t
MAX_UINT
= 4294967295¶ (2^32 - 1)
-
constexpr const uint32_t
MAX_4BYTE
= 4294967295¶ (2^32 - 1)
-
constexpr const int32_t
MIN_INT
= -2147483648¶ (- 2^31)
-
constexpr const double
log2_chart_1_2
[]¶ Large table to log base-2 results.
-
constexpr const double
pow2_chart_bits
[]=
{
1.4142135623730951, 1.1892071150027210, 1.0905077326652577, 1.0442737824274138,
1.0218971486541166, 1.0108892860517005, 1.0054299011128027, 1.0027112750502025,
1.0013547198921082, 1.0006771306930664, 1.0003385080526823, 1.0001692397053021,
1.0000846162726944, 1.0000423072413958, 1.0000211533969647, 1.0000105766425498,
1.0000052883072919, 1.0000026441501502, 1.0000013220742012, 1.0000006610368821,
1.0000003305183864, 1.0000001652591795, 1.0000000826295863, 1.0000000413147923,
1.0000000206573960, 1.0000000103286979, 1.0000000051643489, 1.0000000025821745,
1.0000000012910872, 1.0000000006455436, 1.0000000003227718, 1.0000000001613858
}
¶ Table to provide results of Pow2 for values of bits (0.1, 0.01, 0.001, etc, in binary)
-
constexpr const double
pow2_chart_0_1
[]¶ Table to provide results of Pow2 from 0 to 1.
Debugging Tools¶
Basic tools for use in developing high-assurance code.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2015-2017
- Note
- Status: BETA
Defines
-
BlockRelease
(BLOCK)¶ BlockRelease() will halt compilation if NDEBUG is on. It is useful to include alongside debug print code that you want to remember to remove when you are done debugging.
-
namespace
emp
If we are in emscripten, make sure to include the header.
This file contains extra analysis tools to use with systematics managers that have non-null DATA_TYPES.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
This file contains functions for adding additional data files to Worlds.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
Functions
-
static void
Depricated
(const std::string &name, const std::string &desc = "")¶ Depricated() prints its contents exactly once to notify a user of a depricated function.
Deterministic Finite Automata¶
A Deterministic Finite Automata simulator.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2016-2017
- Note
- Status: BETA
-
namespace
emp
If we are in emscripten, make sure to include the header.
This file contains extra analysis tools to use with systematics managers that have non-null DATA_TYPES.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
This file contains functions for adding additional data files to Worlds.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
Typedefs
-
using
emp::DFA = typedef tDFA<128, uint8_t>
Setup DFA to be a simple tDFA with the basic character set for symbols.
-
template <int NUM_SYMBOLS = 128, typename STOP_TYPE = uint8_t>
classtDFA
¶ - #include <DFA.h>
Public Types
-
template<>
usingstop_t
= STOP_TYPE¶
Public Functions
-
tDFA
(size_t num_states = 0)¶
-
~tDFA
()¶
-
size_t
GetSize
() const¶ How many states is this DFA using?
-
void
Resize
(size_t new_size)¶ Add Additional empty states.
-
const emp::array<int, NUM_SYMBOLS> &
GetTransitions
(size_t from) const¶ Return an array of all transitions associated with a specified state.
-
void
SetTransition
(size_t from, size_t to, size_t sym)¶ Add a specific transition associated with an input symbol.
-
void
SetStop
(size_t state, stop_t stop_val = 1)¶ Set the stop value (no matter what it currently is)
-
void
AddStop
(size_t state, stop_t stop_val = 1)¶ Set the stop value only if it’s higher than the current stop value.
-
stop_t
GetStop
(int state) const¶ Get the stop value associated with a state.
-
bool
IsActive
(int state) const¶ Test if a state is still valid.
-
bool
IsStop
(int state) const¶ Test if a state has a stop.
-
stop_t
GetStop
(size_t state) const¶
-
bool
IsActive
(size_t state) const¶
-
bool
IsStop
(size_t state) const¶
-
int
Next
(int state, size_t sym) const¶ Return the new state after a symbol occurs.
-
template<>
Dynamic Strings¶
A string handler where sections update dynamically based on functions.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2016-2017
- Note
- Status: BETA
-
namespace
emp
If we are in emscripten, make sure to include the header.
This file contains extra analysis tools to use with systematics managers that have non-null DATA_TYPES.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
This file contains functions for adding additional data files to Worlds.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
-
class
DynamicString
¶ - #include <DynamicString.h>
A string handler where some sections can be fixed strings, while others update dynamically based on functions.
Public Functions
-
DynamicString
()¶
-
DynamicString
(const DynamicString&)¶
-
size_t
GetSize
() const¶ How many string components (funcations or continuous substrings) are in this DynamicString?
-
std::string
operator[]
(size_t id) const¶ Index in to a specific component (not a specific character, since size is variable) and return it’s associated string.
-
const value_t &
GetFunction
(size_t id) const¶ Index in to a specific component (not a specific character, since size is variable) and return it’s associated function.
-
DynamicString &
Clear
()¶ Remove all contents on this DynamicString.
-
DynamicString &
Set
(size_t id, const value_t &in_fun)¶ Set the value of a specified component to the provided function.
-
DynamicString &
Set
(size_t id, const std::string &in_text)¶ Set the value of a specified component to the provided std::string text.
-
DynamicString &
Append
(const value_t &in_fun)¶ Add a new function to the end of the DynamicString.
-
DynamicString &
Append
(const std::string &in_text)¶ Add new std::string text to the end of the DynamicString.
-
template <typename IN_TYPE>
DynamicString &operator<<
(IN_TYPE &&_in)¶ Allow operator<< to append to the back of a DynamicString.
-
Errors¶
Warning
doxygenfile: Cannot find file “tools/errors.h
In-memory Files¶
The File object maintains a simple, in-memory file.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
- Note
- Status: BETA
-
namespace
emp
If we are in emscripten, make sure to include the header.
This file contains extra analysis tools to use with systematics managers that have non-null DATA_TYPES.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
This file contains functions for adding additional data files to Worlds.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
-
class
File
¶ - #include <File.h>
A class to maintin files for loading, writing, storing, and easy access to components.
Public Functions
-
File
()¶
-
~File
()¶
-
auto
begin
() const¶ Return const iterator to beginning of file.
-
auto
end
() const¶ Return const iterator to end of file.
-
auto
begin
()¶ Return iterator to beginning of file.
-
auto
end
()¶ Return iterator to end of file.
-
size_t
GetNumLines
() const¶ How many lines are in this file?
-
File &
Append
(const emp::vector<std::string> &in_lines)¶ Append a vector of lines to the end of the file.
-
template <typename T>
autooperator<<
(T &&in)¶ Insert formatted data into file This is exactly the same as operator+=
-
File &
Load
(const std::string &filename)¶ Load a file from disk using the provided name. If file does not exist, this is a nop
-
std::set<std::string>
AsSet
() const¶ Convert this file into an std::set of lines (loses line ordering).
-
File &
Apply
(const std::function<void(std::string&)> &fun)¶ Apply a string manipulation function to all lines in the file.
-
File &
KeepIf
(const std::function<bool(const std::string&)> &fun)¶ Purge functions that don’t meet a certain criterion.
-
File &
CompressWhitespace
()¶ Any time multiple whitespaces are next to each other, collapse to a single WS char. Prefer ‘
’ if in whitespace collapsed, otherwise use ‘ ‘.
-
Flex Functions¶
Based on std::function, but holds default parameter values for calls with fewer args.
A collection of broadly-useful functions (that don’t fit elsewhere)
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2016-2017
- Note
- Status: ALPHA
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2016-2018
- Note
- Status: BETA (though new functions are added frequently)
-
namespace
emp
If we are in emscripten, make sure to include the header.
This file contains extra analysis tools to use with systematics managers that have non-null DATA_TYPES.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
This file contains functions for adding additional data files to Worlds.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
-
template <class R, class... ARGS>
template<>
classflex_function
<R(ARGS...)>¶ - #include <flex_function.h>
A functon class that is almost identical to std::function, but is provided with default values for all parameters so that it can be called with fewer arguments, as needed.
Public Functions
-
template <typename T>
flex_function
(T &&fun_info)¶
-
flex_function
(const this_t&)¶
-
flex_function
(this_t&&)¶
-
flex_function
()¶
-
this_t &
operator=
(const this_t&)¶
-
this_t &
operator=
(this_t&&)¶
-
this_t &
operator=
(const fun_t &_f)¶
-
this_t &
operator=
(fun_t &&_f)¶
-
template <typename T>
this_t &operator=
(T &&arg)¶
-
template <int ID>
voidSetDefault
(pack_id<ID, ARGS...> &in_default)¶ Set the default value for a specific parameter.
-
void
SetDefaults
(ARGS... args)¶ Set the default values for all parameters.
-
return_t
operator()
(ARGS... k) const¶ Allow the function to be called with all args.
-
template <class... IN_ARGS>
return_toperator()
(IN_ARGS&&... k) const¶ All the function to be called with a subset of arguments (and the rest set to defaults)
-
operator bool
() const¶ Determine whether this function has been set.
Public Static Attributes
-
constexpr int
num_args
= sizeof...(ARGS)¶
-
template <typename T>
Functions¶
-
namespace
emp
If we are in emscripten, make sure to include the header.
This file contains extra analysis tools to use with systematics managers that have non-null DATA_TYPES.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
This file contains functions for adding additional data files to Worlds.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
Functions
-
static double
TimeFun
(std::function<void()> test_fun)¶ A function timer that takes a functor an identifies how long it takes to complete when run.
-
bool
Toggle
(bool &in_bool)¶ Toggle an input bool.
-
constexpr bool
AllTrue
()¶ Combine bools to AND them all together.
-
template <typename... Ts>
boolAllTrue
(bool result, Ts... OTHER)¶
-
constexpr bool
AnyTrue
()¶ Combine bools to OR them all together.
-
template <typename... Ts>
boolAnyTrue
(bool result, Ts... OTHER)¶
-
template <typename T>
static emp::vector<T>BuildRange
(T min, T max, T step = 1)¶ Build a vector with a range of values from min to max at the provided step size.
-
template <typename T, size_t N>
constexpr size_tGetSize
(T (&)[N])¶ Determine the size of a built-in array.
-
static size_t
UniqueVal
()¶ A function that will always return a unique value (and trip an assert if it can’t…)
Function Sets¶
Setup a collection of functions, all with the same signature, that can be run as a group.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2016-2017
- Note
- Status: BETA
-
namespace
emp
If we are in emscripten, make sure to include the header.
This file contains extra analysis tools to use with systematics managers that have non-null DATA_TYPES.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
This file contains functions for adding additional data files to Worlds.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
-
template <typename RETURN_T, typename... ARGS>
template<>
classFunctionSet
<RETURN_T(ARGS...)> : public emp::vector<std::function<RETURN_T(ARGS...)>>¶ - #include <FunctionSet.h>
A vector of functions that can all be triggered at onece; results can either be returned in a vector or post-processed in a function (such as max, min, etc.) Derived from emp::vector, hence with all of the same methods as vector.
Public Types
-
template<>
usingreturn_t
= RETURN_T¶
Public Functions
-
FunctionSet
()¶
-
~FunctionSet
()¶
-
size_t
GetSize
() const¶ How many functions are in this FunctionSet?
-
void
Add
(const value_type &in_fun)¶ Add a new funtion to this FunctionSet.
-
void
Remove
(size_t pos)¶ Remove the function at a specified position.
-
const emp::vector<RETURN_T> &
Run
(ARGS... args) const¶ Run all functions and return a vector of all results.
-
RETURN_T
Run
(ARGS... args, std::function<RETURN_T(RETURN_T, RETURN_T)> comp_fun, RETURN_T default_val = 0, ) const¶ If you want to provide a filter function, you can retrieve a specific return value. The filter should take in two return values and indicate which is “better”.
-
RETURN_T
FindMax
(ARGS... args, RETURN_T default_val = 0) const¶ Run all functions and return the highest value.
-
RETURN_T
FindMin
(ARGS... args, RETURN_T default_val = 0) const¶ Run all functions and return the lowest value.
-
RETURN_T
FindSum
(ARGS... args, RETURN_T default_val = 0) const¶ Run all functions and return the total value.
-
RETURN_T
FindProduct
(ARGS... args, RETURN_T default_val = 1) const¶ Run all functions and return a product of all values.
-
template<>
Generic Functions¶
Warning
doxygenfile: Cannot find file “tools/GenericFunctions.h
Graph Utilities¶
This file provides a number of tools for manipulating graphs.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2017
- Note
- Status: BETA
-
namespace
emp
If we are in emscripten, make sure to include the header.
This file contains extra analysis tools to use with systematics managers that have non-null DATA_TYPES.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
This file contains functions for adding additional data files to Worlds.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
Functions
-
Graph
shuffle_graph
(const Graph &in_graph, Random &random)¶ Take an existing graph, and build a new one that is isomorphic to it, but with randomized vertex IDs.
-
Graph
build_graph_ring
(size_t v_count, Random &random)¶ Construct a graph where all vertics are degree two and form a single ring.
-
Graph
build_graph_tree
(size_t v_count, Random &random)¶ Construct a random tree graph (new vertices are repeatedly attached to a random position in a treee as it is constructed.)
-
Graph
build_graph_random
(size_t v_count, size_t e_count, Random &random, bool connected = true)¶ Construct a random, graph with the specified number of vertices and edges. If connected is set, start by building a tree. Then connect random (unconnected) pairs of vertices until the proper number of edges are included.
-
Graph
build_graph_grid
(size_t width, size_t height, Random &random, double prob_use = 1.0)¶ Construct a graph with width x height vertices setup into a grid structure.
-
Graph
build_graph_clique_set
(size_t clique_size, size_t clique_count, Random &random, double extra_prob = 0.5)¶ Build a set of cliques (such that one member of each can be part of an independent set) and then links them together
-
Graph
build_graph_dag
(size_t v_count, size_t e_count, Random &random, bool connected = true)¶ Construct a random, graph with the specified number of vertices and edges. If connected is set, start by building a tree. Then connect random (unconnected) pairs of vertices until the proper number of edges are included.
-
WeightedGraph
build_weighted_graph_tree
(size_t v_count, size_t min_weight, size_t max_weight, Random &random)¶ Construct a random WEIGHTED tree graph (new vertices are repeatedly attached to a random position in a treee as it is constructed.)
-
WeightedGraph
build_weighted_graph_random
(size_t v_count, size_t e_count, size_t min_weight, size_t max_weight, Random &random, bool connected = true)¶ Construct a random, WEIGHTED graph with the specified number of vertices, edges, and range of edge weights. If connected is set, start by building a tree. Then connect random (unconnected) pairs of vertices until the proper number of edges are included.
-
Graph
load_graph_sym
(std::istream &is, bool sub1 = false)¶ Helper function for loading symetric graphs from an input stream. sub1 indicates that verticies are numbered 1 to N instead of 0 to N-1.
-
Graph
load_graph_sym
(std::string filename, bool sub1 = false)¶ Load a graph with a specified filename.
Graphs¶
A simple, fast class for managing verticies (nodes) and edges.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2017
- Note
- Status: BETA
-
namespace
emp
If we are in emscripten, make sure to include the header.
This file contains extra analysis tools to use with systematics managers that have non-null DATA_TYPES.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
This file contains functions for adding additional data files to Worlds.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
-
class
Graph
¶ - #include <Graph.h>
A graph class that maintains a set of vertices (nodes) and edges (connecting pairs of nodes)
Subclassed by emp::WeightedGraph
Public Functions
-
Graph
(size_t num_nodes = 0)¶ Construct a new graph with the specified number of nodes.
-
~Graph
()¶
-
size_t
GetSize
() const¶ Get number of vertices in this graph.
-
size_t
GetEdgeCount
() const¶ Get the total number of edges in this graph.
-
void
Resize
(size_t new_size)¶ Change the number of vertices in this graph.
-
const BitVector &
GetEdgeSet
(size_t id) const¶ Get the set of nodes that a specified node is connected to.
-
size_t
GetDegree
(size_t id) const¶ Get the degree of a specified node.
-
size_t
GetMaskedDegree
(size_t id, const BitVector &mask) const¶ Get how many of a set of nodes that a specified node is connected to.
-
bool
HasEdge
(size_t from, size_t to) const¶ Determine if a specific edge is included in this graph.
-
void
AddEdge
(size_t from, size_t to)¶ Add a specified edge into this graph.
-
void
RemoveEdge
(size_t from, size_t to)¶ Remove a specified edge from this graph.
-
void
SetEdge
(size_t from, size_t to, bool val)¶ Set the status of a specified edge as to whether or not it should be in the graph.
-
bool
HasEdgePair
(size_t from, size_t to) const¶ Determine if edges exist in both directions between a pair of vertices.
-
void
AddEdgePair
(size_t from, size_t to)¶ Add a pair of edges between two vertieces (in both directions)
-
void
RemoveEdgePair
(size_t from, size_t to)¶ Remove edges in both directions between a pair of vertices.
-
void
SetEdgePairs
(size_t from, size_t to, bool val)¶ Set the status as to whether a pair of edges (in both direction) exist.
-
class
Node
¶ - #include <Graph.h>
Information about nodes within a graph.
Public Functions
-
Node
(size_t num_nodes)¶ What other node IDs is this one connected to?
-
~Node
()¶
-
bool
HasEdge
(size_t to) const¶ Is this node connect to a specific other node?
-
void
AddEdge
(size_t to)¶ Add a connection between this node and another.
-
void
RemoveEdge
(size_t to)¶ Remove the connection (if there is one) between this node and another one.
-
void
SetEdge
(size_t to, bool val)¶ Set whether a connection to another specific node should exist or not.
-
const BitVector &
GetEdgeSet
() const¶ Get a BitVector representing which nodes this one is connected to.
-
void
Resize
(size_t new_size)¶ Change the number of potential node connections that we are tracking.
-
void
Clear
()¶ Remove all edges from this node.
-
size_t
GetDegree
() const¶ Identify how many other nodes this one is connected to.
-
-
-
class
WeightedGraph
: public emp::Graph¶ - #include <Graph.h>
Public Functions
-
WeightedGraph
(size_t num_nodes = 0)¶
-
WeightedGraph
(const WeightedGraph&)¶ Copy constructor.
-
WeightedGraph
(WeightedGraph&&)¶ Move constructor.
-
~WeightedGraph
()¶
-
WeightedGraph &
operator=
(const WeightedGraph&)¶ Copy operator.
-
WeightedGraph &
operator=
(WeightedGraph&&)¶ Move operator.
-
void
Resize
(size_t new_size)¶
-
double
GetWeight
(size_t from, size_t to) const¶ Determine weight of a specific edge in this graph.
-
void
AddEdge
(size_t from, size_t to, double weight)¶ When Adding an edge, must also provide a weight.
-
void
AddEdgePair
(size_t from, size_t to, double weight)¶ When Adding an edge pair, must also provide a weight.
-
void
Merge
(const WeightedGraph &in_graph)¶ Merge two WeightedGraphs into one.
-
void
PrintSym
(std::ostream &os = std::cout)¶ Print a symmetric graph to the provided output stream (defaulting to standard out)
-
void
PrintDirected
(std::ostream &os = std::cout)¶ Print a directed graph to the provided output stream (defaulting to standard out)
-
size_t
GetSize
() const¶ Get number of vertices in this graph.
-
size_t
GetEdgeCount
() const¶ Get the total number of edges in this graph.
-
const BitVector &
GetEdgeSet
(size_t id) const¶ Get the set of nodes that a specified node is connected to.
-
size_t
GetDegree
(size_t id) const¶ Get the degree of a specified node.
-
size_t
GetMaskedDegree
(size_t id, const BitVector &mask) const¶ Get how many of a set of nodes that a specified node is connected to.
-
bool
HasEdge
(size_t from, size_t to) const¶ Determine if a specific edge is included in this graph.
-
void
AddEdge
(size_t from, size_t to)¶ Add a specified edge into this graph.
-
void
RemoveEdge
(size_t from, size_t to)¶ Remove a specified edge from this graph.
-
void
SetEdge
(size_t from, size_t to, bool val)¶ Set the status of a specified edge as to whether or not it should be in the graph.
-
bool
HasEdgePair
(size_t from, size_t to) const¶ Determine if edges exist in both directions between a pair of vertices.
-
void
AddEdgePair
(size_t from, size_t to)¶ Add a pair of edges between two vertieces (in both directions)
-
void
RemoveEdgePair
(size_t from, size_t to)¶ Remove edges in both directions between a pair of vertices.
-
void
SetEdgePairs
(size_t from, size_t to, bool val)¶ Set the status as to whether a pair of edges (in both direction) exist.
-
Grids¶
-
namespace
emp
If we are in emscripten, make sure to include the header.
This file contains extra analysis tools to use with systematics managers that have non-null DATA_TYPES.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
This file contains functions for adding additional data files to Worlds.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
-
namespace
Grid
¶ -
template <typename CELL_TYPE = int, typename EDGE_TYPE = void, class POINT_TYPE = void>
classBoard
¶ - #include <grid.h>
Public Functions
-
CELL_TYPE
GetCellValue
(int id) const¶
-
EDGE_TYPE
GetEdgeHValue
(int id) const¶
-
EDGE_TYPE
GetEdgeVValue
(int id) const¶
-
POINT_TYPE
GetPointValue
(int id) const¶
-
void
SetCellValue
(int id, CELL_TYPE value)¶
-
void
SetEdgeHValue
(int id, EDGE_TYPE value)¶
-
void
SetEdgeVValue
(int id, EDGE_TYPE value)¶
-
void
SetPointValue
(int id, POINT_TYPE value)¶
-
CELL_TYPE
-
template <typename CELL_TYPE>
classCell
¶ - #include <grid.h>
-
template <typename EDGE_TYPE>
classHEdge
¶ - #include <grid.h>
-
class
Layout
¶ - #include <grid.h>
Public Functions
-
Layout
(int w, int h)¶
-
~Layout
()¶
-
int
GetWidth
() const¶
-
int
GetHeight
() const¶
-
int
GetNumRegions
() const¶
-
int
GetX
(int id) const¶
-
int
GetY
(int id) const¶
-
int
GetID
(int x, int y) const¶
-
int
GetTopID
(int id) const¶
-
int
GetBottomID
(int id) const¶
-
int
GetLeftID
(int id) const¶
-
int
GetRightID
(int id) const¶
-
-
template <typename POINT_TYPE>
classPoint
¶ - #include <grid.h>
-
template <typename STATE_TYPE>
classStateSet
¶ - #include <grid.h>
-
template <>
template<>
classStateSet
<bool>¶ - #include <grid.h>
-
template <>
template<>
classStateSet
<void>¶ - #include <grid.h>
-
template <typename CELL_TYPE = int, typename EDGE_TYPE = void, class POINT_TYPE = void>
Index Map¶
A simple class to weight items differently within a container and return the correct index.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2015-2018
- Note
- Status: BETA
-
namespace
emp
If we are in emscripten, make sure to include the header.
This file contains extra analysis tools to use with systematics managers that have non-null DATA_TYPES.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
This file contains functions for adding additional data files to Worlds.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
-
class
IndexMap
¶ - #include <IndexMap.h>
A map of weighted indecies. If a random index is selected, the probability of an index being returned is directly proportional to its weight.
Public Functions
-
IndexMap
(size_t _items = 0)¶ Construct an IndexMap where num_items is the maximum number of items that can be placed into the data structure. All item weigths default to zero.
-
IndexMap
(size_t _items, double init_weight)¶
-
~IndexMap
()¶
-
size_t
GetSize
() const¶ How many indices are in this map?
-
double
GetWeight
() const¶ What is the total weight of all indices in this map?
-
double
RawWeight
(size_t id) const¶ What is the current weight of the specified index?
-
double
GetWeight
(size_t id) const¶
-
double
RawProb
(size_t id) const¶ What is the probability of the specified index being selected?
-
double
GetProb
(size_t id) const¶
-
void
Resize
(size_t new_size, double def_value = 0.0)¶ Change the number of indecies in the map.
-
size_t
size
() const¶ Standard library compatibility.
-
void
resize
(size_t new_size)¶ Standard library compatibility.
-
void
Clear
()¶ Reset all item weights to zero.
-
void
ResizeClear
(size_t new_size)¶ Change the size of this map AND change all weights to zero.
-
void
RawAdjust
(size_t id, const double new_weight)¶ Adjust the weight associated with a particular index in the map.
- Parameters
id
: is the identification number of the item whose weight is being adjusted.weight
: is the new weight for that entry.
-
void
Adjust
(size_t id, const double new_weight)¶
-
void
AdjustAll
(double new_weight)¶ Adjust all index weights to the set provided.
-
size_t
Index
(double index, size_t cur_id = 0) const¶ Determine the ID at the specified index position.
-
double
operator[]
(size_t id) const¶
-
IndexMap &
operator-=
(IndexMap &in_map)¶ Substract the weigthes from another index map from this one.
-
void
DeferRefresh
()¶ Indicate that we need to adjust weights before relying on them in the future; this will prevent refreshes from occuring immediately and is useful when many updates to weights are likely to be done before any are accessed again.
Private Functions
-
size_t
ParentID
(size_t id) const¶ Which ID is the parent of the ID provided?
-
size_t
LeftID
(size_t id) const¶ Which ID is the left child of the ID provided?
-
size_t
RightID
(size_t id) const¶ Which ID is the right child of the ID provided?
-
size_t
CalcZeroOffset
() const¶ Sift through the nodes to find the where index zero maps to.
-
size_t
ToInternalID
(size_t id) const¶
-
size_t
ToInternalID
(size_t id, size_t _items, size_t _offset) const¶
-
size_t
ToExternalID
(size_t id) const¶
-
void
ResolveRefresh
() const¶ Check if we need to do a refresh, and if so do it!
-
Information Theory Tools¶
-
namespace
emp
If we are in emscripten, make sure to include the header.
This file contains extra analysis tools to use with systematics managers that have non-null DATA_TYPES.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
This file contains functions for adding additional data files to Worlds.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
Functions
-
template <typename CONTAINER>
doubleEntropy
(const CONTAINER &weights)¶ Convert a vector of weights to probabilities and return the entropy of the system.
-
template <typename CONTAINER, typename WEIGHT_FUN>
doubleEntropy
(const CONTAINER &objs, WEIGHT_FUN fun, double total = 0.0)¶ Calculate the entropy in a container of arbitrary objects. Args are a container, a function to extract the weight of each member, and an (optional) total weight.
-
constexpr double
Entropy2
(const double p)¶ Calculate the entropy when their are two possibile states based on one state’s probability.
-
template <typename CONTAINER, typename CAT_FUN_X, typename CAT_FUN_Y, typename WEIGHT_FUN>
doubleEntropy
(const CONTAINER &objs, CAT_FUN_X funX, CAT_FUN_Y funY, WEIGHT_FUN funW)¶ Conitional Entropy: H(X|Y) Allow for entropy of arbitrary objects with a converter.
Lexer Utilities¶
A set of utilities to convert between NFAs and DFAs.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2016-2017
- Note
- Status: BETA
-
namespace
emp
If we are in emscripten, make sure to include the header.
This file contains extra analysis tools to use with systematics managers that have non-null DATA_TYPES.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
This file contains functions for adding additional data files to Worlds.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
Functions
-
static const DFA &
to_DFA
(const DFA &dfa)¶ Converting DFA to DFA no change needed.
-
static const NFA &
to_NFA
(const NFA &nfa)¶ Converting NFA to MFA no change needed.
-
static DFA
to_DFA
(const NFA &nfa, int keep_invalid = false)¶ Systematic conversion of NFA to DFA…
-
static NFA
to_NFA
(const DFA &dfa)¶ Systematic up-conversion of DFA to NFA…
-
template <typename T1>
static NFAMergeNFA
(T1 &&in)¶ Merge multiple automata into one NFA (base case, single converstion)
-
template <typename T1, typename T2, typename... Ts>
static NFAMergeNFA
(T1 &&in1, T2 &&in2, Ts&&... others)¶ Merge multiple automata (DFA, NFA, RegEx) into one NFA.
-
struct
DFAStatus
¶ - #include <lexer_utils.h>
Structure to track the current status of a DFA.
Lexer¶
A general-purpose, fast lexer.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2016-2017
- Note
- Status: BETA
-
namespace
emp
If we are in emscripten, make sure to include the header.
This file contains extra analysis tools to use with systematics managers that have non-null DATA_TYPES.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
This file contains functions for adding additional data files to Worlds.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
-
class
Lexer
¶ - #include <Lexer.h>
A lexer with a set of token types (and associated regular expressions)
Public Functions
-
Lexer
()¶
-
~Lexer
()¶
-
size_t
AddToken
(const std::string &in_name, const std::string &in_regex)¶ Add a new token, specified by a name and the regex used to identify it.
-
size_t
GetTokenID
(const std::string &name) const¶ Get the ID associated with a token type (you provide the token name)
-
std::string
GetTokenName
(size_t id) const¶ Get the name associated with a token type (you provide the ID)
-
TokenInfo
GetTokenInfo
(const std::string &name) const¶ Get the full information about a token (you provide the name)
-
void
Generate
() const¶ Create the NFA that will identify the current set of tokens in a sequence.
Public Static Functions
-
static bool
TokenOK
(size_t id)¶
-
static constexpr size_t
MaxTokenID
()¶ How many total token types are allowed in this lexer?
-
-
struct
Token
¶ - #include <Lexer.h>
Information about a token instance from an input stream.
Public Functions
Map Utilities¶
A set of simple functions to manipulate maps.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2016-2017
- Note
- Status: BETA
-
namespace
emp
If we are in emscripten, make sure to include the header.
This file contains extra analysis tools to use with systematics managers that have non-null DATA_TYPES.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
This file contains functions for adding additional data files to Worlds.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
Functions
-
template <class MAP_T, class KEY_T>
boolHas
(const MAP_T &in_map, const KEY_T &key)¶ Take any map type, and run find to determine if a key is present.
-
template <class MAP_T, class KEY_T>
autoFind
(const MAP_T &in_map, const KEY_T &key, const typename MAP_T::mapped_type &dval)¶ Take any map, run find() member function, and return the result found (or default value if no results found).
-
template <class MAP_T, class KEY_T>
const auto &FindRef
(const MAP_T &in_map, const KEY_T &key, const typename MAP_T::mapped_type &dval)¶ Take any map and element, run find() member function, and return a reference to the result found (or default value if no results found).
Math¶
Useful mathematical functions (that are constexpr when possible.)
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2016-2018
- Note
- Status: BETA (though new functions are added frequently)
-
namespace
emp
If we are in emscripten, make sure to include the header.
This file contains extra analysis tools to use with systematics managers that have non-null DATA_TYPES.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
This file contains functions for adding additional data files to Worlds.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
Functions
-
constexpr int
Mod
(int in_val, int mod_val)¶ % is actually remainder; Mod is a proper modulus command that handles negative #’s correctly
-
double
Mod
(double in_val, double mod_val)¶ Regular Mod doesn’t work on doubles. Build one that does!
-
template <typename T>
constexpr TAbs
(T in)¶ Find the absolute value for any variable.
-
template <typename TYPE>
constexpr TYPEToRange
(const TYPE &value, const TYPE &in_min, const TYPE &in_max)¶ Run both min and max on a value to put it into a desired range.
-
template <typename T>
constexpr TMin
(T in1)¶ Min of only one element is that element itself!
-
template <typename T, typename... Ts>
constexpr TMin
(T in1, T in2, Ts... extras)¶ Min of multiple elements is solved recursively.
-
template <typename T>
constexpr TMax
(T in1)¶ Max of only one element is that element itself!
-
template <typename T, typename... Ts>
constexpr TMax
(T in1, T in2, Ts... extras)¶ Max of multiple elements is solved recursively.
-
template <typename T>
constexpr const T &MinRef
(const T &in1)¶ MinRef works like Min, but never copies any inputs; always treats as references. MinRef of only one element returns reference to that element itself!
-
template <typename T, typename... Ts>
constexpr const T &MinRef
(const T &in1, const T &in2, const Ts&... extras)¶ MinRef of multiple elements returns reference to minimum value.
-
template <typename T>
constexpr const T &MaxRef
(const T &in1)¶ MaxRef works like Max, but never copies any inputs; always treats as references. MaxRef of only one element returns reference to that element itself!
-
template <typename T, typename... Ts>
constexpr const T &MaxRef
(const T &in1, const T &in2, const Ts&... extras)¶ MaxRef of multiple elements returns reference to maximum value.
-
static constexpr double
Log2
(double x)¶ Compile-time log base 2 calculator.
-
static constexpr double
Log
(double x, double base = 10.0)¶ Compile-time log calculator.
-
static constexpr double
Ln
(double x)¶ Compile-time natural log calculator.
-
static constexpr double
Log10
(double x)¶ Compile-time log base 10 calculator.
-
template <typename T>
static constexpr TSquare
(T val)¶ A simple function to square a value.
-
template <typename T>
static constexpr type_if<T, std::is_integral>Pow
(T base, T p)¶ A fast (O(log p)) integral-power command.
-
static constexpr double
Pow2
(double exp)¶ A fast 2^x command.
-
template <typename TYPE>
static constexpr TYPEIntPow
(TYPE base, TYPE exp)¶ A fast method for calculating exponents for int types.
-
static constexpr double
Pow
(double base, double exp)¶ A fast method for calculating exponents on doubles.
-
static constexpr double
Exp
(double exp)¶ A fast method of calculating e^x.
-
template <typename TYPE>
static constexpr intIntLog2
(TYPE x)¶ A compile-time int-log calculator (aka, significant bits)
-
template <typename TYPE>
static constexpr intCountOnes
(TYPE x)¶ A compile-time bit counter.
-
template <typename TYPE>
static constexpr TYPEMaskLow
(std::size_t num_bits)¶ Quick bit-mask generator for low bits.
-
template <typename TYPE>
static constexpr TYPEMaskHigh
(std::size_t num_bits)¶ Quick bit-mask generator for high bits.
-
template <typename T>
constexpr const T &Min
(const T &in1, const T &in2, const T &in3)¶ Return the minimum of three values.
-
namespace
internal
¶
Memory Tracking¶
A set of macros to track how many instances of specific classes are made.
One way of tracking memory leaks is to simply count instances of classes. The macros here simplify this process.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2015-2017
- Note
- Status: BETA
To setup, every constructor for a class must incude EMP_TRACK_CONSTRUCT(CLASS_NAME), and every destructor must have EMP_TRACK_DESTRUCT(CLASS_NAME). Make sure to avoid implicit constructors/destructors or counts will be off.
To collect information, EMP_TRACK_COUNT(CLASS_NAME) will provide the current count for a specific class, and EMP_TRACK_STATUS will translate into a string providing information about all available classes.
Developer notes:
-
namespace
emp
If we are in emscripten, make sure to include the header.
This file contains extra analysis tools to use with systematics managers that have non-null DATA_TYPES.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
This file contains functions for adding additional data files to Worlds.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
-
namespace
internal
¶
Memoized Functions¶
Warning
doxygenfile: Cannot find file “tools/memo_functions.h
Non-Deterministic Finite Automata¶
A Non-deterministic Finite Automata simulator.
To build a standard NFA, use
emp::NFA. If you want to have more symbols or more stop states, use emp::tNFA<S,T> where S is the number of symbols and T is the type used for stop. (defaults are 128 for ASCII-128 and uint8_t respectively.)- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2016-2017
- Note
- Status: BETA
The constructor can take as parameters the number of states and the id of the start state (both default to 0)
- Note
- DFA’s use SetTransition(), but NFA’s use AddTransition. This distinction is intentional since in a DFA a second SetTransition with the same start state and symbol will override first, while in an NFA a second AddTransition will always add a new option.
-
namespace
emp
If we are in emscripten, make sure to include the header.
This file contains extra analysis tools to use with systematics managers that have non-null DATA_TYPES.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
This file contains functions for adding additional data files to Worlds.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
Typedefs
-
using
emp::NFA = typedef tNFA<128, uint8_t>
NFA is the most standard tNFA setup.
-
using
emp::NFA_State = typedef tNFA_State<128, uint8_t>
NFA_State is the most standard tNFA_State setup.
-
template <size_t S = 128, typename STOP_TYPE = uint8_t>
classtNFA
¶ - #include <NFA.h>
A dynamic NFA class, for easily building non-determanistic finite automata.
Public Functions
-
tNFA
(size_t num_states = 1, size_t start_state = 0)¶
-
~tNFA
()¶
-
size_t
GetSize
() const¶ Return the current number of states.
-
const std::set<size_t> &
GetStart
() const¶ Return start state and all others reachable through empty transitions.
-
std::set<size_t>
GetNext
(size_t sym, size_t from_id = 0) const¶ Return the states reachable from the current state given the provided symbol.
-
std::set<size_t>
GetNext
(size_t sym, const std::set<size_t> from_set) const¶ return the states reachable from the current set of states given the provided symbol.
-
bool
HasFreeTransitions
(size_t id) const¶ Does the provided state have free transitions?
-
bool
HasSymTransitions
(size_t id) const¶ Does the provided state have symbol-transitions?
-
opts_t
GetSymbolOptions
(const std::set<size_t> &test_set) const¶ Return an emp::BitSet indicating the symbols available from the provided set of states.
-
void
Resize
(size_t new_size)¶ Change the number of available states.
-
size_t
AddNewState
()¶ Add a new state into the NFA and return its id.
-
void
AddTransition
(size_t from, size_t to, size_t sym)¶ Add a transition between states ‘from’ and ‘to’ that can be taken with the provided symbol.
-
void
AddTransition
(size_t from, size_t to, const std::string &sym_set)¶ Add a transition between states ‘from’ and ‘to’ that can be taken with the provided symbols.
-
void
AddTransition
(size_t from, size_t to, const BitSet<NUM_SYMBOLS> &sym_set)¶ Add a transition between states ‘from’ and ‘to’ that can be taken with the provided symbols.
-
void
AddFreeTransition
(size_t from, size_t to)¶ Create a free transition between ‘from’ and ‘to’.
-
template <typename T = stop_t>
voidSetStop
(size_t state, T stop_val = 1)¶ Set the specified state to be a stop state (with an optional stop value.)
-
stop_t
GetStop
(size_t state) const¶ Get any stop value associated with the provided state.
-
bool
IsStart
(size_t state) const¶ Test if NFA begins at provided state (may have free transitions to other states)
-
bool
IsStop
(size_t state) const¶ Test if this state is a legal endpoint for the NFA.
-
bool
IsEmpty
(size_t state) const¶ Test if this state has only empty transitions from it, and not stop state.
-
void
Merge
(const tNFA<NUM_SYMBOLS, STOP_TYPE> &nfa2)¶ Merge another NFA into this one.
-
void
Print
() const¶ Print information about this NFA (for debugging)
-
void
PrintFreeMoves
()¶ Identify free moves in NFA (for debugging)
Public Static Attributes
-
constexpr const size_t
NUM_SYMBOLS
= S¶
Private Members
-
size_t
start
¶ Main start state (others might be reached for free.)
-
-
template <size_t NUM_SYMBOLS = 128, typename STOP_TYPE = uint8_t>
classtNFA_State
¶ - #include <NFA.h>
Information about the current full state (i.e., set of legal states) of an NFA.
Public Functions
-
~tNFA_State
()¶
-
bool
IsActive
() const¶ Are there currently any legal NFA states?
-
bool
IsStop
() const¶ Can we legally stop in any of the current states?
-
bool
HasState
(size_t id)¶ Is a particular NFA state currently included?
-
size_t
GetSize
()¶ How many states are currently included?
-
void
Reset
()¶ Change current states to start + free transitions from start.
-
void
Next
(size_t sym)¶ Update states given a new input symbol.
-
void
Next
(const std::string &sym_set)¶ Update states given a new series of input symbols (as a string)
-
void
Print
()¶ Print out current information about this NFA State (for debugging)
-
Parser¶
A general-purpose, fast parser.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2016-2017
- Note
- Status: DEVELOPMENT
-
namespace
emp
If we are in emscripten, make sure to include the header.
This file contains extra analysis tools to use with systematics managers that have non-null DATA_TYPES.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
This file contains functions for adding additional data files to Worlds.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
-
class
Parser
¶ - #include <Parser.h>
Full information about a parser, including a lexer, symbols, and rules.
Public Functions
-
~Parser
()¶
-
size_t
GetID
(size_t id) const¶ Trivial conversions of ID to ID…
-
ParseSymbol &
GetParseSymbol
(const std::string &name)¶ Get the parser symbol information associated with a provided name.
-
template <typename... STATES>
Parser &Rule
(STATES... states)¶ Use the currently active symbol and attach a rule to it.
-
template <typename... STATES>
size_tAddRule
(const std::string &name, STATES&&... states)¶ Specify the name of the symbol and add a rule to it, returning the symbol id.
Private Functions
-
template <typename T, typename... EXTRAS>
voidBuildRule
(emp::vector<size_t> &new_pattern, T &&arg, EXTRAS&&... extras)¶
-
int
GetSymbolPos
(const std::string &name) const¶ Return the position in the symbols vector where this name is found; else return -1.
-
int
GetIDPos
(size_t id) const¶ Convert a symbol ID into its position in the symbols[] vector.
Private Members
-
emp::vector<ParseSymbol>
symbols
¶ Set of symbols that make up this grammar.
-
size_t
cur_symbol_id
¶ Which id should the next new symbol get?
-
int
active_pos
¶ Which symbol pos is active?
-
Random-Access Set¶
This file defines a Random Access Set template.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2017
- Note
- Status: ALPHA
-
namespace
emp
If we are in emscripten, make sure to include the header.
This file contains extra analysis tools to use with systematics managers that have non-null DATA_TYPES.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
This file contains functions for adding additional data files to Worlds.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
-
template <typename T>
classra_set
¶ - #include <ra_set.h>
This class uses a combination of a hashtable (std::unordered_map) and emp::vector to lookup insert, lookup, and delete values in constant time, while still being able to step through all values (albeit in an arbitrary order).
- Note
- The arbitrary order of values may change if any values are deleted.
Public Types
-
template<>
usingvalue_type
= T¶
Public Functions
-
ra_set
()¶
-
size_t
size
() const¶ How many elements are in this set?
-
void
clear
()¶ Remove all values from this container.
-
void
insert
(const T &v)¶ Insert a new value into container.
-
bool
erase
(const T &v)¶ Erase a specific value from the container.
-
size_t
count
(const T &v) const¶ Count the number of times a particular value in in the container (0 or 1).
Randomness Utilites¶
Helper functions for emp::Random for common random tasks.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2016-2017
- Note
- Status: RELEASE
-
namespace
emp
If we are in emscripten, make sure to include the header.
This file contains extra analysis tools to use with systematics managers that have non-null DATA_TYPES.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
This file contains functions for adding additional data files to Worlds.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
Functions
-
template <typename T>
voidShuffle
(Random &random, emp::vector<T> &v, size_t max_count)¶ Randomly reorder all of the elements in a vector. If max_count is provided, just make sure that the first max_count entries are randomly drawn from entire vector.
-
emp::vector<size_t>
GetPermutation
(Random &random, size_t size)¶ Return an emp::vector<int> numbered 0 through size-1 in a random order.
-
void
Choose
(Random &random, size_t N, size_t K, std::vector<size_t> &choices)¶ Choose K positions from N possibilities.
-
BitVector
RandomBitVector
(Random &random, size_t size, double p = 0.5)¶ Generate a random BitVector of the specified size.
-
emp::vector<double>
RandomDoubleVector
(Random &random, size_t size, double min, double max)¶ Generate a random double vector in the specified range.
-
emp::vector<size_t>
RandomUIntVector
(Random &random, size_t size, size_t min, size_t max)¶ Generate a random size_t vector in the specified range.
-
template <typename T>
emp::vector<T>RandomVector
(Random &random, size_t size, T min, T max)¶ Generate a random vector in the specified type and range.
Random Number Generator¶
A versatile and non-patterned pseudo-random-number generator.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2015-2018
- Note
- Status: RELEASE
-
namespace
emp
If we are in emscripten, make sure to include the header.
This file contains extra analysis tools to use with systematics managers that have non-null DATA_TYPES.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
This file contains functions for adding additional data files to Worlds.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
Range¶
A simple way to track value ranges.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2016-2018
- Note
- Status: BETA
-
namespace
emp
If we are in emscripten, make sure to include the header.
This file contains extra analysis tools to use with systematics managers that have non-null DATA_TYPES.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
This file contains functions for adding additional data files to Worlds.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
Functions
-
template <typename T>
classRange
¶ - #include <Range.h>
A range of values from a lower limit to and upper limit, of any provided type.
Public Functions
-
Range
()¶
-
Range
(T _l, T _u)¶
-
T
GetLower
() const¶
-
T
GetUpper
() const¶
-
size_t
CalcBin
(T value, size_t num_bins) const¶
-
void
SetLower
(T l)¶
-
void
SetUpper
(T u)¶
-
void
Set
(T _l, T _u)¶
-
void
SetMaxLower
()¶
-
void
SetMaxUpper
()¶
-
bool
Valid
(T value) const¶ Determine if a provided value is in the range.
-
T
Limit
(T _in) const¶ Force a value into range.
-
Regular Expressions¶
Basic regular expression handler.
A fully (well, mostly) functional regular expression processor.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2016-2017
- Note
- Status: BETA
Special chars: ‘|’ - or ‘*’ - zero or more of previous ‘+’ - one or more of previous ‘?’ - previous is optional ‘.’ - Match any character except
Pluse the following group contents (and change may translation rules) ‘(‘ and ‘)’ - group contents ‘”’ - Ignore special characters in contents (quotes still need to be escaped) ‘[‘ and ‘]’ - character set
choose ONE character ^ as first char negates contents ; - indicates range UNLESS first or last.Additional overloads for functions in lexer_utils.h:
static NFA to_NFA(const RegEx & regex, int stop_id=1); static DFA to_DFA(const RegEx & regex);
-
namespace
emp
If we are in emscripten, make sure to include the header.
This file contains extra analysis tools to use with systematics managers that have non-null DATA_TYPES.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
This file contains functions for adding additional data files to Worlds.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
Functions
-
class
RegEx
¶ - #include <RegEx.h>
A basic regular expression handler.
Public Functions
-
RegEx
()¶
-
~RegEx
()¶
-
std::string
AsString
() const¶ Convert the RegEx to an standard string, readable from outsite this class.
-
void
AddToNFA
(NFA &nfa, size_t start, size_t stop) const¶ Add this regex to an NFA being built.
-
void
PrintInternal
()¶ For debugging: print the internal representation of the regex.
-
void
PrintNotes
()¶ For debugging: print any internal notes generated about this regex.
-
void
PrintDebug
()¶ Print general debuging information about this regex.
Private Types
-
using
opts_t
= BitSet<NUM_SYMBOLS>¶
Private Functions
-
template <typename... T>
voidError
(T&&... args)¶
-
bool
EnsureNext
(char x)¶ Make sure that there is another element in the RegEx (e.g., after an ‘|’) or else trigger and error to report the problem.
-
Ptr<re_charset>
ConstructSet
()¶ Construct a character range.
Private Members
-
bool
valid
¶ Set to false if regex cannot be processed.
-
size_t
pos
¶ Position being read in regex.
-
bool
dfa_ready
¶ Is the dfa ready? (or does it need to be generated?)
Private Static Attributes
-
struct
re_base
¶ Internal base representation of a portion of a regex.
-
struct
re_parent
: public emp::RegEx::re_base¶ Intermediate base class for RegEx components that have children (such as “and” and “or”)
Public Functions
-
re_parent
()¶
-
~re_parent
()¶
-
void
Clear
()
-
virtual void
push
(Ptr<re_base> x)
-
Ptr<re_base>
pop
()
-
size_t
GetSize
() const
-
Ptr<re_parent>
AsParent
()
-
bool
Simplify
()¶
-
virtual Ptr<re_block>
AsBlock
()
-
virtual Ptr<re_charset>
AsCharSet
()
-
virtual Ptr<re_string>
AsString
()
-
virtual void
AddToNFA
(NFA &nfa, size_t start, size_t stop) const¶
-
-
struct
re_plus
: public emp::RegEx::re_parent¶ Representations of one-or-more instances of a component. e.g., a+.
Public Functions
-
virtual void
AddToNFA
(NFA &nfa, size_t start, size_t stop) const¶
-
void
Clear
()
-
virtual void
push
(Ptr<re_base> x)
-
Ptr<re_base>
pop
()
-
size_t
GetSize
() const
-
Ptr<re_parent>
AsParent
()
-
bool
Simplify
()
-
virtual Ptr<re_block>
AsBlock
()
-
virtual Ptr<re_charset>
AsCharSet
()
-
virtual Ptr<re_string>
AsString
()
-
virtual void
-
struct
re_qm
: public emp::RegEx::re_parent¶ Representations of zero-or-one instances of a component. e.g., a?
Public Functions
-
virtual void
AddToNFA
(NFA &nfa, size_t start, size_t stop) const¶
-
void
Clear
()
-
virtual void
push
(Ptr<re_base> x)
-
Ptr<re_base>
pop
()
-
size_t
GetSize
() const
-
Ptr<re_parent>
AsParent
()
-
bool
Simplify
()
-
virtual Ptr<re_block>
AsBlock
()
-
virtual Ptr<re_charset>
AsCharSet
()
-
virtual Ptr<re_string>
AsString
()
-
virtual void
-
struct
re_star
: public emp::RegEx::re_parent¶ Representations of zero-or-more instances of a component. e.g., a*.
Public Functions
-
virtual void
AddToNFA
(NFA &nfa, size_t start, size_t stop) const¶
-
void
Clear
()
-
virtual void
push
(Ptr<re_base> x)
-
Ptr<re_base>
pop
()
-
size_t
GetSize
() const
-
Ptr<re_parent>
AsParent
()
-
bool
Simplify
()
-
virtual Ptr<re_block>
AsBlock
()
-
virtual Ptr<re_charset>
AsCharSet
()
-
virtual Ptr<re_string>
AsString
()
-
virtual void
-
Sequence Utilities¶
Functions for analyzing with generic sequence types.
A set of functions for analyzing sequences, including distance metrics (Hamming and Edit/Levenschtein) and alignment.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2016-2017
- Note
- Status: BETA
-
namespace
emp
If we are in emscripten, make sure to include the header.
This file contains extra analysis tools to use with systematics managers that have non-null DATA_TYPES.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
This file contains functions for adding additional data files to Worlds.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
Functions
-
template <typename TYPE>
size_tcalc_hamming_distance
(const TYPE &in1, const TYPE &in2, int offset = 0)¶ Hamming distance is a simple count of substitutions needed to convert one array to another.
- Parameters
in1
: The first sequence to compare.in2
: The second sequence to compare.offset
: (optional) Position in the first sequence to start the second sequence.
-
template <typename TYPE>
size_tcalc_edit_distance
(const TYPE &in1, const TYPE &in2)¶ Edit distance is the minimum number of insertions, deletions and substitutions to convert one array to another.
-
template <typename TYPE, typename GAP_TYPE>
size_talign
(TYPE &in1, TYPE &in2, GAP_TYPE gap)¶ Use edit distance to find the minimum number of insertions, deletions and substitutions to convert one array to another, and then insert gaps into the arrays appropriately.
Serialization Macros¶
Macros for simplifying to serialization of objects.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2015-2017
- Note
- Status: ALPHA
Serialization Tools¶
Tools to save and load data from classes.
All of the important information about a class is stored in a DataPod, which can be used to restore the class at a later time.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2015-2017
- Note
- Status: ALPHA
Why is this better than other serialization techniques?
- Only one line of code is added to a custom class to make it serializable.
- Serialized objects do not need a default constructor (a DataPod constructor is added)
- Serialized objects can be const since they get rebuilt during construction.
- Synergistic interactions with other EMP classes, such as config and tuple_struct
In order to setup a target class to be able to be serialized into a pod, you must add a macro to include the needed functionality. For a basic class, use:
EMP_SETUP_DATAPOD(ClassName, var1, var2, …)
Where ClassName is the target class’ name and var1, var2, etc are the names of the member variables that also need to be stored. Note that member variables can either be either built-in types or custom types that have also had DataPods setup in them.
If the target class is a derived class, you must use either:
EMP_SETUP_DATAPOD_D(ClassName, BassClassName, var1, var2, …)
-or-
EMP_SETUP_DATAPOD_D2(ClassName, BassClass1Name, BaseClass2Name, var1, var2, …)
…depending on how many base classes it was derived from (currently max 2).
Note also that this macro must either go in the public section of the target class definition, or the target class must be made a friend to the emp::serialize::DataPod class.
-
namespace
emp
If we are in emscripten, make sure to include the header.
This file contains extra analysis tools to use with systematics managers that have non-null DATA_TYPES.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
This file contains functions for adding additional data files to Worlds.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
-
namespace
serialize
¶ Functions
-
template <typename T>
autoStoreVar
(DataPod &pod, const T &var, bool)¶ StoreVar() takes a DataPod and a variable and stores that variable to the pod. The third argument (bool vs. int) will receive a bool, and thus bool versions are preferred in the case of a tie. Specialized versions of this function can be included elsewhere, as needed, and should take a bool as the third argument.
-
template <typename T>
Set Utilities¶
Tools to save and load data from classes.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2016-2018
- Note
- Status: ALPHA
-
namespace
emp
If we are in emscripten, make sure to include the header.
This file contains extra analysis tools to use with systematics managers that have non-null DATA_TYPES.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
This file contains functions for adding additional data files to Worlds.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
Functions
-
template <typename T>
voidinsert
(std::set<T> &s1, const std::set<T> &s2)¶ Insert the full contents of s2 into s1.
-
template <typename T, typename H>
boolHas
(const std::set<T, H> &s, const T &val)¶ Test if an std::set has a particular element without modifying the set in any way.
-
template <typename T, typename H>
boolHas
(const std::multiset<T, H> &s, const T &val)¶ Test if an std::multiset has a particular element without modifying the set in any way.
-
template <typename T, typename H>
boolHas
(const std::unordered_set<T, H> &s, const T &val)¶ Test if an std::unordered_set has a particular element without modifying the set in any way.
-
template <typename T, typename H>
boolHas
(const std::unordered_multiset<T, H> &s, const T &val)¶ Test if an std::unordere_multiset has a particular element without modifying the set in any way.
-
template <typename T>
std::set<T>difference
(std::set<T> &s1, std::set<T> &s2)¶ Compute the set difference of.
- Parameters
s1
: ands2
: (elements that are in S1 but no S2)
-
template <typename T>
std::set<T>difference
(emp::vector<T> s1, emp::vector<T> &s2)¶ Compute the set difference of.
- Parameters
s1
: ands2
: (elements that are in S1 but no S2)
-
template <typename T>
std::set<T>difference
(std::set<T> &s1, emp::vector<T> s2)¶ Compute the set difference of.
- Parameters
s1
: ands2
: (elements that are in S1 but not S2)
-
template <typename T>
std::set<T>difference
(emp::vector<T> s1, std::set<T> &s2)¶ Compute the set difference of.
- Parameters
s1
: ands2
: (elements that are in S1 but no S2)
-
template <typename T>
std::set<T>intersection
(std::set<T> s1, std::set<T> s2)¶ Compute the set intersection of.
- Parameters
s1
: ands2
: (elements that are in both S1 and S2)
-
template <typename T>
std::set<T>intersection
(emp::vector<T> s1, emp::vector<T> s2)¶ Compute the set intersection of.
- Parameters
s1
: ands2
: (elements that are in both S1 and S2)
-
template <typename T>
std::set<T>intersection
(std::set<T> s1, emp::vector<T> s2)¶ Compute the set intersection of.
- Parameters
s1
: ands2
: (elements that are in both S1 and S2)
-
template <typename T>
std::set<T>intersection
(emp::vector<T> s1, std::set<T> s2)¶ Compute the set intersection of.
- Parameters
s1
: ands2
: (elements that are in both S1 and S2)
-
template <typename T>
std::set<T>set_union
(std::set<T> s1, std::set<T> s2)¶ Compute the set union of.
- Parameters
s1
: ands2
: (elements that are in either S1 or S2)
-
template <typename T>
std::set<T>set_union
(emp::vector<T> s1, emp::vector<T> s2)¶ Compute the set union of.
- Parameters
s1
: ands2
: (elements that are in either S1 or S2)
-
template <typename T>
std::set<T>set_union
(std::set<T> s1, emp::vector<T> s2)¶ Compute the set union of.
- Parameters
s1
: ands2
: (elements that are in either S1 or S2)
-
template <typename T>
std::set<T>set_union
(emp::vector<T> s1, std::set<T> s2)¶ Compute the set union of.
- Parameters
s1
: ands2
: (elements that are in either S1 or S2)
-
template <typename T>
std::set<T>symmetric_difference
(std::set<T> s1, std::set<T> s2)¶ Compute the set symmetric_difference of.
- Parameters
s1
: ands2
: (elements that are in either S1 or S2 but not both)
-
template <typename T>
std::set<T>symmetric_difference
(emp::vector<T> s1, emp::vector<T> s2)¶ Compute the set symmetric_difference of.
- Parameters
s1
: ands2
: (elements that are in either S1 or S2 but not both)
Branch and Bound Solution States¶
Used as part of a branching solver to keep track of the current state.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2016-2017
- Note
- Status: BETA
-
namespace
emp
If we are in emscripten, make sure to include the header.
This file contains extra analysis tools to use with systematics managers that have non-null DATA_TYPES.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
This file contains functions for adding additional data files to Worlds.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
-
class
SolveState
¶ - #include <SolveState.h>
Often in a branch-and-bound algorithm, we need to identify the sub-set of items that maximizes (or minimizes) an optimization metric. SolveState keeps track of the current state for which items have been locked in as “included” in the current branks, which have been “excluded”, and which are still “unknown” (still to be decided upon.) All tracking is performed with BitVectors for high efficiency.
Public Functions
-
SolveState
(size_t state_size = 0)¶
-
SolveState
(const SolveState &in)¶
-
~SolveState
()¶
-
SolveState &
operator=
(const SolveState &in)¶ Set this SolveState to be identical to another.
-
size_t
GetSize
() const¶ How many items are being considered in the current SolveState?
-
bool
IsIn
(size_t id) const¶ Test if a particular item is going to be included for sure in the current solve state. (If it has been excluded -OR- is yet to be decided upon, false will be returned)
-
bool
IsUnk
(size_t id) const¶ Test if a particular item is yet to be decided upon in the current solve state. (If it has been excluded -OR- is included for sure, false will be returned)
-
bool
IsOut
(size_t id) const¶ Test if a particular item is going to be excluded for sure in the current solve state. (If it has been included -OR- is yet to be decided upon, false will be returned)
-
bool
IsFinal
() const¶ Test if all items have been decided upon (none are still in the “unknown” state)
-
size_t
CountIn
() const¶ How many items have been included for sure?
-
size_t
CountUnk
() const¶ How many items have yet to be decided upon (are “unknown”)
-
size_t
CountOut
() const¶ How many items have been excluded for sure.
-
const BitVector &
GetInVector
() const¶ Get the BitVector associated with which items have been included for sure.
-
const BitVector &
GetUnkVector
() const¶ Get the BitVector associated with which items have yet to be decided upon.
-
BitVector
GetOutVector
() const¶ Get the BitVector associated with which iterm have been excluded for sure.
-
int
GetNextUnk
(size_t prev_unk) const¶ Get the ID of the next unknown item.
-
void
Include
(size_t id)¶ Mark a specific item as to be included.
-
void
Exclude
(size_t id)¶ Mark a specific item as to be excluded.
-
void
ForceExclude
(size_t id)¶ Change our mind about a potentially included node (Be careful since many algorithms don’t requite this type of changes to be made.)
-
Statistics Tools¶
Functions for calculating various statistics about an ensemble.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2016-2017
- Note
- Status: BETA
-
namespace
emp
If we are in emscripten, make sure to include the header.
This file contains extra analysis tools to use with systematics managers that have non-null DATA_TYPES.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
This file contains functions for adding additional data files to Worlds.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
Functions
-
template <typename C>
std::enable_if<!emp::is_ptr_type<typename C::value_type>::value && std::is_scalar<typename C::value_type>::value, typename C::value_type>::typeSum
(C &elements)¶ Calculate sum of the members of the container passed Only works on containers with a scalar member type
-
template <typename C>
std::enable_if<emp::is_ptr_type<typename C::value_type>::value && std::is_scalar<typename emp::remove_ptr_type<typename C::value_type>::type >::value, typename emp::remove_ptr_type<typename C::value_type>::type>::typeSum
(C &elements)¶ Calculate sum of the values pointed at by pointers in a container Only works on containers of pointers to a scalar type
-
template <typename C>
std::enable_if<!emp::is_ptr_type<typename C::value_type>::value, double>::typeShannonEntropy
(C &elements)¶ Calculate Shannon Entropy of the members of the container passed.
-
template <typename C>
std::enable_if<emp::is_ptr_type<typename C::value_type>::value, double>::typeShannonEntropy
(C &elements)¶ Calculate Shannon Entropy of the members of the container when those members are pointers.
-
template <typename C>
std::enable_if<!emp::is_ptr_type<typename C::value_type>::value && std::is_scalar<typename C::value_type>::value, double>::typeVariance
(C &elements)¶ Calculate variance of the members of the container passed Only works on containers with a scalar member type
-
template <typename C>
std::enable_if<emp::is_ptr_type<typename C::value_type>::value && std::is_scalar<typename emp::remove_ptr_type<typename C::value_type>::type >::value, double>::typeVariance
(C &elements)¶ Calculate variance of the values pointed at by members of the container passed Only works on containers with a scalar member type
-
template <typename C>
emp::sfinae_decoy<double, typename C::value_type>Mean
(C &elements)¶ Calculate the mean of the values in a container If values are pointers, they will be automatically de-referenced Values must be numeric.
-
template <typename C>
emp::sfinae_decoy<double, typename C::value_type>StandardDeviation
(C &elements)¶ Calculate the standard deviation of the values in a container If values are pointers, they will be automatically de-referenced Values must be numeric.
-
template <typename C>
std::enable_if<!emp::is_ptr_type<typename C::value_type>::value, int>::typeUniqueCount
(C &elements)¶ Count the number of unique elements in a container.
-
template <typename C>
std::enable_if<emp::is_ptr_type<typename C::value_type>::value, int>::typeUniqueCount
(C &elements)¶ Count the number of unique elements in the container of pointers. (compares objects pointed to; pointers do not have to be identical)
-
template <typename C, typename RET_TYPE, typename ARG_TYPE>
RET_TYPEMaxResult
(std::function<RET_TYPE(ARG_TYPE)> &fun, C &elements, )¶ Run the provided function on every member of a container and return the MAXIMUM result.
-
template <typename C, typename RET_TYPE, typename ARG_TYPE>
RET_TYPEMinResult
(std::function<RET_TYPE(ARG_TYPE)> &fun, C &elements, )¶ Run the provided function on every member of a container and return the MINIMUM result.
-
template <typename C, typename RET_TYPE, typename ARG_TYPE>
std::enable_if<std::is_scalar<RET_TYPE>::value, double>::typeMeanResult
(std::function<RET_TYPE(ARG_TYPE)> &fun, C &elements, )¶ Run the provided function on every member of a container and return the AVERAGE result. Function must return a scalar (i.e. numeric) type.
String Utilities¶
Simple functions to manipulate strings.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2016-2018
- Note
- Status: RELEASE
-
namespace
emp
If we are in emscripten, make sure to include the header.
This file contains extra analysis tools to use with systematics managers that have non-null DATA_TYPES.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
This file contains functions for adding additional data files to Worlds.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
Functions
-
static const std::string &
empty_string
()¶ Return a const reference to an empty string. This function is useful to implement other functions that need to return a const reference for efficiency, but also need a null response.
-
static std::string
to_escaped_string
(char value)¶ Convert a single chararcter to one that uses a proper escape sequence (in a string) if needed.
-
static std::string
to_escaped_string
(const std::string &value)¶ Convert a full string to one that uses proper escape sequences, as needed.
-
template <typename LIT_TYPE>
std::stringto_literal
(const LIT_TYPE &value)¶ Take a value and convert it to a C++-style literal.
-
static std::string
to_literal
(const std::string &value)¶ Take a string and convert it to a C++-style literal.
-
bool
is_whitespace
(char test_char)¶ Determine if a character is whitespace.
-
bool
is_upper_letter
(char test_char)¶ Determine if a character is an uppercase letter.
-
bool
is_lower_letter
(char test_char)¶ Determine if a character is a lowercase letter.
-
bool
is_letter
(char test_char)¶ Determine if a character is a letter of any kind.
-
bool
is_digit
(char test_char)¶ Determine if a character is a digit.
-
bool
is_alphanumeric
(char test_char)¶ Determine if a character is a letter or digit.
-
bool
is_idchar
(char test_char)¶ Determine if a character is a letter, digit, or underscore.
-
static bool
is_one_of
(char test_char, const std::string &char_set)¶ Determine if a character is in a set of characters (represented as a string)
-
static bool
is_composed_of
(const std::string &test_str, const std::string &char_set)¶ Determine if a string is composed only of a set of characters (represented as a string)
-
bool
has_whitespace
(const std::string &test_str)¶ Determine if there is whitespace anywhere in a string.
-
bool
has_upper_letter
(const std::string &test_str)¶ Determine if there are any uppercase letters in a string.
-
bool
has_lower_letter
(const std::string &test_str)¶ Determine if there are any lowercase letters in a string.
-
bool
has_alphanumeric
(const std::string &test_str)¶ Determine if there are any letters or digits anywhere in a string.
-
bool
has_idchar
(const std::string &test_str)¶ Determine if there are any letters, digit, or underscores anywhere in a string.
-
static bool
has_one_of
(const std::string &test_str, const std::string &char_set)¶ Determine if a specified set of characters appears anywhere in a string.
-
bool
is_valid
(char test_char)¶ If no functions are provided to is_valid(), always return false as base case.
-
template <typename... FUNS>
boolis_valid
(char test_char, std::function<bool(char)> fun1, FUNS... funs, )¶ Determine if a character passes any of the test functions provided.
-
template <typename... FUNS>
static boolis_valid
(const std::string &test_str, FUNS... funs)¶ For a string to be valid, each character must pass at least one provided function.
-
static std::string
string_pop_fixed
(std::string &in_string, std::size_t end_pos, size_t delim_size = 0)¶ Pop a segment from the beginning of a string as another string, shortening original.
-
static std::string
string_get_range
(const std::string &in_string, std::size_t start_pos, std::size_t end_pos)¶ Get a segment from the beginning of a string as another string, leaving original untouched.
-
std::string
string_pop
(std::string &in_string, const char delim = ' ')¶ Remove a prefix of the input string (up to a specified delimeter) and return it. If the delimeter is not found, return the entire input string and clear it.
-
std::string
string_get
(const std::string &in_string, const char delim, size_t start_pos = 0)¶ Return a prefix of the input string (up to a specified delimeter), but do not modify it. If the delimeter is not found, return the entire input string.
-
std::string
string_pop
(std::string &in_string, const std::string &delim_set)¶ Remove a prefix of the input string (up to any of a specified set of delimeters) and return it. If the delimeter is not found, return the entire input string and clear it.
-
std::string
string_get
(const std::string &in_string, const std::string &delim_set, size_t start_pos = 0)¶ Return a prefix of the input string (up to any of a specified set of delimeters), but do not modify it. If the delimeter is not found, return the entire input string.
-
std::string
string_pop_word
(std::string &in_string)¶ Remove a prefix of a string, up to the first whitespace, and return it.
-
std::string
string_get_word
(const std::string &in_string, size_t start_pos = 0)¶ Return a prefix of a string, up to the first whitespace (do not modify the original string)
-
std::string
string_pop_line
(std::string &in_string)¶ Remove a prefix of a string, up to the first newline, and return it.
-
std::string
string_get_line
(const std::string &in_string, size_t start_pos = 0)¶ Return a prefix of a string, up to the first newline (do not modify the original string)
-
std::string
left_justify
(std::string &in_string)¶ Remove all whitespace at the beginning of a string. Return the whitespace removed.
-
static void
remove_chars
(std::string &in_string, std::string chars)¶ Remove instances of characters from file.
-
static void
compress_whitespace
(std::string &in_string)¶ Every time one or more whitespace characters appear replace them with a single space.
-
static void
remove_whitespace
(std::string &in_string)¶ Remove all whitespace from anywhere within a string.
-
static void
remove_punctuation
(std::string &in_string)¶ Remove all characters from a string except letters, numbers, and whitespace.
-
static void
slice
(const std::string &in_string, emp::vector<std::string> &out_set, char delim = 'n')¶ Cut up a string based on the provided delimitor; fill them in to the provided vector.
-
static emp::vector<std::string>
slice
(const std::string &in_string, char delim = 'n')¶ Slice a string without passing in result vector (may be less efficient).
-
template <typename... ALL_TYPES>
std::stringto_string
(ALL_TYPES&&... all_values)¶ This function does its very best to convert everything it’s to a string. Takes any number of arguments and returns a single string containing all of them concatenated. Objects can be any normal (POD) data type, container, or anything that can be passed into a stringstream.
-
template <typename T>
Tfrom_string
(const std::string &str)¶ This function tries to convert a string into any type you’re looking for… You just need to specify the out type as the template argument.
-
template <typename... Ts>
voidfrom_string
(const std::string &str, Ts&... args)¶ The from_string() function can also take multiple args instead of a return.
-
template <typename T>
emp::vector<T>from_strings
(const emp::vector<std::string> &string_v)¶ The from_strings() function takes a vector of strings and convets them into a vector of the appropriate type.
-
namespace
internal
Tuple Struct¶
Tuple Utilities¶
Functions to simplify the use of std::tuple.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2016-2017
- Note
- Status: RELEASE
-
namespace
emp
If we are in emscripten, make sure to include the header.
This file contains extra analysis tools to use with systematics managers that have non-null DATA_TYPES.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
This file contains functions for adding additional data files to Worlds.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
Functions
-
template <typename TUPLE_T>
constexpr inttuple_size
()¶ Quick way to calculate tuple size.
-
template <typename... Ts, int... Ps>
autoshuffle_tuple
(const std::tuple<Ts...> &tup, IntPack<Ps...>)¶ Reorganize the entries in tuple; the provided int pack must specify the new ordering.
-
template <typename FUN_T, typename TUPLE_T, int... N>
autoApplyTuple
(const FUN_T &fun, const TUPLE_T &tup, IntPack<N...>)¶ Apply a tuple as arguments to a function, where all argument positions in function are specified with and IntPack
-
template <typename FUN_T, typename TUPLE_T>
autoApplyTuple
(const FUN_T &fun, const TUPLE_T &tup)¶ Apply a tuple as arguments to a function, in order.
Type Tracker¶
Track class types abstractly to dynamically call correct function overloads.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2016-2017
- Note
- Status: BETA
-
namespace
emp
If we are in emscripten, make sure to include the header.
This file contains extra analysis tools to use with systematics managers that have non-null DATA_TYPES.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
This file contains functions for adding additional data files to Worlds.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
-
struct
TrackedType
¶ - #include <TypeTracker.h>
The base class of any type to be tracked.
Subclassed by emp::TypeTracker_Class< REAL_T, ID >
-
template <typename... TYPES>
structTypeTracker
¶ - #include <TypeTracker.h>
Dynamic functions that are indexed by parameter types; calls lookup the correct function to forward arguments into.
Public Types
-
template<>
usingthis_t
= TypeTracker<TYPES...>¶
-
template<>
usingwrap_t
= TypeTracker_Class<REAL_T, get_type_index<REAL_T, TYPES...>()>¶
Public Functions
-
TypeTracker
()¶
-
TypeTracker
(const TypeTracker&)¶
-
TypeTracker
(TypeTracker&&)¶
-
TypeTracker &
operator=
(const TypeTracker&)¶
-
TypeTracker &
operator=
(TypeTracker&&)¶
-
~TypeTracker
()¶
-
template <typename REAL_T>
wrap_t<REAL_T>Wrap
(REAL_T &&val)¶ Convert an input value into a TypeTracker_Class maintaining the value (universal version)
-
template <typename REAL_T>
wrap_t<REAL_T> *New
(REAL_T &val)¶ Create an input value in a TypeTracker_Class maintaining the value (reference version)
-
template <typename REAL_T>
wrap_t<REAL_T> *New
(REAL_T &&val)¶ Create an input value in a TypeTracker_Class maintaining the value (move version)
-
template <typename TEST_T>
boolIsType
(TrackedType &tt)¶ Test if the tracked type is TEST_T.
-
template <typename TEST_T>
boolIsType
(TrackedType *tt)¶ Test if the tracked type points to TEST_T.
-
template <typename REAL_T>
REAL_TToType
(TrackedType &tt)¶ Convert the tracked type back to REAL_T. Assert that this is type safe!
-
template <typename REAL_T>
REAL_TToType
(TrackedType *tt)¶ Convert the tracked type pointer back to REAL_T. Assert that this is type safe!
-
template <typename OUT_T>
OUT_TCast
(TrackedType &tt)¶ Cast the tracked type to OUT_T. Try to do so even if NOT original type!
-
template <typename OUT_T>
OUT_TCast
(TrackedType *tt)¶ Cast the tracked type pointer to OUT_T. Try to do so even if NOT original type!
-
template <typename... Ts>
this_t &AddFunction
(std::function<void(Ts...)> fun)¶ Add a new std::function that this TypeTracker should call if the appropriate types are passed in.
-
template <typename... Ts>
this_t &AddFunction
(void (*fun)(Ts...))¶ Add a new function pointer that this TypeTracker should call if the appropriate types are passed in.
-
template <typename... Ts>
voidRunFunction
(Ts... args)¶ Run the appropriate function based on the argument types received.
-
template <typename... Ts>
voidoperator()
(Ts... args)¶ Call TypeTracker as a function (refers call to RunFunction)
Public Members
Public Static Functions
-
static constexpr size_t
GetNumTypes
()¶ How many types are we working with?
-
static constexpr size_t
GetNumCombos
(size_t vals = 2)¶ How many combinations of V types are there?
-
static constexpr size_t
GetCumCombos
(size_t vals = 2)¶ How many combinations are the of the given number of types OR FEWER?
-
template <typename T>
static constexpr size_tGetID
()¶ Each type should have a unique ID.
-
template <typename T1, typename T2, typename... Ts>
static constexpr size_tGetID
()¶ Each set of types should have an ID unique within that number of types.
-
template <typename... Ts>
static constexpr size_tGetComboID
()¶ A ComboID should be unique across all size combinations.
-
static size_t
GetTrackedID
(const TrackedType &tt)¶ A Tracked ID is simply the unique ID of the type being tracked.
-
template <typename... Ts>
static size_tGetTrackedID
(const TrackedType &tt1, const TrackedType &tt2, const Ts&... ARGS)¶ Or set of types being tracked…
-
static size_t
GetTrackedID
(TrackedType *tt)¶ We should also about able to use a pointer to access tracked IDs.
-
template <typename... Ts>
static size_tGetTrackedID
(TrackedType *tt1, TrackedType *tt2, Ts *... ARGS)¶ A set of pointers to access tracked IDs.
-
template <typename... Ts>
static constexpr size_tGetTrackedComboID
(Ts... ARGS)¶ A tracked COMBO ID, is an ID for this combination of types, unique among all possible type combinations. Consistent with GetComboID with the same underlying types.
-
template<>
-
template <typename REAL_T, size_t ID>
structTypeTracker_Class
: public emp::TrackedType¶ - #include <TypeTracker.h>
The derived classes to be tracked should inherit from TypeTracker_Class<ID> where ID is the position in the type list for TypeTracker. Note: this value can be obtained dyanmically at compile type by using TypeTracker<…>::GetID<TYPE>()
Public Types
-
template<>
usingreal_t
= REAL_T¶
Public Functions
-
TypeTracker_Class
(const REAL_T &in)¶
-
TypeTracker_Class
(REAL_T &&in)¶
-
TypeTracker_Class
(const TypeTracker_Class&)¶
-
TypeTracker_Class
(TypeTracker_Class&&)¶
-
TypeTracker_Class &
operator=
(const TypeTracker_Class&)¶
-
TypeTracker_Class &
operator=
(TypeTracker_Class&&)¶
-
virtual size_t
GetTypeTrackerID
() const¶
Public Members
-
REAL_T
value
¶
-
template<>
Unit Testing¶
Macros to facilitate unit testing.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2015-2017
- Note
- Status: technically DEPRECATED (now using Catch, but may revert back)
Vector Utilities¶
A set of simple functions to manipulate emp::vector.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2017-2018
- Note
- Status: BETA
-
namespace
emp
If we are in emscripten, make sure to include the header.
This file contains extra analysis tools to use with systematics managers that have non-null DATA_TYPES.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
This file contains functions for adding additional data files to Worlds.
- Note
- This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
- Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
- 2018
Functions
-
template <typename T>
intFindValue
(const emp::vector<T> vec, const T &val, size_t start_pos = 0)¶ Return the first position of a value in a vector (or -1 if none exists)
-
template <typename T>
boolHas
(const emp::vector<T> vec, const T &val)¶ Return whether a value exists in a vector.s.
-
template <typename T>
voidPrint
(const emp::vector<T> &v, std::ostream &os = std::cout, const std::string &spacer = " ")¶ Print the contects of a vector.
-
template <typename T>
size_tFindIndex
(const T &v, const std::function<bool(typename T::value_type, typename T::value_type)> &fun)¶ Find the index with the “optimal” value (picks first in cases of a tie).
- Parameters
v
: Any object allowing indexing (e.g. vector, array, etc.)fun
: Comparison function; returns true if the first value os more optimal than second.
-
template <typename T>
size_tFindMinIndex
(const T &v)¶ Find the index with the minimal value (picks first in cases of a tie).
-
template <typename T>
size_tFindMaxIndex
(const T &v)¶ Find the index with the maximal value (picks first in cases of a tie).
-
template <typename T, typename... Ts>
voidSort
(emp::vector<T> &v, Ts... args)¶ A quick shortcut for sorting a vector.
-
template <typename T>
emp::vector<T>Slice
(emp::vector<T> vec, int start, int stop)¶ Returns a vector containing a chunk of elements from
- Parameters
vec
: starting atstart
: and going up to but not includingstop.
:
-
constexpr size_t
tree_left
(size_t id)¶ Tree manipulation in vectors.
-
constexpr size_t
tree_right
(size_t id)¶
-
constexpr size_t
tree_parent
(size_t id)¶