Class IBSMCPopulation
- Direct Known Subclasses:
IBSCPopulation
IBSCPopulation.- Author:
- Christoph Hauert
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Model.HasIBS.MCGroupsFor group interaction modulesmodule==groupmoduleholds andnullotherwise.protected IBSC.InitType of initial configuration.private double[]The array for calculating and storing the mean traits and their standard deviation.(package private) double[]Temporary storage for the traits of the focal individual.(package private) double[]Temporary storage for the scores of each participant prior to group interactions.(package private) double[]Temporary storage for the traits of the focal individual before the update.protected Model.HasIBS.MCPairsFor pairwise interaction modulesmodule==pairmoduleholds andnullotherwise.(package private) double[]Temporary storage for traits of individuals in small sub-group interactions.(package private) double[]Temporary storage for traits of individuals in group interactions.protected double[]The array with the maximal values for each trait.protected double[]The array with the minimal values for each trait.(package private) double[]The array of individual traits.(package private) double[]The array for temporarily storing traits during updates.Fields inherited from class IBSPopulation
adjustScores, competition, compGroup, consistencyCheckRequested, debugFocal, debugModel, debugModels, debugNModels, debugSame, distrMigrants, engine, fitness, groupScores, hasLookupTable, interaction, interactions, interGroup, isMultispecies, isNeutral, logger, map2fit, maxEffScoreIdx, maxFitness, maxScore, migrationType, minFitness, minScore, module, mutation, nIssues, nMixedInter, nPopulation, nTraits, opponent, optimizeHomo, pAddwire, playerScoreAveraged, playerScoring, playerUpdate, pMigration, populationUpdate, pRewire, rng, scores, smallScores, staticmodule, sumFitness, syncFraction, tags, typeFitness, typeScores, vacantIdx -
Constructor Summary
ConstructorsConstructorDescriptionIBSMCPopulation(EvoLudo engine, Continuous module) Creates a population of individuals with multiple continuous traits for IBS simulations. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddState(double[] state) Adds the traits of all individuals to the arraystate.voidadjustPairGameScoresAt(int me) Adjusts scores of focal individual with indexmeand its neighbors aftermechanged trait.voidadjustScoreAt(int index, double adjust) Adjust score of individual with indexindexbyadjustand update all applicable helper variables, e.g.voidadjustScoreAt(int index, double before, double after) Adjust score of individual with indexindexfrombeforetoafterand update all applicable helper variables, e.g.booleancheck()Check all model parameters for consistency and adjust if necessary (and feasible).booleanCheck if population has converged.voidcommitTraitAt(int me) The change of a trait of the player atindexis stored in a temporary variable and must be committed before proceeding.voidAfter a synchronous update step the new state must be copied back to become the current state.private doubledeltaTraits(int a, int b) Measure the (Cartesian) distance between traits ataandbprotected booleanCheck if scores can be adjusted rather than recalculated after an individual changed its trait.voidencodeTraits(StringBuilder plist) Encode the traits of all individuals in the IBS model in aplistinspiredXMLstring.private voidgatherPlayers(IBSGroup group) Gather the traits of all individuals in the interaction groupgroup.voidget2DTraitHistogramData(double[] bins, int trait1, int trait2) Creates 2D histogram for traitstrait1andtrait2.getInit()Gets the type of the initial configuration and its arguments.double[]Gets the maximal value of each trait in the population and stores it in the arraymax.double[]getMaxTraits(double[] max) Gets the maximal value of each trait in the population and stores it in the arraymax.double[]getMeanFitness(double[] mean) Returns the mean fitness of this population in the arraymean.double[]getMeanTraits(double[] mean) Returns the mean trait(s) of this population in the arraymean.double[]Gets the minimal value of each trait in the population and stores it in the arraymin.double[]getMinTraits(double[] min) Gets the minimal value of each trait in the population and stores it in the arraymin.Gets the status of the as a formatted string.doublegetTraitAt(int idx) Get the trait of individual with indexidx.doublegetTraitAt(int idx, int d) Get traitdof individual with indexidx.<T> voidgetTraitData(T[] colors, ColorMap<T> colorMap) Returns the traits of all individuals in this population coded as colors in the arraycolorsusing the mapcolorMap.voidgetTraitHistogramData(double[][] bins) Creates a histogram for each trait separately (if there are multiple) and returns the result in the arraybinswhere the first index denotes the trait and the second refers to the bin.voidgetTraitHistogramData(double[] bins, int trait) Creates a histogram for the trait with indextraitand returns the result in the arraybins.getTraitNameAt(int index) Gets the formatted name of the trait of the individual at siteindex.double[]Get the maxima for all traits.double[]Get the minima for all traits.getTraits(int digits) Gets all traits of all individuals.double[]getTraitsAt(int idx) Get the trait array of individual with indexidx.double[]getTraitsAt(int idx, double[] idxtraits) Get the trait array of individual with indexidx.booleanhaveSameTrait(int a, int b) Check if individuals with indexaand indexbhave the same traits.voidinit()Initialize the model.(package private) voidInitialize traits by sampling from a (possibly truncated) Gaussian distribution per trait.(package private) voidinitMono()Initialize all individuals with the same (monomorphic) trait value.(package private) voidInitialize a monomorphic resident population with a single mutant.(package private) voidInitialize each trait uniformly at random in its allowed range.booleanisSameTrait(int a) Check if individual with indexahas switched traits.protected booleanmaybeMutateAt(int focal, boolean switched) Consider mutating the trait of the focal individual with indexfocal.protected voidmaybeMutateMoran(int source, int dest) Consider mutating the trait of the parent individual with indexsource.booleanmouseHitNode(int hit, boolean alt) Called from GUI if node/individual with indexidxreceived a mouse click or tap and indicates whether thealt-key had been pressed.intmutateAt(int focal) Mutate the trait of the focal individual with indexfocal.private booleanmutateAt(int focal, boolean switched) Mutate all traits of the focal individual with indexfocalifmutate == true.voidplayGroupGameAt(IBSGroup group) Play a group interaction with the individuals ingroup.(package private) voidplayGroupOnceAt(int me, IBSGroup group) Evaluate a single group interaction with the sampled opponents.(package private) voidplayGroupSequentiallyAt(int me, IBSGroup group, int nGroup) Evaluate sequential group interactions when not enough opponents are available simultaneously.(package private) voidplayNoGameAt(int me) Handle the case where a focal player has no opponents and should not play a game.voidplayPairGameAt(IBSGroup group) Play a pairwise interaction with the individuals ingroup.booleanpreferredPlayerBest(int me, int best, int sample) For deterministic updating with multiple traits (more than two), it must be specified which trait is the preferred one.voidPrior to a synchronous update step the current state must be duplicated in preparation for processing the next step.voidreset()Reset the model.booleanrestoreTraits(Plist plist) Restore the traits of all individuals encoded in theplistinspiredmapofkey, value-pairs.voidSets the type of the initial configuration and any accompanying arguments.voidsetOpponentPop(IBSPopulation<?, ?> opponent) Set the interaction partner/opponent of this population.voidsetTraitAt(int idx, double trait) Set the trait of individual with indexidxtotrait.voidsetTraitAt(int idx, int d, double trait) Set traitdof the individual with indexidx.voidsetTraitsAt(int idx, double[] idxtraits) Set the trait array of individual with indexidxto arrayidxtraits.voidswapTraits(int a, int b) Swap traits of individuals with indexaand indexb.voidupdateFromModelAt(int index, int modelPlayer) Update individual with indexmeand adopt the trait of individual with indexyou.voidyalpGroupGameAt(IBSGroup group) Counterpart ofIBSPopulation.playGroupGameAt(IBSGroup),IBSPopulation.playGameAt(int)and/orIBSPopulation.playGameSyncAt(int).Methods inherited from class IBSPopulation
adjustGameScoresAt, becomesVacantAt, checkCompSampling, checkConsistentFitness, checkGeometry, checkGeometryRewire, checkInteractions, checkLookupTable, checkMigration, checkNoLookupTable, checkOptimizations, checkPayoffs, debugMarkChange, debugScores, debugUpdate, debugUpdatePopulationAt, doBirthDeathMigration, doDeathBirthMigration, doDiffusionMigration, doMigration, doSyncMigration, encodeFitness, encodeGeometry, encodeInteractions, getCompetitionGeometry, getCompGroup, getFitness, getFitnessAt, getFitnessData, getFitnessHistogramData, getFitnessNameAt, getFitnessNameAt, getInteractionGeometry, getInteractionsAt, getInterGroup, getMaxScore, getMigrationProb, getMigrationType, getMinScore, getModule, getNMean, getNMixedInteractions, getPlayerScoreAveraged, getPlayerScoring, getPopulationSize, getPopulationUpdate, getScoreAt, getScoreNameAt, getScores, getSpeciesUpdateRate, getSyncFraction, getTagAt, getTagData, getTagNameAt, getTags, getTotalFitness, isConsistent, isMonomorphic, isVacantAt, logAccountingIssue, logAccountingIssue, logFitnessIssue, logMapIssue, logScoringIssue, logScoringIssue, migrateMoran, mouseHitNode, mutate, nextBinomial, pickFitFocalIndividual, pickFitFocalIndividual, pickFitNeighborAt, pickFitNeighborAt, pickFocalIndividual, pickFocalIndividual, pickFocalSite, pickFocalSite, pickNeighborSiteAt, playGameAt, playGameSyncAt, processScore, random01, random0n, randomGaussian, removeScoreAt, removeScoreAt, resetEphemeral, resetMoran, resetScoreAt, resetScores, resetTraits, restoreFitness, restoreGeometry, restoreInteractions, setAddwire, setConsistencyCheck, setGeometryNames, setMaxEffScoreIdx, setMigrationProb, setMigrationType, setPlayerScoreAveraged, setPlayerScoring, setPopulationUpdate, setRewire, setScoreAt, setSyncFraction, setTagAt, step, swapScoresAt, updateEffScoreRange, updateFitnessAt, updateMinMaxScores, updatePlayerAsync, updatePlayerAsyncAt, updatePlayerAt, updatePlayerAt, updatePlayerBest, updatePlayerBestHalf, updatePlayerBestResponse, updatePlayerEcology, updatePlayerEcologyAt, updatePlayerMoranBirthDeath, updatePlayerMoranBirthDeathAt, updatePlayerMoranDeathBirth, updatePlayerMoranDeathBirthAt, updatePlayerMoranImitate, updatePlayerMoranImitateAt, updatePlayerSwap, updateProportionalAbs, updateReplicatorHalf, updateReplicatorPlus, updateScoreAt, updateScoreAt, updateScoreAt, updateScores, updateThermal
-
Field Details
-
pairmodule
For pairwise interaction modulesmodule==pairmoduleholds andnullotherwise. Convenience field to reduce the number of (unnecessary) casts.- See Also:
-
groupmodule
For group interaction modulesmodule==groupmoduleholds andnullotherwise. Convenience field to reduce the number of (unnecessary) casts.- See Also:
-
traitRangeMin
protected double[] traitRangeMinThe array with the minimal values for each trait. Convenience variable to reduce calls to module.Note: Internally traits are always scaled to
[0, 1].- See Also:
-
traitRangeMax
protected double[] traitRangeMaxThe array with the maximal values for each trait. Convenience variable to reduce calls to module.Note: Internally traits are always scaled to
[0, 1].- See Also:
-
traits
double[] traitsThe array of individual traits. The traits of individualiare stored attraits[i * nTraits]throughtraits[(i + 1) * nTraits - 1] -
traitsNext
double[] traitsNextThe array for temporarily storing traits during updates. -
tmpGroup
double[] tmpGroupTemporary storage for traits of individuals in group interactions. -
smallTrait
double[] smallTraitTemporary storage for traits of individuals in small sub-group interactions. -
myTraits
double[] myTraitsTemporary storage for the traits of the focal individual. -
oldTraits
double[] oldTraitsTemporary storage for the traits of the focal individual before the update. Used for adjusting scores. -
oldScores
double[] oldScoresTemporary storage for the scores of each participant prior to group interactions. -
meantrait
private double[] meantraitThe array for calculating and storing the mean traits and their standard deviation. Must be of length> 2 * nTraits. -
init
-
-
Constructor Details
-
IBSMCPopulation
Creates a population of individuals with multiple continuous traits for IBS simulations.- Parameters:
engine- the pacemaker for running the modelmodule- the module that defines the game
-
-
Method Details
-
setOpponentPop
Description copied from class:IBSPopulationSet the interaction partner/opponent of this population.- Overrides:
setOpponentPopin classIBSPopulation<Continuous, IBSMCPopulation>- Parameters:
opponent- the interaction partner/opponent
-
checkConvergence
public boolean checkConvergence()Description copied from class:IBSPopulationCheck if population has converged. By defaulttrueif population is monomorphic and no (zero) mutations. However, different implementations may have different criteria for convergence.Note: This tends to be less restrictive than reaching an absorbing state. Typically convergence is used as a criterion to abort simulations.
- Overrides:
checkConvergencein classIBSPopulation<Continuous, IBSMCPopulation>- Returns:
trueif converged.
-
getTraitRangeMin
public double[] getTraitRangeMin()Get the minima for all traits.- Returns:
- the array with the trait minima
-
getTraitRangeMax
public double[] getTraitRangeMax()Get the maxima for all traits.- Returns:
- the array with the trait maxima
-
getTraitAt
public double getTraitAt(int idx) Get the trait of individual with indexidx.- Parameters:
idx- the index of the individual- Returns:
- the trait of the individual
-
getTraitAt
public double getTraitAt(int idx, int d) Get traitdof individual with indexidx.- Parameters:
idx- the index of the individuald- the trait index- Returns:
- the trait of the individual
-
setTraitAt
public void setTraitAt(int idx, double trait) Set the trait of individual with indexidxtotrait.- Parameters:
idx- the index of the individualtrait- the trait of the individual
-
setTraitAt
public void setTraitAt(int idx, int d, double trait) Set traitdof the individual with indexidx.- Parameters:
idx- the index of the individuald- the trait indextrait- the new trait value
-
getTraitsAt
public double[] getTraitsAt(int idx) Get the trait array of individual with indexidx. Allocates array to store the trait values.- Parameters:
idx- the index of the individual- Returns:
- the traits of the individual
-
getTraitsAt
public double[] getTraitsAt(int idx, double[] idxtraits) Get the trait array of individual with indexidx. Stores the trait values in the arrayidxtraits.- Parameters:
idx- the index of the individualidxtraits- the array for storing the traits- Returns:
- the traits of the individual
-
setTraitsAt
public void setTraitsAt(int idx, double[] idxtraits) Set the trait array of individual with indexidxto arrayidxtraits.- Parameters:
idx- the index of the individualidxtraits- the traits of the individual
-
updateFromModelAt
public void updateFromModelAt(int index, int modelPlayer) Description copied from class:IBSPopulationUpdate individual with indexmeand adopt the trait of individual with indexyou.Note: method must be subclassed to deal with different data types of traits but should also include a call to super.
- Overrides:
updateFromModelAtin classIBSPopulation<Continuous, IBSMCPopulation>- Parameters:
index- the index of the focal individualmodelPlayer- the index of the model individual to adopt trait from- See Also:
-
haveSameTrait
public boolean haveSameTrait(int a, int b) Description copied from class:IBSPopulationCheck if individuals with indexaand indexbhave the same traits.- Specified by:
haveSameTraitin classIBSPopulation<Continuous, IBSMCPopulation>- Parameters:
a- the index of first individualb- the index of second individual- Returns:
trueif the two individuals have the same traits
-
isSameTrait
public boolean isSameTrait(int a) Description copied from class:IBSPopulationCheck if individual with indexahas switched traits.Note: this test is only meaningful before trait are committed.
- Specified by:
isSameTraitin classIBSPopulation<Continuous, IBSMCPopulation>- Parameters:
a- index of individual- Returns:
trueif trait remained unchanged- See Also:
-
swapTraits
public void swapTraits(int a, int b) Description copied from class:IBSPopulationSwap traits of individuals with indexaand indexb.Note: the traits still need to be committed.
- Specified by:
swapTraitsin classIBSPopulation<Continuous, IBSMCPopulation>- Parameters:
a- the index of first individualb- the index of second individual- See Also:
-
mutateAt
public int mutateAt(int focal) Description copied from class:IBSPopulationMutate the trait of the focal individual with indexfocal. The mutated trait is committed and the scores updated.- Specified by:
mutateAtin classIBSPopulation<Continuous, IBSMCPopulation>- Parameters:
focal- the index of the focal individual- Returns:
- the number of elapsed realtime units
-
maybeMutateAt
protected boolean maybeMutateAt(int focal, boolean switched) Description copied from class:IBSPopulationConsider mutating the trait of the focal individual with indexfocal. The trait of the focal individual is stored in the arraytraitsunless the focal individual switched trait. In that case the current trait is stored in the arraytraitsNext.Important: The trait is not committed regardless of whether a mutation occurred.
- Specified by:
maybeMutateAtin classIBSPopulation<Continuous, IBSMCPopulation>- Parameters:
focal- the index of the focal individualswitched-trueif the focal individual switched trait- Returns:
trueif the trait of the focal individual changed
-
maybeMutateMoran
protected void maybeMutateMoran(int source, int dest) Description copied from class:IBSPopulationConsider mutating the trait of the parent individual with indexsource. The mutated trait is committed and the scores updated.- Specified by:
maybeMutateMoranin classIBSPopulation<Continuous, IBSMCPopulation>- Parameters:
source- the index of the parent individualdest- the index of the location for the offspring placement
-
mutateAt
private boolean mutateAt(int focal, boolean switched) Mutate all traits of the focal individual with indexfocalifmutate == true. In all cases commit traits and update scores.- Parameters:
focal- the index of the focal individual that gets updatedswitched-trueif focal already switched trait- Returns:
trueif the trait has changed
-
preferredPlayerBest
public boolean preferredPlayerBest(int me, int best, int sample) For deterministic updating with multiple traits (more than two), it must be specified which trait is the preferred one.Summary: does 'me' prefer 'sample' over 'best'?
Here we introduce the convention the trait closer to
meis preferred.- Specified by:
preferredPlayerBestin classIBSPopulation<Continuous, IBSMCPopulation>- Parameters:
me- the index of the focal individualbest- the index of the best performing individualsample- the index of the sample type- Returns:
trueifsampleis preferred overbest
-
deltaTraits
private double deltaTraits(int a, int b) Measure the (Cartesian) distance between traits ataandb- Parameters:
a- the index where the traits of the first individual startb- the index where the traits of the second individual start- Returns:
- the distance between
aandb
-
gatherPlayers
Gather the traits of all individuals in the interaction groupgroup.- Parameters:
group- the interaction group
-
doAdjustScores
protected boolean doAdjustScores()Description copied from class:IBSPopulationCheck if scores can be adjusted rather than recalculated after an individual changed its trait. This requires that individuals interact with all their neighbours and that the structure of the population is not well-mixed. Some implementations may be able to extend adjustments to other structures. For example, adjusting scores is feasible in well-mixed populations for discrete traits.Requirements:
- Group.SAMPLING_ALL
- individuals need to be interacting with all their neighbours (not just a randomly selected subset).
- AbstractGeometry.MEANFIELD
- interactions with everyone are not feasible (impossible to model
efficiently), in general, for unstructured populations (subclasses can do
better, e.g. for discrete trait it is possible, see
IBSDPopulation.doAdjustScores()). - playerScoreReset
- if scores are reset whenever an individual adopts the trait of another (regardless of whether an actual trait change occurred) then the expected number of interactions of each individual remains constant over time (even though the interaction count may differ for individuals on heterogeneous structures).
- Specified by:
doAdjustScoresin classIBSPopulation<Continuous, IBSMCPopulation>- Returns:
trueif adjusting scores is feasible- See Also:
-
adjustScoreAt
public void adjustScoreAt(int index, double before, double after) Description copied from class:IBSPopulationAdjust score of individual with indexindexfrombeforetoafterand update all applicable helper variables, e.g.sumFitness.Important: Use only to adjust scores of individuals that did not change trait.
- Specified by:
adjustScoreAtin classIBSPopulation<Continuous, IBSMCPopulation>- Parameters:
index- the index of the individualbefore- the score before adjustmentsafter- the score after adjustments
-
adjustScoreAt
public void adjustScoreAt(int index, double adjust) Description copied from class:IBSPopulationAdjust score of individual with indexindexbyadjustand update all applicable helper variables, e.g.sumFitness.- Specified by:
adjustScoreAtin classIBSPopulation<Continuous, IBSMCPopulation>- Parameters:
index- the index of the individualadjust- the score adjustment
-
playPairGameAt
Play a pairwise interaction with the individuals ingroup.Continuous modules with a single trait never get here.
- Specified by:
playPairGameAtin classIBSPopulation<Continuous, IBSMCPopulation>- Parameters:
group- the group of individuals interacting in pairs- See Also:
-
adjustPairGameScoresAt
public void adjustPairGameScoresAt(int me) Adjusts scores of focal individual with indexmeand its neighbors aftermechanged trait. Only works ifadjustScores==true.Important: new trait must not yet have been committed.
Continuous modules with a single trait never get here.
- Specified by:
adjustPairGameScoresAtin classIBSPopulation<Continuous, IBSMCPopulation>- Parameters:
me- the index of the focal individual- See Also:
-
playGroupGameAt
Play a group interaction with the individuals ingroup.Continuous modules with a single trait never get here.
- Specified by:
playGroupGameAtin classIBSPopulation<Continuous, IBSMCPopulation>- Parameters:
group- the group of interacting individuals- See Also:
-
playNoGameAt
void playNoGameAt(int me) Handle the case where a focal player has no opponents and should not play a game.- Parameters:
me- focal player index
-
playGroupSequentiallyAt
Evaluate sequential group interactions when not enough opponents are available simultaneously.- Parameters:
me- focal player indexgroup- sampled opponent groupnGroup- number of players participating in each interaction
-
playGroupOnceAt
Evaluate a single group interaction with the sampled opponents.- Parameters:
me- focal player indexgroup- sampled opponent group
-
yalpGroupGameAt
Counterpart ofIBSPopulation.playGroupGameAt(IBSGroup),IBSPopulation.playGameAt(int)and/orIBSPopulation.playGameSyncAt(int). Removes the payoffs of group interactions.Continuous modules with a single trait never get here.
- Specified by:
yalpGroupGameAtin classIBSPopulation<Continuous, IBSMCPopulation>- Parameters:
group- the interaction group- See Also:
-
prepareTraits
public void prepareTraits()Description copied from class:IBSPopulationPrior to a synchronous update step the current state must be duplicated in preparation for processing the next step.- Specified by:
prepareTraitsin classIBSPopulation<Continuous, IBSMCPopulation>- See Also:
-
commitTraits
public void commitTraits()Description copied from class:IBSPopulationAfter a synchronous update step the new state must be copied back to become the current state.- Specified by:
commitTraitsin classIBSPopulation<Continuous, IBSMCPopulation>- See Also:
-
commitTraitAt
public void commitTraitAt(int me) Description copied from class:IBSPopulationThe change of a trait of the player atindexis stored in a temporary variable and must be committed before proceeding.- Specified by:
commitTraitAtin classIBSPopulation<Continuous, IBSMCPopulation>- Parameters:
me- the index of the player that needs to have its new trait committed
-
getTraitData
Description copied from class:IBSPopulationReturns the traits of all individuals in this population coded as colors in the arraycolorsusing the mapcolorMap. Used by GUI to visualize the current state of this IBS model. Colors are coded in different data types<T>depending on the runtime environment (GWT or JRE) as well as the graph (e.g.PopGraph2DorPopGraph3D).- Specified by:
getTraitDatain classIBSPopulation<Continuous, IBSMCPopulation>- Type Parameters:
T- the type of color data (StringorMeshLambertMaterialfor GWT andColorfor JRE).- Parameters:
colors- the array where the colors of all nodes are storedcolorMap- the map that converts traits into colors
-
getTraitHistogramData
public void getTraitHistogramData(double[][] bins) Creates a histogram for each trait separately (if there are multiple) and returns the result in the arraybinswhere the first index denotes the trait and the second refers to the bin.- Parameters:
bins- the array to store the histogram(s)
-
getTraitHistogramData
public void getTraitHistogramData(double[] bins, int trait) Creates a histogram for the trait with indextraitand returns the result in the arraybins.- Parameters:
bins- the array to store the histogram(s)trait- the index of the trait
-
get2DTraitHistogramData
public void get2DTraitHistogramData(double[] bins, int trait1, int trait2) Creates 2D histogram for traitstrait1andtrait2. The result is returned in the linear arraybinsand arranged in a way that is compatible with square lattice geometries for visualization byDistributionandPopGraph2D(GWT only).- Parameters:
bins- the linear array to store the 2D histogramtrait1- the index of the first traittrait2- the index of the second trait
-
getTraits
Gets all traits of all individuals. The traits are returned as a formatted string with an accuracy ofdigitsdecimals. With multiple traits they are listed sequentially for each individual.- Parameters:
digits- the number of decimals of the formatted string- Returns:
- the formatted traits
-
getTraitNameAt
Description copied from class:IBSPopulationGets the formatted name of the trait of the individual at siteindex.- Specified by:
getTraitNameAtin classIBSPopulation<Continuous, IBSMCPopulation>- Parameters:
index- the index of the- Returns:
- the string describing the trait
-
getMeanTraits
public double[] getMeanTraits(double[] mean) Returns the mean trait(s) of this population in the arraymean. Used by GUI to visualize the current state of this IBS model.For continuous traits the first
nTraitsentries represent the mean of each trait and the secondnTraitsentries denote the standard deviation.- Specified by:
getMeanTraitsin classIBSPopulation<Continuous, IBSMCPopulation>- Parameters:
mean- the array for returning the trait values- Returns:
- the array
meancontaining the mean trait values - See Also:
-
getMinTraits
public double[] getMinTraits()Gets the minimal value of each trait in the population and stores it in the arraymin. The array must be of length>= nTraits.- Returns:
- the array with the minimal trait values (same as input)
-
getMinTraits
public double[] getMinTraits(double[] min) Gets the minimal value of each trait in the population and stores it in the arraymin. The array must be of length>= nTraits.- Parameters:
min- the array to store the minimal trait values- Returns:
- the array with the minimal trait values (same as input)
-
getMaxTraits
public double[] getMaxTraits()Gets the maximal value of each trait in the population and stores it in the arraymax.- Returns:
- the array with the maximal trait values (same as input)
-
getMaxTraits
public double[] getMaxTraits(double[] max) Gets the maximal value of each trait in the population and stores it in the arraymax. The array must be of length>= nTraits.- Parameters:
max- the array to store the maximal trait values- Returns:
- the array with the maximal trait values (same as input)
-
getMeanFitness
public double[] getMeanFitness(double[] mean) Returns the mean fitness of this population in the arraymean. Used by GUI to visualize the current state of this IBS model. Returnstrueif data point belongs to the same time series andfalseif a new series was started throughIBSPopulation.init()orIBSPopulation.reset().For continuous traits the first
nTraitsentries represent the mean fitness of each trait and the secondnTraitsentries denote their standard deviation.- Specified by:
getMeanFitnessin classIBSPopulation<Continuous, IBSMCPopulation>- Parameters:
mean- the array for storing the mean fitness values- Returns:
- the array
meancontaining the mean fitness values - See Also:
-
addState
public void addState(double[] state) Adds the traits of all individuals to the arraystate. The array must be of lengthnPopulation * nTraits.- Parameters:
state- the array to store the traits
-
getStatus
Description copied from class:IBSPopulationGets the status of the as a formatted string. This is typically used in the GUI to summarize the progress of the model.- Specified by:
getStatusin classIBSPopulation<Continuous, IBSMCPopulation>- Returns:
- the status of the population
-
check
public boolean check()Description copied from class:IBSPopulationCheck all model parameters for consistency and adjust if necessary (and feasible). Returnstrueif adjustments require a reset. Free memory if possible and request a reset if new memory needs to be allocated.- Overrides:
checkin classIBSPopulation<Continuous, IBSMCPopulation>- Returns:
trueif reset is required- See Also:
-
setInit
Sets the type of the initial configuration and any accompanying arguments. If eithertypeorargsarenullthe respective current setting is preserved.- Parameters:
init- the type and arguments of the initial configuration
-
getInit
Gets the type of the initial configuration and its arguments.- Returns:
- the type and arguments of the initial configuration
-
init
public void init()Description copied from class:IBSPopulationInitialize the model. All parameters must be consistent. Subclasses must override this method to generate the initial trait configuration and call super.Note: Initialization leaves the interaction and competition structures untouched
- Overrides:
initin classIBSPopulation<Continuous, IBSMCPopulation>- See Also:
-
initUniform
void initUniform()Initialize each trait uniformly at random in its allowed range. -
initMono
void initMono()Initialize all individuals with the same (monomorphic) trait value. -
initGaussian
void initGaussian()Initialize traits by sampling from a (possibly truncated) Gaussian distribution per trait. -
initMutant
void initMutant()Initialize a monomorphic resident population with a single mutant. -
reset
public void reset()Description copied from class:IBSPopulationReset the model. All parameters must be consistent at this point. Allocate memory and initialize the interaction and competition structures. If structures include random elements, e.g. random regular graphs, a new structure is generated. Generate initial configuration. Subclasses must override this method to allocate memory for the trait and call super.- Overrides:
resetin classIBSPopulation<Continuous, IBSMCPopulation>- See Also:
-
mouseHitNode
public boolean mouseHitNode(int hit, boolean alt) Description copied from class:IBSPopulationCalled from GUI if node/individual with indexidxreceived a mouse click or tap and indicates whether thealt-key had been pressed.- Overrides:
mouseHitNodein classIBSPopulation<Continuous, IBSMCPopulation>- Parameters:
hit- the index of the nodealt-trueif thealt-key was pressed- Returns:
falseif no actions taken
-
encodeTraits
Description copied from class:IBSPopulationEncode the traits of all individuals in the IBS model in aplistinspiredXMLstring.- Specified by:
encodeTraitsin classIBSPopulation<Continuous, IBSMCPopulation>- Parameters:
plist- theStringBuilderto write the encoded state to- See Also:
-
restoreTraits
Description copied from class:IBSPopulationRestore the traits of all individuals encoded in theplistinspiredmapofkey, value-pairs.- Specified by:
restoreTraitsin classIBSPopulation<Continuous, IBSMCPopulation>- Parameters:
plist- the map ofkey, value-pairs- Returns:
trueif successful- See Also:
-