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.GeometricThe distribution for migration events.protected RNGDistribution.GeometricThe distribution for migration events.(package private) booleanThe flag to indicate whether to optimize migration.protected doubleTime of previous sample.private double[]The time spent in homogenous states.Fields inherited from class TBT.IBSPop
tsFit, tsFits, tsMean, tsTraitsFields inherited from class IBSDPopulation
accuTypeScores, active, groupmodule, init, initCount, module, mutation, opponent, optimizeMoran, pairmodule, traitsCount, traitsNextFields 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 TypeMethodDescriptionvoidadjustGameScoresAt(int me) Adjust scores of focal playermeand its neighbours (interaction partners).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.voidPerform 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.voidPerform 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 intDetermine the number of homogeneous demes in trait A, provided that all demes are homogeneous.voidinit()Initialize the model.voidmodelChanged(ChangeListener.PendingAction pending) Called whenever the state of the EvoLudo model changed.voidCalled after a running EvoLudo model stopped because the model converged (or reached an absorbing state).protected voidReset statistics.protected voidStart collecting statistics.protected voidupdatePlayerMoranBirthDeathAt(int parent) Perform a Moran (Birth-death) update for the focal individual with indexparentto produce a clonal offspring and replace one of the parent's neighbours selected uniformly at random.voidUpdate the scores of all individuals in the population.protected voidupdateStatistics(double time) Update statistics.Methods inherited from class TBT.IBSPop
getMeanFitness, getMeanTraits, getNMean, getTraitNameAt, initKaleidoscopeMethods inherited from class IBSDPopulation
adjustPairGameScoresAt, adjustScoreAt, adjustScoreAt, becomesVacantAt, countTraits, debugMarkChange, doAdjustScores, encodeTraits, getFitnessAt, getFitnessHistogramData, getInit, getInitialTraits, getMonoScore, getPopulationSize, getScoreAt, getTraitAt, getTraitData, getTraits, getTraitsCount, haveSameTrait, initFrequency, initMono, initMono, initMono, initMutant, initStripes, initTemperature, initUniform, isConsistent, isMonomorphic, isSameTrait, isVacantAt, maybeMutateAt, maybeMutateMoran, mouseHitNode, mutateAt, playGroupGameAt, playPairGameAt, preferredPlayerBest, prepareTraits, reset, resetScoreAt, resetScores, resetTraits, restoreFitness, restoreTraits, setInit, setInitialTraits, setNextTraitAt, setOpponentPop, setScoreAt, setTraitAt, stripGroupVacancies, stripVacancies, swapTraits, updateFromModelAt, updateMixedMeanScores, updatePlayerBestResponse, updatePlayerEcologyAt, updatePlayerMoranBirthDeath, updatePlayerMoranDeathBirth, updatePlayerMoranDeathBirth, updatePlayerMoranImitate, updateScoreAt, updateTraitCount, yalpGroupGameAtMethods 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, getSpeciesUpdateRate, 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, updatePlayerAt, updatePlayerBest, updatePlayerBestHalf, updatePlayerEcology, updatePlayerMoranDeathBirthAt, updatePlayerMoranImitateAt, updatePlayerSwap, updateProportionalAbs, updateReplicatorHalf, updateReplicatorPlus, updateScoreAt, updateScoreAt, updateThermalMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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: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 classTBT.IBSPop- Returns:
trueif reset is required- See Also:
-
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 classIBSDPopulation- See Also:
-
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.- Overrides:
getStatusin classTBT.IBSPop- Returns:
- the status of the population
-
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 classIBSDPopulation- Returns:
trueif converged.
-
homoDemes
protected int homoDemes()Determine the number of homogeneous demes in trait A, provided that all demes are homogeneous. Returns-1if any deme is heterogeneous.- Returns:
- the number of homogeneous A demes or
-1if 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:
doDiffusionMigrationin 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:
doDeathBirthMigrationin classIBSPopulation
-
updatePlayerMoranBirthDeathAt
protected void updatePlayerMoranBirthDeathAt(int parent) Description copied from class:IBSPopulationPerform a Moran (Birth-death) update for the focal individual with indexparentto 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:
updatePlayerMoranBirthDeathAtin classIBSPopulation- Parameters:
parent- the index of the parent
-
modelChanged
Description copied from interface:ChangeListenerCalled 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 asRESETandINITthat in turn triggermodelReset()andmodelInit(), respectively.- Specified by:
modelChangedin interfaceChangeListener- Parameters:
pending- pending action that needs to be processed.- See Also:
-
modelStopped
public void modelStopped()Description copied from interface:MilestoneListenerCalled after a running EvoLudo model stopped because the model converged (or reached an absorbing state).- Specified by:
modelStoppedin 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
-
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.- Overrides:
commitTraitAtin classIBSDPopulation- Parameters:
me- the index of the player that needs to have its new trait committed
-
commitTraits
public void commitTraits()Description copied from class:IBSDPopulationAfter a synchronous update step the new state must be copied back to become the current state.For discrete modules, update the trait count of each type and check if population reached a homogeneous state.
- Overrides:
commitTraitsin 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:
updateScoresin classIBSDPopulation
-
adjustGameScoresAt
public void adjustGameScoresAt(int me) Adjust scores of focal playermeand its neighbours (interaction partners).Requirements/notes:
- This optimized method is only applicable if
IBSGroup.SamplingType.ALLis 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 trait 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:
adjustGameScoresAtin classIBSDPopulation- Parameters:
me- the index of the focal individual- See Also:
- This optimized method is only applicable if
-