Package org.evoludo.simulator.models
Class IBSCPopulation
Object
IBSPopulation
IBSMCPopulation
IBSCPopulation
The core class for individual based simulations with a single
continuous trait. As compared to the more generic
IBSMCPopulation
this subclass takes advantage of simplifications that are possible for a
single trait.- Author:
- Christoph Hauert
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected IBS.HasIBS.CGroups
For group interaction modulesmodule==groupmodule
holds andnull
otherwise.(package private) double
Temporary storage for the traits of the focal individual.(package private) IBSCPopulation
The interaction partner/opponent of this populationopponent.getModule()==getModule().getOpponent()
.protected IBS.HasIBS.CPairs
For pairwise interaction modulesmodule==pairmodule
holds andnull
otherwise.Fields inherited from class IBSMCPopulation
init, module, mutation, oldScores, oldTrait, smallTrait, tmpGroup, traitMax, traitMin, traits, traitsNext
Fields inherited from class IBSPopulation
adjustScores, competition, compGroup, consistencyCheckRequested, debugFocal, debugModel, debugModels, debugNModels, debugSame, distrMigrants, engine, fitness, groupScores, hasLookupTable, interaction, interactions, interGroup, isConsistent, isMultispecies, isNeutral, logger, map2fit, maxEffScoreIdx, maxFitness, maxScore, migrationType, minFitness, minScore, nMixedInter, nPopulation, nTraits, pAddwire, playerScoreAveraged, playerScoring, playerUpdate, pMigration, populationUpdate, pRewire, rng, scores, smallScores, staticmodule, sumFitness, syncFraction, tags, typeFitness, typeScores, VACANT
-
Constructor Summary
ConstructorsConstructorDescriptionIBSCPopulation
(EvoLudo engine, Continuous module) Creates a population of individuals with a single continuous trait for IBS simulations. -
Method Summary
Modifier and TypeMethodDescriptionvoid
adjustPairGameScoresAt
(int me) Adjusts scores of focal individual with indexme
and its neighbors afterme
changed trait.void
commitTraitAt
(int me) The change of a trait of the player atindex
is stored in a temporary variable and must be committed before proceeding.void
getTraitHistogramData
(double[] bins) Creates a histogram fortrait
and returns the result in the arraybins
.boolean
haveSameTrait
(int a, int b) Check if individuals with indexa
and indexb
have the same traits.boolean
isSameTrait
(int a) Check if individual with indexa
has switched traits.void
playGroupGameAt
(IBSGroup group) Play a group interaction with the individuals ingroup
.void
playPairGameAt
(IBSGroup group) Play a pairwise interaction with the individuals ingroup
.void
Prior to a synchronous update step the current state must be duplicated in preparation for processing the next step.void
setOpponentPop
(IBSPopulation opponent) Set the interaction partner/opponent of this population.void
swapTraits
(int a, int b) Swap traits of individuals with indexa
and indexb
.void
yalpGroupGameAt
(IBSGroup group) Counterpart ofIBSPopulation.playGroupGameAt(IBSGroup)
,IBSPopulation.playGameAt(int)
and/orIBSPopulation.playGameSyncAt(int)
.Methods inherited from class IBSMCPopulation
adjustScoreAt, adjustScoreAt, check, checkConvergence, commitTraits, doAdjustScores, encodeTraits, get2DTraitHistogramData, getInit, getMeanFitness, getMeanTraits, getStatus, getTraitData, getTraitHistogramData, getTraitHistogramData, getTraitMax, getTraitMin, getTraitNameAt, getTraits, init, maybeMutateAt, maybeMutateMoran, mouseHitNode, mutateAt, preferredPlayerBest, reset, restoreTraits, setInit, updateFromModelAt
Methods inherited from class IBSPopulation
adjustGameScoresAt, becomesVacantAt, checkGeometry, createCompetitionGeometry, createInteractionGeometry, debugMarkChange, debugScores, debugUpdatePopulationAt, doBirthDeathMigration, doDeathBirthMigration, doDiffusionMigration, doMigration, doSyncMigration, encodeFitness, encodeGeometry, encodeInteractions, generateGeometry, getCompetitionGeometry, getCompGroup, getFitness, getFitnessAt, getFitnessData, getFitnessHistogramData, getFitnessNameAt, getFitnessNameAt, getInteractionGeometry, getInteractionsAt, getInterGroup, getMaxScore, getMigrationProb, getMigrationType, getMinScore, getModule, getNMean, getPlayerScoreAveraged, getPlayerScoring, getPopulationSize, getPopulationUpdate, getScoreAt, getScoreNameAt, getScores, getSpeciesUpdateRate, getSyncFraction, getTagAt, getTagData, getTagNameAt, getTags, getTotalFitness, isConsistent, isMonomorphic, isVacantAt, migrateMoran, mouseHitNode, mutate, nextBinomial, parseGeometry, pickFitFocalIndividual, pickFitFocalIndividual, pickFitNeighborAt, pickFitNeighborAt, pickFocalIndividual, pickFocalIndividual, pickFocalSite, pickFocalSite, pickNeighborSiteAt, playGameAt, playGameSyncAt, processScore, random01, random01d, random0n, random0N, randomGaussian, removeScoreAt, removeScoreAt, resetScoreAt, resetScores, resetTraits, restoreFitness, restoreGeometry, restoreInteractions, setAddwire, setConsistencyCheck, setMaxEffScoreIdx, setMigrationProb, setMigrationType, setPlayerScoreAveraged, setPlayerScoring, setPopulationUpdate, setRewire, setScoreAt, setSyncFraction, setTagAt, srandom, 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==pairmodule
holds andnull
otherwise. Convenience field to reduce the number of (unnecessary) casts.- See Also:
-
groupmodule
For group interaction modulesmodule==groupmodule
holds andnull
otherwise. Convenience field to reduce the number of (unnecessary) casts.- See Also:
-
opponent
IBSCPopulation opponentThe interaction partner/opponent of this populationopponent.getModule()==getModule().getOpponent()
. In intra-species interactionsopponent==this
. Convenience field.Note: This deliberately hides
IBSPopulation.opponent
. The two variables point to the same object but this setup avoids unnecessary casts because onlyDiscrete
modules generateIBSDPopulation
(s). -
myTrait
double myTraitTemporary storage for the traits of the focal individual. This deliberately hides the array of the same name inIBSMCPopulation
.
-
-
Constructor Details
-
IBSCPopulation
Creates a population of individuals with a single continuous trait for IBS simulations.- Parameters:
engine
- the pacemaker for running the modelmodule
- the module that defines the rules of the game
-
-
Method Details
-
setOpponentPop
Description copied from class:IBSPopulation
Set the interaction partner/opponent of this population.- Overrides:
setOpponentPop
in classIBSMCPopulation
- Parameters:
opponent
- the interaction partner/opponent
-
haveSameTrait
public boolean haveSameTrait(int a, int b) Description copied from class:IBSPopulation
Check if individuals with indexa
and indexb
have the same traits.- Overrides:
haveSameTrait
in classIBSMCPopulation
- Parameters:
a
- the index of first individualb
- the index of second individual- Returns:
true
if the two individuals have the same traits
-
isSameTrait
public boolean isSameTrait(int a) Description copied from class:IBSPopulation
Check if individual with indexa
has switched traits.Note: this test is only meaningful before trait are committed.
- Overrides:
isSameTrait
in classIBSMCPopulation
- Parameters:
a
- index of individual- Returns:
true
if trait remained unchanged- See Also:
-
swapTraits
public void swapTraits(int a, int b) Description copied from class:IBSPopulation
Swap traits of individuals with indexa
and indexb
.Note: the traits still need to be committed.
- Overrides:
swapTraits
in classIBSMCPopulation
- Parameters:
a
- the index of first individualb
- the index of second individual- See Also:
-
playPairGameAt
Description copied from class:IBSPopulation
Play a pairwise interaction with the individuals ingroup
.- Overrides:
playPairGameAt
in classIBSMCPopulation
- Parameters:
group
- the group of individuals interacting in pairs
-
adjustPairGameScoresAt
public void adjustPairGameScoresAt(int me) Description copied from class:IBSPopulation
Adjusts scores of focal individual with indexme
and its neighbors afterme
changed trait. Only works ifadjustScores==true
.Important: new trait must not yet have been committed.
- Overrides:
adjustPairGameScoresAt
in classIBSMCPopulation
- Parameters:
me
- the index of the focal individual
-
playGroupGameAt
Description copied from class:IBSPopulation
Play a group interaction with the individuals ingroup
.- Overrides:
playGroupGameAt
in classIBSMCPopulation
- Parameters:
group
- the group of interacting individuals
-
yalpGroupGameAt
Description copied from class:IBSPopulation
Counterpart ofIBSPopulation.playGroupGameAt(IBSGroup)
,IBSPopulation.playGameAt(int)
and/orIBSPopulation.playGameSyncAt(int)
. Removes the payoffs of group interactions.- Overrides:
yalpGroupGameAt
in classIBSMCPopulation
- Parameters:
group
- the interaction group
-
prepareTraits
public void prepareTraits()Description copied from class:IBSPopulation
Prior to a synchronous update step the current state must be duplicated in preparation for processing the next step.- Overrides:
prepareTraits
in classIBSMCPopulation
- See Also:
-
commitTraitAt
public void commitTraitAt(int me) Description copied from class:IBSPopulation
The change of a trait of the player atindex
is stored in a temporary variable and must be committed before proceeding.- Overrides:
commitTraitAt
in classIBSMCPopulation
- Parameters:
me
- the index of the player that needs to have its new trait committed
-
getTraitHistogramData
public void getTraitHistogramData(double[] bins) Creates a histogram fortrait
and returns the result in the arraybins
.- Parameters:
bins
- the array to store the histogram(s)
-