Skip to main content

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:

actionproduced positive/negative effectsrouted effectsfitness\text{action} \rightarrow \text{produced positive/negative effects} \rightarrow \text{routed effects} \rightarrow \text{fitness}

The key design choice is:

K+0,K0K^{+} \ge 0,\qquad K^{-} \ge 0

That is, the model uses two nonnegative kernels rather than one signed kernel.

Interpretation:

  • K+K^{+} routes positive effects
  • KK^{-} 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 jj take action aj(t)a_j(t) at time tt.

That action may produce both:

Bj+(t)0B_j^{+}(t) \ge 0

and

Bj(t)0B_j^{-}(t) \ge 0

where:

  • Bj+(t)B_j^{+}(t) is the positive, fitness-relevant output generated by the action of agent jj
  • Bj(t)B_j^{-}(t) is the negative, fitness-relevant output generated by the action of agent jj

Those effects are then routed separately:

Ri+(t)=jτ0Kji+(τ,Xt)Bj+(tτ)R_i^{+}(t) = \sum_j \sum_{\tau \ge 0} K^{+}_{j \to i}(\tau, X_t)\,B_j^{+}(t-\tau) Ri(t)=jτ0Kji(τ,Xt)Bj(tτ)R_i^{-}(t) = \sum_j \sum_{\tau \ge 0} K^{-}_{j \to i}(\tau, X_t)\,B_j^{-}(t-\tau)

where:

  • Ri+(t)R_i^{+}(t) is the total positive returned effect received by agent ii at time tt
  • Ri(t)R_i^{-}(t) is the total negative returned effect received by agent ii at time tt
  • Kji+(τ,Xt)K^{+}_{j \to i}(\tau, X_t) is the positive-effect kernel from producer jj to recipient ii
  • Kji(τ,Xt)K^{-}_{j \to i}(\tau, X_t) is the negative-effect kernel from producer jj to recipient ii
  • τ\tau is the delay between production and return
  • XtX_t 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:

Wi(t)=w0+Ri+(t)Ri(t)Ci(t)W_i(t)=w_0 + R_i^{+}(t) - R_i^{-}(t) - C_i(t)

where:

  • Wi(t)W_i(t) is the fitness or selection-relevant score of agent ii
  • w0w_0 is baseline fitness
  • Ci(t)C_i(t) is the private cost paid by agent ii

So:

positive routed effects raise fitness\text{positive routed effects raise fitness} negative routed effects lower fitness\text{negative routed effects lower fitness}

Why Two Nonnegative Kernels Are Better Than One Signed Kernel

One could try to write a single signed kernel:

KjiRK_{j \to i} \in \mathbb{R}

but that makes interpretation harder.

Using two nonnegative kernels is cleaner because:

  1. Positive and negative channels stay conceptually separate.

  2. Normalization is easier to inspect:

    iKji+1,iKji1\sum_i K^{+}_{j \to i} \le 1,\qquad \sum_i K^{-}_{j \to i} \le 1
  3. Different mechanisms can use different routing logic for help versus harm.

  4. It avoids accidental cancellation inside the kernel itself.

  5. 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:

action(B+,B)(R+,R)W\text{action} \rightarrow (B^{+}, B^{-}) \rightarrow (R^{+}, R^{-}) \rightarrow W

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:

(Bj+(t),Bj(t))\big(B_j^{+}(t), B_j^{-}(t)\big)

and only afterward are those outputs distributed through the population:

Ri±(t)=jτ0Kji±(τ,Xt)Bj±(tτ)R_i^{\pm}(t) = \sum_j \sum_{\tau \ge 0} K^{\pm}_{j \to i}(\tau, X_t)\,B_j^{\pm}(t-\tau)

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:

Bj(t)=0B_j^{-}(t)=0

and the positive kernel is the usual open-plus-retained structure:

K+=Kopen+KretainedK^{+}=K^{open}+K^{retained}

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:

Bj(t)=0B_j^{-}(t)=0

but K+K^{+} 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:

Bj+(t)=0B_j^{+}(t)=0

and actions only generate negative routed effects.

Examples:

  • interference
  • exclusion
  • sabotage
  • competitive suppression

Mixed Interaction Case

An action can also create both:

Bj+(t)>0,Bj(t)>0B_j^{+}(t) > 0,\qquad B_j^{-}(t) > 0

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:

Pi(t)=Si(W1(t),W2(t),,Wn(t))P_i(t)=S_i\big(W_1(t),W_2(t),\dots,W_n(t)\big)

where:

  • Pi(t)P_i(t) is the probability that agent ii survives, reproduces, or is copied
  • SiS_i 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 WiW_i
  • negative routed effects matter through decreasing WiW_i
  • 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:

iWi(t)=nw0+iRi+(t)iRi(t)iCi(t)\sum_i W_i(t) = n w_0 + \sum_i R_i^{+}(t) - \sum_i R_i^{-}(t) - \sum_i C_i(t)

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 xix_i denote the action tendency or strategy parameter of agent ii.

The most general condition is:

xiE[Pi(t)]>0\frac{\partial}{\partial x_i}\mathbb{E}[P_i(t)] > 0

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:

xiE[Ri+(t)Ri(t)]>Ci(t)xi\frac{\partial}{\partial x_i}\mathbb{E}\big[R_i^{+}(t)-R_i^{-}(t)\big] > \frac{\partial C_i(t)}{\partial x_i}

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 aj(t)a_j(t) generates Bj+(t)B_j^{+}(t) and Bj(t)B_j^{-}(t), but it does not yet specify how.

A fuller version should include a production map such as:

(Bj+(t),Bj(t))=F(aj(t),zj(t),Xt)\big(B_j^{+}(t), B_j^{-}(t)\big) = F\big(a_j(t), z_j(t), X_t\big)

where zj(t)z_j(t) is the internal state, trait, or strategy parameter of agent jj.

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:

Bj+(t)>0B_j^{+}(t) > 0

under the production map:

(Bj+(t),Bj(t))=F(aj(t),zj(t),Xt)\big(B_j^{+}(t), B_j^{-}(t)\big) = F\big(a_j(t), z_j(t), X_t\big)

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 XtX_t 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:

Xt+1=G(Xt,a(t),R+(t),R(t))X_{t+1} = G\big(X_t, a(t), R^{+}(t), R^{-}(t)\big)

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 Pi(t)P_i(t), but it still needs a rule for what is transmitted or updated after selection.

For an evolutionary version, one can write:

zi(t+1)U(z(t),P(t),M)z_i(t+1) \sim U\big(z(t), P(t), M\big)

where UU is the reproduction, replacement, or copying rule and MM 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:

Wi(t)=w0+Ri+(t)Ri(t)Ci(t)W_i(t)=w_0 + R_i^{+}(t) - R_i^{-}(t) - C_i(t) Wˉg(t)=1gigWi(t)\bar{W}_g(t)=\frac{1}{|g|}\sum_{i\in g}W_i(t)

where:

  • Wi(t)W_i(t) is individual score
  • Wˉg(t)\bar{W}_g(t) is a group-level score for group gg

Then define both:

P(ig,t)f(Wi(t))P(i\mid g,t)\propto f\big(W_i(t)\big) P(g,t)F(Wˉg(t))P(g,t)\propto F\big(\bar{W}_g(t)\big)

Interpretation:

  • P(ig,t)P(i\mid g,t) handles selection within groups
  • P(g,t)P(g,t) handles selection between groups

In mixed formulations, one can also use a weighting parameter to interpolate between levels:

Pi(t)=(1λ)Pwithin(i,t)+λPbetween(g(i),t)P_i(t)=(1-\lambda)P_{\text{within}}(i,t)+\lambda P_{\text{between}}(g(i),t)

with λ[0,1]\lambda\in[0,1] 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:

0Bj+(t)+Bj(t)Qj(t)0 \le B_j^{+}(t) + B_j^{-}(t) \le Q_j(t)

where Qj(t)Q_j(t) is the total interaction budget available to agent jj.

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 jj can observe when choosing actions or targets.

That can be written by letting action choice and routing depend on an information state Ij(t)I_j(t):

aj(t)=Aj(Ij(t),zj(t),Xt)a_j(t) = A_j\big(I_j(t), z_j(t), X_t\big) Kji±(τ,Xt,Ij(t))K^{\pm}_{j \to i}(\tau, X_t, I_j(t))

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:

  1. Action choice:
aj(t)=Aj(Ij(t),zj(t),Xt)a_j(t) = A_j\big(I_j(t), z_j(t), X_t\big)
  1. Positive and negative effect production:
(Bj+(t),Bj(t))=F(aj(t),zj(t),Xt)\big(B_j^{+}(t), B_j^{-}(t)\big) = F\big(a_j(t), z_j(t), X_t\big)

with an optional interaction budget:

0Bj+(t)+Bj(t)Qj(t)0 \le B_j^{+}(t) + B_j^{-}(t) \le Q_j(t)
  1. Routing of those effects through the population:
Ri+(t)=jτ0Kji+(τ,Xt,Ij(t))Bj+(tτ)R_i^{+}(t) = \sum_j \sum_{\tau \ge 0} K^{+}_{j \to i}\big(\tau, X_t, I_j(t)\big)\,B_j^{+}(t-\tau) Ri(t)=jτ0Kji(τ,Xt,Ij(t))Bj(tτ)R_i^{-}(t) = \sum_j \sum_{\tau \ge 0} K^{-}_{j \to i}\big(\tau, X_t, I_j(t)\big)\,B_j^{-}(t-\tau)
  1. Fitness-relevant score formation:
Wi(t)=w0+Ri+(t)Ri(t)Ci(ai(t),zi(t),Xt)W_i(t)=w_0 + R_i^{+}(t) - R_i^{-}(t) - C_i\big(a_i(t), z_i(t), X_t\big)
  1. Relative selection:
Pi(t)=Si(W1(t),W2(t),,Wn(t))P_i(t)=S_i\big(W_1(t),W_2(t),\dots,W_n(t)\big)
  1. Inheritance, replacement, or policy updating:
zi(t+1)U(z(t),P(t),M)z_i(t+1) \sim U\big(z(t), P(t), M\big)
  1. State transition:
Xt+1=G(Xt,a(t),R+(t),R(t),z(t+1))X_{t+1} = G\big(X_t, a(t), R^{+}(t), R^{-}(t), z(t+1)\big)

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 AA, FF, K+K^{+}, KK^{-}, CC, SS, UU, and GG.

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 logic
  • kernels.py: routing rules for positive and negative effects
  • selection.py: relative-success rule based on the vector of agent scores
  • metrics.py: trait, routed-effect, and fitness summary diagnostics
  • config/interaction_kernel_config.py: active runtime parameters

Current Implementation Scope

The current implementation is deliberately small:

  • each site carries a continuous trait h and an inherited lineage label
  • B_plus and B_minus are produced from h
  • K_plus can be uniform or kin-weighted
  • K_minus can 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.

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 Ri+R_i^{+} and RiR_i^{-}, optional delay au au, state dependence through XtX_t, 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 KjiK_{j \to i} 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.

FeatureThis setupLehmann 2007Ohtsuki 2006Pena 2016Allen 2013Moore 1997McGlothlin 2010
Structured redistribution of social effectsYesYesYesYesYesYesYes
Explicit produced -> routed separationYesNoNoNoNoNoNo
Explicit recipient-level routed quantitiesYesNoNoNoNoNoNo
Separate positive and negative channelsYesNoNoNoNoNoNo
Distance- or state-dependent structureYesYesPartialPartialYesNoNo
Separate interaction from selection or updateYesNoNoPartialYesPartialPartial
Helping and harming in one frameworkYesYesNoNoNoNoNo
Explicit delay in routingYesNoNoNoNoNoNo
Display 1: Feature coverage of related research compared with the interaction-kernel setup.

References