Package org.evoludo.simulator.models
Class IBSCPopulation
Object
IBSPopulation
IBSMCPopulation
IBSCPopulation
The core class for individual based simulations with a single
continuous trait/strategy. As compared to the more generic
IBSMCPopulation
this subclass takes advantage of simplifications that
are possible for a single trait/strategy.- Author:
- Christoph Hauert
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected IBS.HasIBS.CGroups
For group interaction modulesmodule==groupmodule
holds andnull
otherwise.(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
groupStrat, init, module, mutation, myTrait, oldScores, oldTrait, smallStrat, strategies, strategiesScratch, traitMax, traitMin
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 strategy.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
getTraitHistogramData
(double[] bins) Creates a histogram fortrait
and returns the result in the arraybins
.boolean
haveSameStrategy
(int a, int b) Check if individuals with indexa
and indexb
have the same strategies.boolean
isSameStrategy
(int a) Check if individual with indexa
has switched strategies.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
swapStrategies
(int a, int b) Swap strategies 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, commitStrategies, doAdjustScores, encodeStrategies, get2DTraitHistogramData, getInit, getInitialTraits, getMeanFitness, getMeanTraits, getStatus, getTraitData, getTraitHistogramData, getTraitHistogramData, getTraitMax, getTraitMin, getTraitNameAt, getTraits, init, maybeMutateAt, maybeMutateMoran, mouseHitNode, mutateAt, preferredPlayerBest, reset, restoreStrategies, 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, 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, resetStrategies, restoreFitness, restoreGeometry, restoreInteractions, setAddwire, setConsistencyCheck, setMaxEffScoreIdx, setMigrationProb, setMigrationType, setPlayerScoreAveraged, setPlayerScoring, setPopulationUpdate, setRewire, setScoreAt, setSyncFraction, setTagAt, srandom, step, swapScoresAt, updateEffScoreRange, updateFitnessAt, updateMinMaxScores, updatePlayerAsync, updatePlayerAsyncAt, 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).
-
-
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
-
haveSameStrategy
public boolean haveSameStrategy(int a, int b) Description copied from class:IBSPopulation
Check if individuals with indexa
and indexb
have the same strategies.- Overrides:
haveSameStrategy
in classIBSMCPopulation
- Parameters:
a
- the index of first individualb
- the index of second individual- Returns:
true
if the two individuals have the same strategies
-
isSameStrategy
public boolean isSameStrategy(int a) Description copied from class:IBSPopulation
Check if individual with indexa
has switched strategies.Note: this test is only meaningful before strategy gets committed.
- Overrides:
isSameStrategy
in classIBSMCPopulation
- Parameters:
a
- index of individual- Returns:
true
if strategy remained the same- See Also:
-
swapStrategies
public void swapStrategies(int a, int b) Description copied from class:IBSPopulation
Swap strategies of individuals with indexa
and indexb
.Note: the strategies still need to be committed.
- Overrides:
swapStrategies
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 strategy. Only works ifadjustScores==true
.Important: new strategy 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
-
prepareStrategies
public void prepareStrategies()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:
prepareStrategies
in classIBSMCPopulation
- See Also:
-
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 classIBSMCPopulation
- Parameters:
me
- the index of the player that needs to have its new strategy 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)
-