Class DemesTBT.IBSPop
- All Implemented Interfaces:
ChangeListener
,MilestoneListener
- Enclosing class:
DemesTBT
-
Nested Class Summary
Nested classes/interfaces inherited from interface ChangeListener
ChangeListener.PendingAction
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) int[][]
The number of traits in each deme.protected RNGDistribution.Geometric
The distribution for migration events.protected RNGDistribution.Geometric
The distribution for migration events.(package private) boolean
The flag to indicate whether to optimize migration.protected double
Time of previous sample.private double[]
The time spent in homogenous states.Fields inherited from class TBT.IBSPop
tsFit, tsFits, tsMean, tsTraits
Fields inherited from class IBSDPopulation
accuTypeScores, groupmodule, init, initTypeCount, module, mutation, optimizeMoran, pairmodule, strategies, strategiesScratch, strategiesTypeCount
Fields inherited from class IBSPopulation
adjustScores, competition, compGroup, debugFocal, debugModel, debugModels, debugNModels, debugSame, distrMigrants, engine, fitness, groupScores, hasLookupTable, interaction, interactions, interGroup, isMultispecies, isNeutral, logger, map2fit, maxEffScoreIdx, maxFitness, maxScore, migrationType, minFitness, minScore, nMixedInter, nPopulation, nTraits, pAddwire, playerScoreAveraged, playerScoring, pMigration, pRewire, rng, scores, smallScores, staticmodule, sumFitness, tags, typeFitness, typeScores, VACANT
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
adjustGameScoresAt
(int me) Adjust scores of focal playerme
and its neighbours (interaction partners).boolean
check()
Check all model parameters for consistency and adjust if necessary (and feasible).boolean
Check if population has converged.void
After a synchronous update step the new state must be copied back to become the current state.void
commitStrategyAt
(int me) The change of a strategy of the player atindex
is stored in a temporary variable and must be committed before proceeding.void
Perform a death-birth migration, where a member of the population (selected uniformly at random) dies and the remaining individuals compete to repopulate the vacant site.void
Perform diffusion migration, which is implemented as two players swap their locations while leaving their respective neighbourhood structure untouched.Gets the status of the as a formatted string.protected int
Determine the number of homogeneous demes in trait A, provided that all demes are homogeneous.void
init()
Initialize the model.void
modelChanged
(ChangeListener.PendingAction pending) Called whenever the state of the EvoLudo model changed.void
Called after a running EvoLudo model stopped because the model converged (or reached an absorbing state).protected void
Reset statistics.protected void
Start collecting statistics.protected void
updatePlayerMoranBirthDeathAt
(int parent) Perform a Moran (Birth-death) update for the focal individual with indexparent
to produce a clonal offspring and replace one of the parent's neighbours selected uniformly at random.void
Update the scores of all individuals in the population.protected void
updateStatistics
(double time) Update statistics.Methods inherited from class TBT.IBSPop
getMeanFitness, getMeanTraits, getNMean, getTraitNameAt, initKaleidoscope
Methods inherited from class IBSDPopulation
adjustPairGameScoresAt, adjustScoreAt, adjustScoreAt, becomesVacantAt, countTraits, debugMarkChange, doAdjustScores, encodeStrategies, getFitnessAt, getFitnessHistogramData, getInit, getInitialTraits, getMonoScore, getPopulationSize, getScoreAt, getStrategiesTypeCount, getTraitData, getTraits, haveSameStrategy, initFrequency, initMono, initMutant, initStripes, initTemperature, initUniform, isConsistent, isMonomorphic, isSameStrategy, isVacantAt, maybeMutateAt, maybeMutateMoran, mouseHitNode, mutateAt, playGroupGameAt, playPairGameAt, preferredPlayerBest, prepareStrategies, reset, resetScoreAt, resetScores, resetStrategies, restoreFitness, restoreStrategies, setInit, setInitialTraits, setOpponentPop, setScoreAt, stripGroupVacancies, stripVacancies, swapStrategies, updateFromModelAt, updateMixedMeanScores, updatePlayerBestResponse, updatePlayerEcologyAt, updatePlayerMoranBirthDeath, updatePlayerMoranDeathBirth, updatePlayerMoranDeathBirth, updatePlayerMoranImitate, updateScoreAt, updateStrategiesTypeCount, yalpGroupGameAt
Methods inherited from class IBSPopulation
checkGeometry, createCompetitionGeometry, createInteractionGeometry, debugScores, debugUpdatePopulationAt, doBirthDeathMigration, doMigration, doSyncMigration, encodeFitness, encodeGeometry, encodeInteractions, generateGeometry, getCompetitionGeometry, getCompGroup, getFitness, getFitnessData, getFitnessNameAt, getFitnessNameAt, getInteractionGeometry, getInteractionsAt, getInterGroup, getMaxScore, getMigrationProb, getMigrationType, getMinScore, getModule, getPlayerScoreAveraged, getPlayerScoring, getPopulationUpdate, getScoreNameAt, getScores, getSyncFraction, getTagAt, getTagData, getTagNameAt, getTags, getTotalFitness, migrateMoran, mouseHitNode, mutate, nextBinomial, parseGeometry, pickFitFocalIndividual, pickFitFocalIndividual, pickFitNeighborAt, pickFitNeighborAt, pickFocalIndividual, pickFocalIndividual, pickFocalSite, pickFocalSite, pickNeighborSiteAt, playGameAt, playGameSyncAt, processScore, random01, random01d, random0n, random0N, randomGaussian, removeScoreAt, removeScoreAt, restoreGeometry, restoreInteractions, setAddwire, setConsistencyCheck, setMaxEffScoreIdx, setMigrationProb, setMigrationType, setPlayerScoreAveraged, setPlayerScoring, setPopulationUpdate, setRewire, setSyncFraction, setTagAt, srandom, step, swapScoresAt, updateEffScoreRange, updateFitnessAt, updateMinMaxScores, updatePlayerAsync, updatePlayerAsyncAt, updatePlayerAt, updatePlayerBest, updatePlayerBestHalf, updatePlayerEcology, updatePlayerMoranDeathBirthAt, updatePlayerMoranImitateAt, updatePlayerSwap, updateProportionalAbs, updateReplicatorHalf, updateReplicatorPlus, updateScoreAt, updateScoreAt, updateThermal
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface MilestoneListener
modelDidInit, modelDidReset, modelLoaded, modelRelaxed, modelRunning, modelSettings, modelUnloaded, moduleLoaded, moduleRestored, moduleUnloaded
-
Field Details
-
distrMigration
The distribution for migration events. -
distrMutationMigration
The distribution for migration events. -
pure
private double[] pureThe time spent in homogenous states. -
demeTypeCount
int[][] demeTypeCountThe number of traits in each deme. -
optimizeMigration
boolean optimizeMigrationThe flag to indicate whether to optimize migration. -
prevsample
protected double prevsampleTime of previous sample.
-
-
Constructor Details
-
IBSPop
Create a new instance of the IBSPop class.- Parameters:
engine
- the pace maker of the simulationmodule
- the module that defines the interactions
-
-
Method Details
-
check
public boolean check()Description copied from class:IBSPopulation
Check all model parameters for consistency and adjust if necessary (and feasible). Returnstrue
if adjustments require a reset. Free memory if possible and request a reset if new memory needs to be allocated.- Overrides:
check
in classTBT.IBSPop
- Returns:
true
if reset is required- See Also:
-
init
public void init()Description copied from class:IBSPopulation
Initialize the model. All parameters must be consistent. Subclasses must override this method to generate the initial strategy configuration and call super.Note: Initialization leaves the interaction and competition structures untouched
- Overrides:
init
in classIBSDPopulation
- See Also:
-
getStatus
Description copied from class:IBSPopulation
Gets the status of the as a formatted string. This is typically used in the GUI to summarize the progress of the model.- Overrides:
getStatus
in classTBT.IBSPop
- Returns:
- the status of the population
-
checkConvergence
public boolean checkConvergence()Description copied from class:IBSPopulation
Check if population has converged. By defaulttrue
if 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:
checkConvergence
in classIBSDPopulation
- Returns:
true
if converged.
-
homoDemes
protected int homoDemes()Determine the number of homogeneous demes in trait A, provided that all demes are homogeneous. Returns-1
if any deme is heterogeneous.- Returns:
- the number of homogeneous A demes or
-1
if any deme is heterogeneous
-
doDiffusionMigration
public void doDiffusionMigration()Perform diffusion migration, which is implemented as two players swap their locations while leaving their respective neighbourhood structure untouched.Override IBSPopulation.doDiffusionMigration() to take demes into account.
- Overrides:
doDiffusionMigration
in classIBSPopulation
-
doDeathBirthMigration
public void doDeathBirthMigration()Perform a death-birth migration, where a member of the population (selected uniformly at random) dies and the remaining individuals compete to repopulate the vacant site. One competitor succeeds with a probability proportional proportional to fitness.Note: This is almost identical to Moran (birth-death) updating in well-mixed populations
- Override IBSPopulation.doDeathBirthMigration() to take demes into account.
- Almost identical (victim and migrant always different) to Moran (death-birth) updating in well-mixed population.
- Overrides:
doDeathBirthMigration
in classIBSPopulation
-
updatePlayerMoranBirthDeathAt
protected void updatePlayerMoranBirthDeathAt(int parent) Description copied from class:IBSPopulation
Perform a Moran (Birth-death) update for the focal individual with indexparent
to produce a clonal offspring and replace one of the parent's neighbours selected uniformly at random. This is the original Moran process where the offspring can replace the parent in well-mixed populations.- Overrides:
updatePlayerMoranBirthDeathAt
in classIBSPopulation
- Parameters:
parent
- the index of the parent
-
modelChanged
Description copied from interface:ChangeListener
Called whenever the state of the EvoLudo model changed. Process potentially pending requests.Note: the model may process some pending actions directly and without notifying the listeners through
modelChanged(PendingAction)
first. In particular, this applies to pending actions that fire their own notifications, such asRESET
andINIT
that in turn triggermodelReset()
andmodelInit()
, respectively.- Specified by:
modelChanged
in interfaceChangeListener
- Parameters:
pending
- pending action that needs to be processed.- See Also:
-
modelStopped
public void modelStopped()Description copied from interface:MilestoneListener
Called after a running EvoLudo model stopped because the model converged (or reached an absorbing state).- Specified by:
modelStopped
in interfaceMilestoneListener
-
startStatistics
protected void startStatistics()Start collecting statistics. -
resetStatistics
protected void resetStatistics()Reset statistics. -
updateStatistics
protected void updateStatistics(double time) Update statistics.- Parameters:
time
- the time of the sample
-
commitStrategyAt
public void commitStrategyAt(int me) Description copied from class:IBSPopulation
The change of a strategy of the player atindex
is stored in a temporary variable and must be committed before proceeding.- Overrides:
commitStrategyAt
in classIBSDPopulation
- Parameters:
me
- the index of the player that needs to have its new strategy committed
-
commitStrategies
public void commitStrategies()Description copied from class:IBSDPopulation
After a synchronous update step the new state must be copied back to become the current state.For discrete modules, update the strategy count of each type and check if population reached a homogeneous state.
- Overrides:
commitStrategies
in classIBSDPopulation
- See Also:
-
updateScores
public void updateScores()Update the scores of all individuals in the population.Note: Overridden to set scores in well-mixed populations more efficiently.
Overridden to set scores in demes more efficiently
- Overrides:
updateScores
in classIBSDPopulation
-
adjustGameScoresAt
public void adjustGameScoresAt(int me) Adjust scores of focal playerme
and its neighbours (interaction partners).Requirements/notes:
- This optimized method is only applicable if
IBSGroup.SamplingType.ALL
is true and notGeometry.Type.MEANFIELD
, i.e. if the interaction group includes all neighbors but not all other members of the population. - For pairwise interactions more efficient approaches are possible but those require direct access to the stratgies and are hence delegated to subclasses.
Overridden to allow for adjusting scores in well-mixed populations.
Overridden to set scores in demes more efficiently
- Overrides:
adjustGameScoresAt
in classIBSDPopulation
- Parameters:
me
- the index of the focal individual- See Also:
- This optimized method is only applicable if
-