One generation: from evaluated solutions to a new population
COIN is an estimation-of-distribution algorithm for permutations. It does not cross two parents. It turns selected permutations into coincidence counts, updates a probabilistic weight model, and constructs the next population by sampling only unused items.
- EvaluateSend every permutation to the same evaluator. A single-objective run returns a scalar fitness; a multi-objective run returns an objective vector.
- SelectChoose a better tail as reward evidence and a worse tail as punishment evidence.
- CountTranslate each selected permutation into edge events, position–item events, or both, depending on the variant.
- LearnConservative learning redistributes integer weight; reconstruction learning rebuilds weights from the latest reward counts.
- SampleRoulette-sample from eligible unused items. Missing values and duplicates are impossible by construction.
- RepeatEvaluate the new population, update progress and archives, then create the next model snapshot.
Compare algorithms by objective evaluations, not generation count alone: evaluations = population size × effective generations.
The mathematical object being learned
Let a candidate permutation be π=(π₀,π₁,…,πₙ₋₁), where every item in {0,…,n−1} occurs exactly once. COIN does not assign an independent probability to each complete permutation—there are n! of them. Instead, it factorises useful evidence into a quadratic model. Edge variants use directed adjacency indicators; Node variants use position–item indicators.
Edge event
Eᵢⱼ(π)=1 when j immediately follows i in π. The current implementation also counts the closing relation from the final item back to the first, so one permutation contributes exactly n directed edge events.
E(i,j|π) = 1 if successorπ(i)=j; otherwise 0Node/position event
Nₚⱼ(π)=1 when item j occupies position p. Every permutation contributes exactly one event to each position row and one event for each item.
N(p,j|π) = 1 if π[p]=j; otherwise 0For reward set B and punishment set W, COIN forms count matrices R=Σπ∈B feature(π) and Q=Σπ∈W feature(π). The feature is E, N, or both. The evaluator can therefore change from TSP to Flow Shop, Sudoku or RNA while the model consumes the same selected-permutation interface.
Why quadratic memory is a deliberate compromise
A full joint distribution over permutations is intractable. An n×n coincidence model uses Θ(n²) memory and exposes a strong first-order learning signal. It cannot directly represent every long subsequence or higher-order dependency, but repeated sampling can assemble longer structures from compatible pairwise evidence. Hybrid variants extend this vocabulary without escalating to an exponential model.
Reward and punishment are selected evidence
With population 8 and reward/punishment ratios 25:25 in a minimization problem, the two lowest-fitness permutations reward the model and the two highest-fitness permutations punish it. The middle four are still evaluated and can update best-so-far, but they do not write model evidence in that generation.
A complete worked generation
Assume n=6, minimization, population size 8, reward 25%, punishment 25%, and Conservative learning. Sorting fitness selects two reward and two punishment permutations. The learner then counts events—not objective values. A solution with fitness 19 and one with fitness 22 each contribute one vote per observed event; the fitness gap does not automatically give the first solution a larger vote.
For Edge COIN, reward permutation [1,3,5,0,4,2] increments six cells. If the second reward permutation contains 1→5 rather than 1→3, both successor hypotheses receive support. Punishment counts identify transitions characteristic of poor solutions. Conservative updating then transfers available row mass without turning a legal transition into a permanent zero.
| successor | 0 | 2 | 3 | 4 | 5 | row sum |
|---|---|---|---|---|---|---|
| before | 20 | 20 | 20 | 20 | 20 | 100 |
| R count | 0 | 0 | 1 | 0 | 1 | 2 events |
| Q count | 0 | 1 | 0 | 1 | 0 | 2 events |
| after | 20 | 18 | 22 | 18 | 22 | 100 |
Selection pressure and information quality
Very small reward sets learn aggressively from a few individuals and may lock onto accidental patterns. Very large sets dilute the distinction between strong and ordinary solutions. Punishment can accelerate rejection of repeatedly poor traits, but an excessive punishment fraction may suppress edges that are bad only in a particular context. Parameter grids should therefore report both quality and stability across seeds.
Edge COIN: learn what should follow what
Edge COIN stores an n×n matrix H[a,b]. Each cell is the integer sampling weight for placing item b after item a. The permutation [1,3,5,0,4,2] contributes directed events 1→3, 3→5, 5→0, 0→4, 4→2, and the cycle-closing edge 2→1.
| H | 0 | 1 | 2 | 3 |
|---|---|---|---|---|
| 0 | 0 | 12 | 8 | 31 |
| 1 | 9 | 0 | 14 | 38 |
| 2 | 16 | 35 | 0 | 11 |
| 3 | 29 | 10 | 17 | 0 |
Two learning modes
Roulette sampling under a permutation constraint
The matrix row is not sampled over all columns. At construction step t, COIN creates an eligibility mask from items already used. It sums only eligible weights, draws an integer or floating threshold in that reduced total, and scans cumulative weight until the threshold is crossed. After selection, that item becomes ineligible for every later step.
eligible = not_used AND legal_for_problem
total = sum(weight[row,j] for j in eligible)
r = random(0,total)
next = first j whose cumulative eligible weight exceeds r
used[next] = true
This conditional renormalisation changes as the permutation grows. A high-weight successor may be unavailable because it was selected earlier, so lower-ranked alternatives remain important. Positive minimum weights are therefore not cosmetic: they keep a feasible completion path available when preferred edges conflict.
Readable and optimized implementations
The library contains an independently readable ReferenceEdgeCoin and an optimized NumPy/Numba implementation. Equivalence tests compare initialized weights, seeded populations, reward and punishment counts, updated matrices and generation records. Optimization is accepted only after behavior is shown to match—not merely because final fitness looks similar.
Node/Position models: NB-COIN and CNB-COIN
NB-COIN
Stores W[position,item]. Before sampling, it shuffles the order in which positions are filled. At each chosen position it roulette-samples an unused item from that position row. Random position order reduces the construction bias of always filling left to right.
positions = shuffle(0..n-1)
for p in positions:
x[p] ~ W[p, unused]CNB-COIN
Uses the same position–item matrix and learner, but visits positions 0,1,…,n−1. This is Chained Node-Based COIN: the construction sequence is explicit, stable and reproducible.
for p in range(n):
x[p] ~ W[p, unused]Both versions learn position coincidences, but their sampling order is not equivalent. This distinction matters when early choices consume values that later positions also strongly prefer.
| position | item 0 | item 1 | item 2 | item 3 |
|---|---|---|---|---|
| 0 | 8 | 35 | 11 | 16 |
| 1 | 14 | 9 | 17 | 31 |
| 2 | 10 | 13 | 29 | 12 |
| 3 | 32 | 15 | 9 | 18 |
Why NB and CNB may diverge despite sharing W
Suppose positions 0 and 5 both strongly prefer item 1. NB-COIN may fill position 5 first and consume item 1; CNB-COIN always gives position 0 first access. Thus the factorized matrix alone does not fully determine the generated distribution—the order of conditional sampling is part of the algorithm. Reporting only “Node-based COIN” would hide this experimental variable.
SNE-COIN
Pure Edge COIN represents transitions strongly but does not give a unique probabilistic role to the first position. SNE-COIN adds a vector S[item] for the first member and retains H[a,b] for subsequent transitions.
This model is useful when the first locus has semantics: a depot, starting city, seed node, initial job or boundary condition.
Two Node–Edge hybrids, two different schemas
Node anchors → Edge completion
- Generate a full Node/Position template.
- Retain scattered 30–70% of its loci; locus 0 is always retained.
- Reserve values required by future anchors.
- Fill holes from the Edge row of the preceding selected item.
- Train both Node and Edge models from the completed population.
template: [1,_,3,_,_,6,_,7,_]
complete: [1,9,3,5,4,6,8,7,2]Node or Edge at every link
Position 0 always comes from the Node model. Every later locus independently chooses its source: W[position,item] or H[previous,item]. A source mask records which model generated each locus.
x[0] ~ W[0,unused]
for p = 1..n-1:
if Bernoulli(.5):
x[p] ~ W[p,unused]
else:
x[p] ~ H[x[p-1],unused]HNE-COIN freezes a partial schema and reconstructs around it. CNE-COIN has no pre-frozen template; it chooses the model independently at each link during construction.
Choosing a representation from problem semantics
Adjacency dominates
Use Edge COIN when consecutive relations carry most of the meaning: route arcs, consecutive jobs, neighboring symbols or pair-table transitions.
Absolute locus dominates
Use NB-COIN when item quality depends on where it appears. Use CNB-COIN when sequential left-to-right construction is itself meaningful or should be controlled.
The first locus is special
Use SNE-COIN when the starting item has a separate semantic role but later quality remains transition-driven.
Both position and adjacency matter
Use HNE-COIN to preserve a scattered positional schema, or CNE-COIN to mix Node and Edge decisions continuously through the order.
What each hybrid can preserve—and destroy
A Node anchor can protect an absolute position while splitting a good edge. An Edge completion can protect adjacency while moving an item away from a good locus. HNE-COIN makes that trade-off explicit through a retained-locus mask. CNE-COIN makes it stochastic at every link. An ablation should therefore record template density or Node-source ratio, not just the final algorithm label.
The complete COIN variant family
| Single-objective | Stored knowledge | Sampling | Multi-objective |
|---|---|---|---|
| Edge COIN | H[previous,next] | edge chain | MO Edge COIN |
| NB-COIN | W[position,item] | random position first | MO NB-COIN |
| CNB-COIN | W[position,item] | position 0→n | MO CNB-COIN |
| SNE-COIN | S[start]+H[edge] | start then edge | MO SNE-COIN |
| HNE-COIN | W+H | Node template→Edge fill | MO HNE-COIN |
| CNE-COIN | W+H | Node/Edge per link | MO CNE-COIN |
Multi-objective COIN does not change a variant’s representation or sampler. It changes the evidence interface: nondominated rank/Pareto depth and diversity-based selection scores replace scalar fitness sorting, while an external archive retains nondominated solutions.
From objective vectors to model evidence
For minimization, solution x dominates y when it is no worse in every objective and strictly better in at least one. Nondominated sorting partitions the population into depth 0, depth 1 and deeper fronts. COIN then combines depth with a diversity-aware selection score so that reward evidence is not drawn only from one extreme of the frontier.
- Evaluate all candidates with the identical objective functions used by competing algorithms.
- Perform nondominated sorting and compute diversity information.
- Select reward and punishment evidence from the resulting ranking.
- Update the same H, W, S or hybrid model used by the corresponding single-objective variant.
- Merge candidates into the external archive and remove dominated or duplicate objective vectors.
Do not report only archive size
| Indicator | Question answered | Direction |
|---|---|---|
| Convergence | How close is the algorithm’s set to the observed/reference Pareto set? | lower is better |
| Spread | How evenly does the set cover the objective trade-off? | lower is better for the adopted spread definition |
| Nondominated ratio | What fraction of an algorithm’s returned set survives against the union? | higher is better |
| Hypervolume | How much dominated objective space is covered relative to a declared reference point? | higher is better |
| Archive size | How many unique nondominated objective vectors were retained? | descriptive, not sufficient alone |
Every indicator must use a common normalization and a stated reference construction. For three or more objectives, pairwise 2-D projections are explanatory views, not replacements for dominance in the full objective space.
Parameters, complexity and diagnostics
Reward selection (%)
A smaller fraction is more selective but noisier. A larger fraction is steadier but may average evidence from several basins.
Punishment selection (%)
The worse-tail fraction used as negative evidence. It is neither a mutation rate nor a number of tournaments.
Training rate
Controls initial integer-weight scale. A higher rate makes new evidence influential sooner.
Learning mode
Conservative accumulates history; reconstruction responds rapidly to the current reward set.
| Family | Memory | Evidence count | Population sampling |
|---|---|---|---|
| Edge / NB / CNB | Θ(n²) | Θ(Pn) | Θ(Pn²) with row scans |
| SNE-COIN | Θ(n²+n) | Θ(Pn) | Θ(Pn²) |
| Hybrids | Θ(2n²) | Θ(Pn) | Θ(Pn²) |
No item is missing or duplicated.
Edge diagonal remains zero; every legal off-diagonal weight remains positive.
The same seed and configuration reproduce the same stochastic trace.
Record best-so-far per objective, diversity, concentration, Pareto depth, archive size and evaluations-to-solution.
A reproducible comparison protocol
- Freeze the problemConstruct one immutable evaluator instance per benchmark and share it across all algorithms.
- Equalize budgetsUse the same number of objective evaluations. Report early termination separately when an exact optimum is certified.
- Control seedsRun a declared seed set, beginning with seed 1 for a quick demonstration but using multiple seeds for inference.
- Preserve raw setsStore permutations, objective vectors, generation/evaluation index, parameter configuration and runtime.
- Separate quality and speedReport objective evaluations to target, wall time, evaluator throughput and model overhead independently.
- Use statistical summariesPublish median, mean, dispersion, success rate and paired comparisons—not only the most favorable run.
Failure modes visible in the model
Premature concentration
A few cells absorb most row mass, diversity falls and best-so-far stops improving. Reduce selection pressure, lower training rate influence, or use a more conservative update.
Diffuse non-learning
Rows remain almost uniform and the learning curve resembles random sampling. Increase evidence strength, inspect whether the selected sets are genuinely different, and verify objective direction.
Representation mismatch
Fitness improves slowly although weights concentrate strongly. The model may be learning adjacency while the problem rewards position—or vice versa. Compare Edge, Node and hybrid ablations.
Misleading MO progress
One objective improves while another is ignored, or a projected frontier looks strong but is dominated in full dimension. Inspect Pareto depth, full vectors and the external archive.
Recommended learning-progress traces
Plot best-so-far for every objective against objective evaluations. Add archive size and nondominated ratio for MO runs, and optionally matrix entropy or effective row support to expose how fast the model concentrates. A minimization best-so-far curve must be non-increasing; an upward jump is a reporting or sign bug, not learning.
Source map: explanation to reusable library
| Component | Python source | Responsibility |
|---|---|---|
| Edge | models/edge_reference.pymodels/edge_optimized.py | Readable and equivalence-tested optimized implementations |
| Learning | learning/reward_punishment.py | Integer reward/punishment update kernel |
| NB / CNB | models/position.pymodels/cnb_position.py | Random-position and chained-position samplers |
| Composite models | models/start_node_edge.pymodels/hybrid.pymodels/hybrid_chain.py | Start-aware and Node–Edge hybrids |
| MO orchestration | core/multiobjective.py | Pareto selection, archive and progress |
Reusable interface boundary
Each model is responsible for initialization, population generation, and learning from selected permutations. The optimization driver owns evaluation budgets, objective direction, best-so-far records and termination. This separation lets the same COIN model solve Flow Shop, TSPTW, Linear Ordering, Sudoku, RNA candidate ordering, load partitioning and other permutation tasks without embedding domain code in the learner.
model = Variant(config, rng)
algorithm = PermutationCoinAlgorithm(model, problem)
result = algorithm.run(evaluation_budget)
# Multi-objective changes the orchestration:
algorithm = MultiObjectiveCoinAlgorithm(model, problem)
pareto_set = algorithm.run(evaluation_budget)
Tests required before a new variant joins the suite
- Every generated chromosome is a complete permutation.
- Reward and punishment counts match a hand-calculated fixture.
- Forbidden transitions retain zero while legal transitions retain positive support.
- Seeded sampling is reproducible.
- Optimized and readable kernels produce equivalent state transitions.
- The evaluator count equals the declared budget, including the final partial generation.
- Single-objective best-so-far has the correct monotonic direction.
- MO archives contain no dominated members or duplicate objective vectors under the declared policy.
The model snapshot is itself experimental evidence. Exporting H, W, S, template masks and CNE-COIN source masks makes it possible to explain what the algorithm learned—not merely which objective value it returned.