Interaction Kernel
Status
Implemented abstraction. This page describes the interaction_kernel/ package in the sibling EvolvedCooperation repository. It is a reusable kernel engine, not a website replay case study.
interaction_kernel/ replaces the earlier feedback-kernel design note with a concrete implementation that routes positive and negative effects through explicit kernels before selection.
Why This Kernel Exists
Retained Benefit generalizes several cooperation mechanisms by asking how much cooperative value returns to cooperators or copies of the cooperative rule. The interaction kernel takes the next step:
allow actions to generate both positive and negative fitness-relevant effects, and route both through explicit kernels
That makes it possible to represent cooperation and competition within one shared formal framework.
Examples:
- helping can create positive effects for others
- exclusion can impose negative effects on rivals
- territorial defense can benefit allies while harming competitors
- predatory or antagonistic actions can create mixed positive and negative downstream consequences
So this is not just a more general cooperation model. It is a more general interaction model.
Core Idea
The basic chain becomes:
The key design choice is:
That is, the model uses two nonnegative kernels rather than one signed kernel.
Interpretation:
- routes positive effects
- routes negative effects
This is cleaner than one signed kernel because it avoids cancellation inside a single operator and keeps normalization easier to interpret.
General Equations
Let agent take action at time .
That action may produce both:
and
where:
- is the positive, fitness-relevant output generated by the action of agent
- is the negative, fitness-relevant output generated by the action of agent
Those effects are then routed separately:
where:
- is the total positive returned effect received by agent at time
- is the total negative returned effect received by agent at time
- is the positive-effect kernel from producer to recipient
- is the negative-effect kernel from producer to recipient
- is the delay between production and return
- is the world state, such as space, lineage, memory, institutions, or ecology
Distance dependence is only one optional parameterization of these kernels, not a built-in requirement. The routing can instead be based on any explicit and interpretable structure, including lineage, reputation, institutions, alliance structure, ecological overlap, or arbitrary network connectivity.
Then a simple fitness score is:
where:
- is the fitness or selection-relevant score of agent
- is baseline fitness
- is the private cost paid by agent
So:
Why Two Nonnegative Kernels Are Better Than One Signed Kernel
One could try to write a single signed kernel:
but that makes interpretation harder.
Using two nonnegative kernels is cleaner because:
-
Positive and negative channels stay conceptually separate.
-
Normalization is easier to inspect:
-
Different mechanisms can use different routing logic for help versus harm.
-
It avoids accidental cancellation inside the kernel itself.
-
It keeps “who gets helped?” and “who gets harmed?” as separately analyzable questions.
So the sign lives in the type of routed effect, not in negative kernel weights.
Minimal Interpretation
This model does not say that “negative fitness” is directly distributed.
A better statement is:
actions generate positive and negative fitness-relevant effects, and the kernels route those effects to recipients
Fitness comes later, after routing:
So:
- produced effects are not yet fitness
- routed effects are not yet final selection outcome
- fitness is the resulting score after combining returned positive effects, returned negative effects, and private costs
Why Separate Production From Routing?
This separation matters because producing an effect and receiving an effect are not the same operation.
In the present setup, an action first generates positive and negative outputs:
and only afterward are those outputs distributed through the population:
That distinction is useful because it preserves causal structure that many payoff-level models compress away.
If the model does not separate production from routing, then several different mechanisms get folded into one net effect:
- how much an action generated
- who received that effect
- how much leaked away
- whether returns were delayed
- whether institutions, space, lineage, or ecology redirected the effect
Keeping the two stages separate makes it possible to ask whether a change in cooperation or competition came from a change in what agents produced or from a change in how the world redistributed those effects.
Many earlier models collapsed these steps because they were optimized for tractable payoff expressions, graph rules, or structure coefficients. That compression is often enough when interactions are local, immediate, and symmetric. But once one cares about leakage, delayed return, recipient-specific routing, or mixed helping and harming, the distinction becomes explanatory rather than cosmetic.
Special Cases
One reason this framework is useful is that many familiar models become special cases.
Retained Benefit
Retained Benefit is recovered when:
and the positive kernel is the usual open-plus-retained structure:
So:
- only positive cooperative output exists
- some of it is open to the local neighborhood
- some of it is protected for same-lineage recipients
Positive-Only Feedback Kernel
A positive-only feedback-kernel case is recovered when:
but is allowed to vary across a broad family of positive return structures.
The old General feedback-kernel subset is therefore best read as a positive-only subset of the implemented Interaction Kernel.
Competition-Only Case
A pure competition case appears when:
and actions only generate negative routed effects.
Examples:
- interference
- exclusion
- sabotage
- competitive suppression
Mixed Interaction Case
An action can also create both:
Examples:
- coalition defense that protects allies and harms rivals
- parental investment that helps descendants while imposing competitive pressure on unrelated others through resource capture
- territorial behavior that benefits the local group while excluding competitors
Selection And Relative Competition
Once competition is introduced, absolute fitness scores are often not enough.
Selection usually depends on relative success, not only on each agent's own absolute score.
So it is useful to define a selection operator:
where:
- is the probability that agent survives, reproduces, or is copied
- is the selection rule that converts the vector of scores into relative success
This matters because a harmful action can be favored even if it does not directly increase the actor's own absolute score, as long as it lowers rivals enough to improve the actor's relative success under the selection rule.
So in the generalized model:
- positive routed effects matter through increasing
- negative routed effects matter through decreasing
- competition can also matter through how changes in one agent's score alter the relative selection probabilities of others
Aggregate Fitness Versus Relative Selection
It is useful to separate two levels of the model.
At the score level:
Nothing in the current formulation forces that aggregate quantity to be conserved.
So total fitness-relevant score can:
- rise if routed positive effects are large relative to routed negative effects and private costs
- fall if negative effects and private costs dominate
- remain roughly unchanged in approximately zero-sum regimes
This is possible because the kernels are routing operators, not conservation laws. Their row sums are constrained for interpretability, but they are not required to preserve a fixed total returned quantity.
By contrast, the selection layer is often closer to fixed-sum or zero-sum. If the selection rule maps scores into a fixed number of survival, reproduction, or copying opportunities, then one agent's gain in relative success can come partly or entirely at the expense of others.
So the distinction is:
- aggregate fitness-relevant score is not intrinsically zero-sum in this model
- relative selection often is fixed-sum or zero-sum in practice
- strict conservation would require an additional assumption, not currently built into the current implementation
Minimal Conditions For Cooperation And Competition
Let denote the action tendency or strategy parameter of agent .
The most general condition is:
That is:
an action is favored when increasing it raises the expected selection probability of the actor
In a simpler score-based view, cooperation-like action is favored when:
Interpretation:
- positive feedback helps
- negative feedback hurts
- private cost must still be paid by the actor
So the generalized law is no longer just about cooperation. It becomes:
Generalized law. An action is favored when its feedback-weighted marginal positive effects, minus its feedback-weighted marginal negative effects, including routed effects that return after delay, improve expected selection success enough to outweigh its marginal private cost.
Why This Generalization Matters
The positive-only feedback-kernel subset is already useful for asking:
when does enough positive return flow back to cooperators or copies of the cooperative rule?
The Interaction Kernel framework asks a broader question:
how do both helping and harming flow through structured populations, and when do those routed effects favor one action over another?
This is closer to a general theory of social interaction under selection than a cooperation-only law.
It allows the same framework to study:
- cooperation
- competition
- exclusion
- antagonism
- mixed social strategies
- ecological and evolutionary tradeoffs between help and harm
What Still Needs To Be Specified
To become a richer generative interaction model, the current implementation still needs a few additional rules.
Action-To-Effect Production Rule
Right now the model says that action generates and , but it does not yet specify how.
A fuller version should include a production map such as:
where is the internal state, trait, or strategy parameter of agent .
This determines when an action produces help, harm, both, or neither.
What Kinds Of Actions Can Produce Benefit?
The model does not privilege one special action type. In principle, any action can produce positive effect if it generates positive, fitness-relevant output before routing.
So an action counts as benefit-producing when:
under the production map:
Examples include:
- resource sharing or provisioning
- collective hunting effort
- alarm calling or protective defense
- parental care or brood protection
- information sharing or coordination signaling
- environmental modification that later improves survival or reproduction
- institutional or social enforcement that increases positive returns to cooperators
The important point is that benefit here is not a moral label and not yet final fitness. It is the positive, fitness-relevant output created by an action before that output is routed through the kernel.
The same action can also generate negative output at the same time. For example, territorial defense or coalition action may create positive effects for allies while imposing negative effects on rivals.
State Transition Rule
The world state already appears inside the kernels, but the current implementation does not yet specify how the world itself changes over time.
A fuller version should include something like:
This lets space, resources, memory, institutions, or ecological conditions be altered by prior interactions rather than treated as fixed background.
Inheritance Or Updating Rule
The framework defines a selection operator , but it still needs a rule for what is transmitted or updated after selection.
For an evolutionary version, one can write:
where is the reproduction, replacement, or copying rule and represents mutation or transmission noise.
For a learning version, the same slot could be replaced by a policy-update operator rather than a reproduction operator.
Why Group Selection Needs A Multilevel Update Rule
Group structure in the interaction kernels is useful, but by itself it does not yet implement group selection.
The kernels say who affects whom. The selection or update rule says who leaves descendants, gets copied, persists, or is replaced.
So if the model only uses individual-level replacement based on individual scores, then the setup is still primarily structured individual selection, even when interactions are clustered by groups.
To represent group selection explicitly, selection must include two levels:
- within-group competition among individuals
- between-group competition among groups
One simple formal sketch is:
where:
- is individual score
- is a group-level score for group
Then define both:
Interpretation:
- handles selection within groups
- handles selection between groups
In mixed formulations, one can also use a weighting parameter to interpolate between levels:
with controlling the strength of group-level selection.
So the key caveat is:
group-aware interaction kernels are necessary for many grouped settings, but explicit multilevel selection or update dynamics are needed if the claim is specifically group selection.
Within this framework, all five mechanisms from Nowak (2006) can be represented as parameterizations of action, state, routing, and selection:
- kin selection
- direct reciprocity
- indirect reciprocity
- network reciprocity
- group selection
The caveat applies only to implementation detail, not representability: group selection is included, but it requires an explicit multilevel selection or update rule rather than interaction kernels alone.
Resource And Budget Constraints
The implementation also needs to say whether positive and negative outputs are unconstrained, budget-limited, or drawn from a shared ecological stock.
One simple option is:
where is the total interaction budget available to agent .
Without a constraint of this kind, the scale of produced positive and negative effects remains underdetermined.
Information And Targeting Constraints
The current kernels determine where effects go, but a fuller version may also need to specify what agent can observe when choosing actions or targets.
That can be written by letting action choice and routing depend on an information state :
This matters when help and harm depend on recognition, signaling, reputation, deception, or uncertainty.
Together, these additions would turn the current implementation into a more fully specified generative model of interaction, ecology, and selection.
One Possible Full Dynamical System
Putting those pieces together, one ordered version of the model is:
- Action choice:
- Positive and negative effect production:
with an optional interaction budget:
- Routing of those effects through the population:
- Fitness-relevant score formation:
- Relative selection:
- Inheritance, replacement, or policy updating:
- State transition:
This closes the model as a loop:
state -> action -> produced effects -> routed effects -> fitness score -> selection and updating -> new state.
Different biological or social theories would mainly differ in the specific forms chosen for , , , , , , , and .
Python Module Layout
The canonical implementation lives as a top-level module in the sibling EvolvedCooperation repository.
interaction_kernel/
__init__.py
README.md
interaction_kernel_model.py
kernels.py
selection.py
metrics.py
config/
interaction_kernel_config.py
data/
latest_run.json
Core responsibilities:
interaction_kernel_model.py: simulation loop and state update logickernels.py: routing rules for positive and negative effectsselection.py: relative-success rule based on the vector of agent scoresmetrics.py: trait, routed-effect, and fitness summary diagnosticsconfig/interaction_kernel_config.py: active runtime parameters
Current Implementation Scope
The current implementation is deliberately small:
- each site carries a continuous trait
hand an inherited lineage label B_plusandB_minusare produced fromhK_pluscan be uniform or kin-weightedK_minuscan be absent or uniform- selection is local and synchronous
- output is written to
interaction_kernel/data/latest_run.json
Run from the EvolvedCooperation repo root:
./.conda/bin/python -m interaction_kernel.interaction_kernel_model
The next implementation steps are retained-benefit-equivalent presets, competition-only presets, and mixed positive/negative interaction sweeps.
Related Research
I have not found an exact prior paper using the same full formulation developed on this page: separate nonnegative positive and negative kernels, explicit routed effects and , optional delay , state dependence through , and a separate selection or update layer. But several research lines come close to important parts of it.
Closest Direct Analogue
- Lehmann, Keller, and Sumpter (2007) is the closest match I found. It explicitly studies both helping and harming on graphs and, as the abstract notes, allows interactions to vary with distance between nodes. That is very close to the present idea of routing positive and negative fitness-relevant effects through a structured operator over recipients.
Graph-Structured Cooperation And Interaction Routing
- Ohtsuki et al. (2006) is not written in kernel notation, but the graph effectively acts like a sparse local routing operator: who receives the downstream benefit of cooperation depends on network neighborhood rather than random mixing.
- Peña et al. (2016) extends this logic to multiplayer games on graphs. Its structure coefficients are more compressed than an explicit operator, but they play a similar role by summarizing how population structure redistributes social effects.
- Débarre, Hauert, and Doebeli (2014) is useful as a broader synthesis of social evolution in structured populations. It is less close to the exact notation used here, but it sits in the same family of models where who affects whom is structured rather than well mixed.
Interaction Structure As A General Formal Object
- Allen, Nowak, and Dieckmann (2013) is a strong formal analogue. It treats interaction structure itself as a general modeling object and shows how long-run evolutionary dynamics depend on which individuals interact with which others. That is conceptually close to making interaction routing a reusable operator.
Indirect Effects And Interaction Matrices
- Moore, Brodie, and Wolf (1997) is not framed as benefit-routing, but it is mathematically close because one individual's trait affects another individual's phenotype through indirect genetic effects.
- McGlothlin et al. (2010) extends that interacting-phenotypes line directly into social evolution. This is one of the best precedents for treating social effects as structured transformations rather than only as entries in a direct payoff matrix.
Takeaway
So the closest fair summary is:
- the general idea that social effects are redistributed through structure is already well represented in graph theory, structured-population theory, and indirect-effect models
- the exact formulation on this page still appears more explicit and more general than the closest matches I found, especially because it separates positive and negative routed channels and keeps routing distinct from the later selection or update rule
Feature Matrix
The matrix below scores the papers already discussed in this section against the main features of the present setup.
Yes means the feature is explicit. Partial means the feature is present in compressed, indirect, or only partly matching form. No means it is absent or not clearly part of the formal setup.
| Feature | This setup | Lehmann 2007 | Ohtsuki 2006 | Pena 2016 | Allen 2013 | Moore 1997 | McGlothlin 2010 |
|---|---|---|---|---|---|---|---|
| Structured redistribution of social effects | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
| Explicit produced -> routed separation | Yes | No | No | No | No | No | No |
| Explicit recipient-level routed quantities | Yes | No | No | No | No | No | No |
| Separate positive and negative channels | Yes | No | No | No | No | No | No |
| Distance- or state-dependent structure | Yes | Yes | Partial | Partial | Yes | No | No |
| Separate interaction from selection or update | Yes | No | No | Partial | Yes | Partial | Partial |
| Helping and harming in one framework | Yes | Yes | No | No | No | No | No |
| Explicit delay in routing | Yes | No | No | No | No | No | No |
References
- Allen, B., Nowak, M. A., & Dieckmann, U. (2013). Adaptive Dynamics with Interaction Structure. The American Naturalist, 181(6), E139-E163. https://doi.org/10.1086/670192
- Débarre, F., Hauert, C., & Doebeli, M. (2014). Social evolution in structured populations. Nature Communications, 5, 3409. https://doi.org/10.1038/ncomms4409
- Hamilton, W. D. (1964). The genetical evolution of social behaviour. I. Journal of Theoretical Biology, 7(1), 1-16. https://doi.org/10.1016/0022-5193(64)90038-4
- Lehmann, L., Keller, L., & Sumpter, D. J. T. (2007). The evolution of helping and harming on graphs: the return of the inclusive fitness effect. Journal of Evolutionary Biology, 20(6), 2284-2295. https://doi.org/10.1111/j.1420-9101.2007.01414.x
- Maynard Smith, J., & Price, G. R. (1973). The logic of animal conflict. Nature, 246, 15-18. https://doi.org/10.1038/246015a0
- Maynard Smith, J. (1982). Evolution and the Theory of Games. Cambridge University Press.
- McGlothlin, J. W., Moore, A. J., Wolf, J. B., & Brodie III, E. D. (2010). Interacting phenotypes and the evolutionary process. III. Social evolution. Evolution, 64(9), 2558-2574. https://doi.org/10.1111/j.1558-5646.2010.01012.x
- Moore, A. J., Brodie, E. D., & Wolf, J. B. (1997). Interacting phenotypes and the evolutionary process: I. Direct and indirect genetic effects of social interactions. Evolution, 51(5), 1352-1362. https://doi.org/10.1111/j.1558-5646.1997.tb01458.x
- Nowak, M. A. (2006). Five rules for the evolution of cooperation. Science, 314(5805), 1560-1563. https://doi.org/10.1126/science.1133755
- Ohtsuki, H., Hauert, C., Lieberman, E., & Nowak, M. A. (2006). A simple rule for the evolution of cooperation on graphs and social networks. Nature, 441(7092), 502-505. https://doi.org/10.1038/nature04605
- Peña, J., Wu, B., Arranz, J., & Traulsen, A. (2016). Evolutionary Games of Multiplayer Cooperation on Graphs. PLOS Computational Biology, 12(8), e1005059. https://doi.org/10.1371/journal.pcbi.1005059
- West, S. A., Griffin, A. S., & Gardner, A. (2007). Evolutionary explanations for cooperation. Current Biology, 17(16), R661-R672. https://doi.org/10.1016/j.cub.2007.06.004