Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Latest commit

 

History

History

readme.md

⚖️ S34 Validator: Statistical Robustness & Fluke Elimination

The Problem: The "Statistical Fluke" in Chaos Physics

When applying a Genetic Algorithm (GA) to a rigid-body physics engine like matter.js, we encounter a fundamental problem: Optimizers are inherently lazy and opportunistic. In a chaotic system like a Plinko board, falling parts are highly sensitive to initial conditions. Occasionally, due to floating-point math quirks or the precise micro-rotation of a single part, a fundamentally flawed machine geometry might experience a "golden run." In this run, the parts perfectly thread the needle, avoiding jams by pure mathematical chance, resulting in an artificially massive fitness score.

Because the GA strictly selects for high fitness, it will actively latch onto these statistical flukes. If left unchecked, the GA will rapidly converge on fragile, overfit geometries that only work in 1 out of 100 simulations—rendering the design completely useless for real-world manufacturing.

The Solution: Large-$N$ Statistical Validation

To combat this, Project S34 employs a dedicated Validator subsystem. The Validator acts as the final gatekeeper in the evolutionary pipeline. It operates on the principle that a truly successful sorting geometry must be consistently reproducible, not just occasionally lucky.

When the GA identifies a "Champion" chromosome, that genome is extracted and fed into the Validator. Instead of evolving the genome, the Validator acts as a Monte Carlo simulation environment, forcing the exact same machine geometry to run through dozens or hundreds of independent simulation trials ($N$-runs).

By analyzing the distribution of these results, we can definitively separate true mechanical ingenuity from statistical noise.


⚙️ Core Architecture & Workflow

1. Headless Parallel Testing

Like the core GA, the Validator is built for speed. It ingests a champion .json seed and spins up a dedicated Web Worker pool (validator_worker_S34.js). This pool delegates the workload to headless sub-workers (validator_sub_worker_S34.js), simulating 50 to 100 identical drops in parallel across the host machine's CPU cores.

2. Variance & Distribution Analysis

Rather than looking at the absolute maximum score, the Validator records the granular results of every single run. It analyzes:

  • The Spread (Standard Deviation): Does the machine score 10,000 points on run 1, but 500 points on run 2? High variance indicates a fragile, fluke-reliant system.
  • The Median Performance: We prioritize the median over the mean to eliminate the skew of anomalous "golden runs." A high median proves the machine geometry fundamentally controls the flow of parts on average.
  • Failure Rates: It tracks the exact percentage of runs that result in catastrophic jams or massive physics violations.

3. Automated Metareport Generation

Once the $N$-runs are complete, the validator_report_generator_S34.js script compiles the raw data into a comprehensive, standalone HTML report.

  • This report visually maps the distribution of fitness scores, throughput, and jam penalties across all trials.
  • It provides the engineer with immediate visual confirmation: a tight, high-scoring bell curve means the mechanical design is mechanically robust and ready for real-world prototyping. A flat, scattered distribution means the GA was chasing a ghost, and the search parameters need to be adjusted via the Cartographer.

The Triad of S34

The Validator completes the S34 architecture triad, ensuring that the AI's designs are not just creative, but physically reliable:

  1. The Simulator (GA): Explores the infinite solution space to find high-potential geometries.
  2. The Cartographer: Maps the mathematical strategies the GA is using, allowing human intervention.
  3. The Validator: Ruthlessly stress-tests the champions to eliminate statistical flukes and guarantee mechanical consistency.