Package org.evoludo.simulator.models
Class IBSGroup
Object
IBSGroup
Interaction and reference groups in IBS models.
- Author:
- Christoph Hauert
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumTypes of sampling of groups for interactions or references: none no interactions all interact with all neighbours random interact with n random neighbours -
Field Summary
FieldsModifier and TypeFieldDescription(package private) intThe index of the focal individual.(package private) GeometryThe geometry associated with this group.(package private) int[]Reference to the indices of the members of the group.private static int[]The empty neighbourhood of a lone individual.private int[]Storage for selected interaction or reference groups.(package private) intThe effective sample size.(package private) intThe sample size requested.protected RNGDistributionThe shared random number generator to ensure reproducibility of results.(package private) IBSGroup.SamplingTypeThe current sampling type for the formation of interaction or reference groups.(package private) booleanThe flag indicating whether to include the focal individual when sampling. -
Constructor Summary
ConstructorsConstructorDescriptionIBSGroup(RNGDistribution rng) Create a new interaction or competition group. -
Method Summary
Modifier and TypeMethodDescriptionintgetFocal()Gets the index of the focal individual.int[]getGroup()Gets the array of indices of the interaction/reference group members.intGet the number of interactions with random neighbours.intGet the number of interactions with random neighbours.Gets the type of sampling of interaction/reference groups.booleangetSelf()Gets whether random sampling includes the focal individual or not.booleanChecks whether the type of sampling of interaction/reference groups istype.int[]pickAt(int me, boolean downstream) Picks an interaction/reference group for the focal individualfocaland the population structuregeom.private voidpickRandom(int size) Pick group ofnSamplesrandom individual with indices0 - (size-1).voidsetGeometry(Geometry geometry) Set the geometry associated with this group.voidsetGroupAt(int focal, int[] group, int size) Sets the interaction/reference group togroupwith a sizesizeand the focal indiviualfocal.voidsetNSamples(int nSamples) Set the number of interactions with random neighbours.voidSets the type of sampling of interaction/reference groups totype.voidsetSelf(boolean self) Sets whether random sampling should include the focal individual or not.
-
Field Details
-
loner
private static int[] lonerThe empty neighbourhood of a lone individual. -
geometry
Geometry geometryThe geometry associated with this group. -
mem
private int[] memStorage for selected interaction or reference groups. -
group
int[] groupReference to the indices of the members of the group. -
focal
int focalThe index of the focal individual. -
rng
The shared random number generator to ensure reproducibility of results.- See Also:
-
samplingType
IBSGroup.SamplingType samplingTypeThe current sampling type for the formation of interaction or reference groups. -
nSamples
int nSamplesThe sample size requested. Default is a single sample for RANDOM sampling. -
nSampled
int nSampledThe effective sample size.nSampled < nSamplesmay hold depending on the population structure. -
self
boolean selfThe flag indicating whether to include the focal individual when sampling.Notes
In the original Moran process the offspring can replace the parent. Hence, for reference groups in well-mixed populations it makes sense to include the focal individual. In contrast, self-interactions may simplify some analytical considerations but in IBS never make sense.
-
-
Constructor Details
-
IBSGroup
Create a new interaction or competition group. The global, shared random number generatorrngmust be passed here to ensure reproducibility of the simulation results.Note: The default (empty) constructor does not need to be declared private in order to prevent instantiation. The compiler does not generate a default constructor if another one exists.
- Parameters:
rng- the random number generator for picking interaction or reference groups
-
-
Method Details
-
setGeometry
Set the geometry associated with this group.- Parameters:
geometry- the geometry associated with group
-
setSampling
Sets the type of sampling of interaction/reference groups totype.- Parameters:
type- the type of sampling
-
getSampling
Gets the type of sampling of interaction/reference groups.- Returns:
- the type of sampling
-
getNSamples
public int getNSamples()Get the number of interactions with random neighbours.- Returns:
- the number of interactions
-
setNSamples
public void setNSamples(int nSamples) Set the number of interactions with random neighbours.- Parameters:
nSamples- the number of interactions
-
isSampling
Checks whether the type of sampling of interaction/reference groups istype.- Parameters:
type- the sampling type to check- Returns:
trueif the type of sampling istype
-
getNSampled
public int getNSampled()Get the number of interactions with random neighbours.- Returns:
- the number of interactions
-
setSelf
public void setSelf(boolean self) Sets whether random sampling should include the focal individual or not.- Parameters:
self-trueif sampling includes focal
-
getSelf
public boolean getSelf()Gets whether random sampling includes the focal individual or not.- Returns:
trueif sampling includes focal
-
setGroupAt
public void setGroupAt(int focal, int[] group, int size) Sets the interaction/reference group togroupwith a sizesizeand the focal indiviualfocal.- Parameters:
focal- the index of the focal individualgroup- the array with the indices of the members of the groupsize- the size of the group
-
getGroup
public int[] getGroup()Gets the array of indices of the interaction/reference group members.- Returns:
- the interaction/reference group
-
getFocal
public int getFocal()Gets the index of the focal individual.- Returns:
- the index of the focal individual
-
pickAt
public int[] pickAt(int me, boolean downstream) Picks an interaction/reference group for the focal individualfocaland the population structuregeom. If the flagout == truethen the group is sampled from the outgoing neighbours (downstream) of thefocaland from the incoming neighbours (upstream) otherwise.Important: For efficiency the sampled group may be a direct reference to the population structure. For example,
group = out[focal]to reference all neighbours of the focal individual. As a consequence the array group is untouchable and must never be manipulated because this would result in permanent changes of the population structure.- Parameters:
me- the index of the focal individualdownstream- the flag indicating whether to sample the group from the outgoing (downstream) or incoming (upstream) neighbours- Returns:
- the interaction/reference group (same as
group) - See Also:
-
pickRandom
private void pickRandom(int size) Pick group ofnSamplesrandom individual with indices0 - (size-1). The focal individual is included ifself==true.- Parameters:
size- the maximum index to pick
-