Class HierarchicalGeometry
Object
AbstractGeometry
AbstractLattice
HierarchicalGeometry
Hierarchical meta-population structure implementation. Embeds well-mixed or
square-lattice demes into recursive layers.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int[]The number of units at each hierarchical level.private doubleCoupling strength between hierarchical levels.private GeometryTypeThe geometry of each hierarchical level.Fields inherited from class AbstractLattice
fixedBoundaryFields inherited from class AbstractGeometry
connectivity, EMPTY_LINKS, engine, features, in, isInterspecies, isRegular, isRewired, isSingle, isUndirected, isValid, kin, kout, logger, name, network2D, network3D, out, pAddwire, pRewire, size, specs, type -
Constructor Summary
ConstructorsConstructorDescriptionHierarchicalGeometry(EvoLudo engine) Create a hierarchical geometry tied to the given engine. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddBoundaryLinks(int player, int fullside, int range, boolean interspecies, int uStep, int vStep) Add links for a boundary player in a square deme.private voidaddSquareNeighborhood(int i, int j, int sideLen, int fullside, int offset, int range, boolean interspecies) Add all neighbours for a player in the square deme.private voidadjustMooreBoundaries(int sideLen, int fullside, int offset, boolean interspecies) Adjust Moore neighbourhoods along fixed boundaries.private voidadjustNeumann2ndBoundaries(int sideLen, int fullside, int offset, boolean interspecies) Adjust second-neighbour von Neumann neighbourhoods along fixed boundaries.private voidadjustNeumannBoundaries(int sideLen, int fullside, int offset, boolean interspecies) Adjust von Neumann neighbourhoods along fixed boundaries.private voidadjustSquareBoundaries(int sideLen, int fullside, int offset, int range, boolean interspecies) Adjust arbitrary-range square neighbourhoods along fixed boundaries.private intcalcSquareUnit(int nHierarchy) Calculate the unit size for square-lattice hierarchies, adjusting each level to a perfect square with at least 2x2 units with at least 3x3 individuals each.private booleanProcess the hierarchy specifications to calculate the number of units and the size of each unit.protected booleanHook for subclasses to implement geometry specific checks.clone()Clone geometry.booleanint[]Retrieve a copy of the processed hierarchy definition (levels plus individuals per deme).doubleReport the weight applied to inter-level interactions.Retrieve the geometry used within each hierarchy level (e.g.inthashCode()voidinit()Initialise the geometry.private voidinitHierarchy(int level, int start) Utility method to generate hierarchical graphs.private voidinitHierarchyMeanfield(int start, int end) Utility method to generate hierarchical well-mixed subpopulations (demes).private voidinitHierarchySquare(int start, int end) Utility method to generate hierarchical square-lattice demes.private voidinitSquare(int sideLen, int fullside, int offset) Initialize a square deme for arbitrary (odd) neighbourhood sizes.private voidinitSquareMoore(int sideLen, int fullside, int offset) Initialize a square deme with Moore connectivity.private voidinitSquareVonNeumann(int sideLen, int fullside, int offset) Initialize a square deme with von Neumann connectivity, optionally adjusting for boundary conditions.private voidinitSquareVonNeumann2nd(int sideLen, int fullside, int offset) Initialize a square deme with second-neighbour von Neumann connectivity.booleanisSubtype(GeometryType type) Check if the sub-geometry matches the given type.booleanisUnique()Check if current geometry unique.(package private) booleanParse geometry-specific CLI options.private voidParse the hierarchy-related CLI spec, updating subtype, boundary flag and weight, and storing the raw hierarchy levels (without the computed leaf size).Methods inherited from class AbstractLattice
isFixedBoundary, setFixedBoundary, stripBoundaryMethods inherited from class AbstractGeometry
addDirected, addEdgeAt, addLinkAt, addUndirected, alloc, check, clearLinksFrom, clearLinksTo, create, create, decodeGeometry, deriveCompetitionGeometry, displaySingle, encodeGeometry, enforceSize, getAddwire, getConnectivity, getEncodeKey, getFeatures, getLabel, getName, getNetwork2D, getNetwork3D, getRewire, getSize, getSpecs, getType, isConsistent, isGraphConnected, isInterspecies, isLattice, isNeighborOf, isRegular, isRewired, isSingle, isType, isUndirected, parse, removeEdgeAt, removeLinkAt, rewire, rewireDirected, rewireEdgeAt, rewireLinkAt, rewireUndirected, setAddwire, setConnectivity, setInterspecies, setName, setNetwork2D, setNetwork3D, setRewire, setSingle, setSize, setType, swapEdges, usage, warn
-
Field Details
-
subType
The geometry of each hierarchical level. -
hierarchy
private int[] hierarchyThe number of units at each hierarchical level. -
hierarchyWeight
private double hierarchyWeightCoupling strength between hierarchical levels.
-
-
Constructor Details
-
HierarchicalGeometry
Create a hierarchical geometry tied to the given engine.- Parameters:
engine- EvoLudo pacemaker
-
-
Method Details
-
parse
Description copied from class:AbstractGeometryParse geometry-specific CLI options.- Overrides:
parsein classAbstractGeometry- Parameters:
spec- the argument string without the geometry key- Returns:
trueif parsing succeeded,falseif invalid
-
isSubtype
Check if the sub-geometry matches the given type.- Parameters:
type- the geometry type to check against- Returns:
trueif the sub-geometry matches the given type
-
getSubType
Retrieve the geometry used within each hierarchy level (e.g. square or well-mixed).- Returns:
- the geometry used within each hierarchy level (e.g. square or well-mixed)
-
getHierarchyWeight
public double getHierarchyWeight()Report the weight applied to inter-level interactions.- Returns:
- the weight applied to inter-level interactions
-
getHierarchyLevels
public int[] getHierarchyLevels()Retrieve a copy of the processed hierarchy definition (levels plus individuals per deme).- Returns:
- a copy of the processed hierarchy definition (levels plus individuals per deme)
-
checkSettings
protected boolean checkSettings()Description copied from class:AbstractGeometryHook for subclasses to implement geometry specific checks.- Overrides:
checkSettingsin classAbstractGeometry- Returns:
trueif adjustments require a reset
-
calcUnitSize
private boolean calcUnitSize()Process the hierarchy specifications to calculate the number of units and the size of each unit. On each level there must be at least 2 units for well-mixed hierarchies and each unit must contain at least 2 individuals. For hierarchies with square lattices each level must ahev at least 2x2 units with at least 3x3 individuals each.- Returns:
trueif the size was adjusted and resetting is required
-
calcSquareUnit
private int calcSquareUnit(int nHierarchy) Calculate the unit size for square-lattice hierarchies, adjusting each level to a perfect square with at least 2x2 units with at least 3x3 individuals each.- Parameters:
nHierarchy- the number of hierarchy levels- Returns:
- the total size of the graph
-
init
public void init()Initialise the geometry.Requirements/notes:
Only well-mixed (complete) or square lattice graphs are currently supported.- Specified by:
initin classAbstractGeometry
-
initHierarchy
private void initHierarchy(int level, int start) Utility method to generate hierarchical graphs.- Parameters:
level- the hierarchical levelstart- the index of the first node to process
-
initHierarchyMeanfield
private void initHierarchyMeanfield(int start, int end) Utility method to generate hierarchical well-mixed subpopulations (demes).- Parameters:
start- the index of the first node to processend- the index of the last node to process
-
initHierarchySquare
private void initHierarchySquare(int start, int end) Utility method to generate hierarchical square-lattice demes.- Parameters:
start- the index of the first node to processend- the index of the last node to process
-
initSquareVonNeumann
private void initSquareVonNeumann(int sideLen, int fullside, int offset) Initialize a square deme with von Neumann connectivity, optionally adjusting for boundary conditions.- Parameters:
sideLen- side length of the demefullside- side length of the full latticeoffset- index offset of the deme
-
adjustNeumannBoundaries
private void adjustNeumannBoundaries(int sideLen, int fullside, int offset, boolean interspecies) Adjust von Neumann neighbourhoods along fixed boundaries.- Parameters:
sideLen- side length of the demefullside- side length of the full latticeoffset- index offset of the demeinterspecies-trueif interspecific interactions allow self-links
-
initSquareVonNeumann2nd
private void initSquareVonNeumann2nd(int sideLen, int fullside, int offset) Initialize a square deme with second-neighbour von Neumann connectivity.- Parameters:
sideLen- side length of the demefullside- side length of the full latticeoffset- index offset of the deme
-
adjustNeumann2ndBoundaries
private void adjustNeumann2ndBoundaries(int sideLen, int fullside, int offset, boolean interspecies) Adjust second-neighbour von Neumann neighbourhoods along fixed boundaries.- Parameters:
sideLen- side length of the demefullside- side length of the full latticeoffset- index offset of the demeinterspecies-trueif interspecific interactions allow self-links
-
initSquareMoore
private void initSquareMoore(int sideLen, int fullside, int offset) Initialize a square deme with Moore connectivity.- Parameters:
sideLen- side length of the demefullside- side length of the full latticeoffset- index offset of the deme
-
adjustMooreBoundaries
private void adjustMooreBoundaries(int sideLen, int fullside, int offset, boolean interspecies) Adjust Moore neighbourhoods along fixed boundaries.- Parameters:
sideLen- side length of the demefullside- side length of the full latticeoffset- index offset of the demeinterspecies-trueif interspecific interactions allow self-links
-
initSquare
private void initSquare(int sideLen, int fullside, int offset) Initialize a square deme for arbitrary (odd) neighbourhood sizes.- Parameters:
sideLen- side length of the demefullside- side length of the full latticeoffset- index offset of the deme
-
addSquareNeighborhood
private void addSquareNeighborhood(int i, int j, int sideLen, int fullside, int offset, int range, boolean interspecies) Add all neighbours for a player in the square deme.- Parameters:
i- row index within the demej- column index within the demesideLen- side length of the demefullside- side length of the full latticeoffset- index offset of the demerange- neighbour rangeinterspecies-trueif interspecific interactions allow self-links
-
adjustSquareBoundaries
private void adjustSquareBoundaries(int sideLen, int fullside, int offset, int range, boolean interspecies) Adjust arbitrary-range square neighbourhoods along fixed boundaries.- Parameters:
sideLen- side length of the demefullside- side length of the full latticeoffset- index offset of the demerange- neighbour rangeinterspecies-trueif interspecific interactions allow self-links
-
addBoundaryLinks
private void addBoundaryLinks(int player, int fullside, int range, boolean interspecies, int uStep, int vStep) Add links for a boundary player in a square deme.- Parameters:
player- the player at the boundaryfullside- the side length of the full latticerange- the neighbour rangeinterspecies-truefor interspecific interactionsuStep- the step size in the u directionvStep- the step size in the v direction
-
isUnique
public boolean isUnique()Description copied from class:AbstractGeometryCheck if current geometry unique. Only unique geomteries need to be encoded.Requirements/notes:
- Lattices etc. are not unique because they can be identically recreated.
- Complete graphs, stars, wheels, etc. are not unique.
- All geometries involving random elements are unique.
- All rewired geometries are unique.
- Hierarchical geometries require recursive checks of uniqueness.
- Overrides:
isUniquein classAbstractGeometry- Returns:
trueif geometry is unique
-
clone
Description copied from class:AbstractGeometryClone geometry.Requirements/notes:
- Overrides:
clonein classAbstractLattice- Returns:
- clone of geometry
-
hashCode
public int hashCode()- Overrides:
hashCodein classAbstractLattice
-
equals
- Overrides:
equalsin classAbstractLattice
-
parseHierarchy
private void parseHierarchy()Parse the hierarchy-related CLI spec, updating subtype, boundary flag and weight, and storing the raw hierarchy levels (without the computed leaf size).
-