Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion algorithms/pir/install.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/bash
pip install "git+https://github.com/Qazi-pk/physics-engine.git@v3.5"
pip install "git+https://github.com/Qazi-pk/physics-engine.git@v3.10.0"
25 changes: 18 additions & 7 deletions algorithms/pir/metadata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,21 @@ paper:
title: "PIR: Physics Intermediate Representation for Automated Discovery of Physical Laws"
url: https://doi.org/10.5281/zenodo.21351039
description: >
Classical symbolic regression via monomial-basis search with log-linearization
gate for power-law detection (F3 gate), pairwise structure decomposition,
RANSAC, sparse regression, and iterative residual refinement with Occam
complexity penalty. No neural components. Verified blind Feynman Tier A:
12/44 EXACT (zero seed wobble, v3.4). Secondary: +12/44 FORM_NUMERIC
(correct functional form, transcendental constant as decimal, reported
separately and never summed into the primary figure).
Classical symbolic regression (no neural components): monomial-basis search
with log-linearization power-law detection, pairwise structure decomposition,
RANSAC, sparse regression, and iterative residual refinement with an Occam
complexity penalty. Since pir-engine 3.6.0, fallback gates run after the
engine when its model is not exact: an exact rational-function gate (P/Q),
an exact exponential gate, and a noise-tolerant power-law gate with exponents
snapped to simple fractions. Since 3.7.0, a safeguard returns a ridge-linear
model (or the mean) instead when the formula fits clearly worse than that
baseline under cross-validation. Since 3.8.0, a deterministic separability
stage tests whether y = g(A)*h(B) for a split of the inputs, solves the
parts separately and accepts their product only if it is exact. Since 3.9.0
it also handles sign-changing targets and root and sin/cos factors.
Since 3.10.0, a noise-tolerant stage (at least 2,000 training rows, only
when nothing is exact) fits separable, exponential and rational forms,
snaps exponents and coefficient ratios to simple fractions within their
standard errors, and accepts a form only if it predicts held-out rows as
well as a flexible reference model.
Software DOI: 10.5281/zenodo.24156912.
77 changes: 65 additions & 12 deletions experiment/methods/pir/regressor.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,45 @@
complexity(est) returns an integer complexity count for the model
eval_kwargs method-specific args forwarded to evaluate_model.py

No neural components. Vanilla classical PIR only — this is the configuration
that produced the verified blind Tier A baseline:

12/44 EXACT (zero seed wobble, v3.4)
+12/44 FORM_NUMERIC secondary (correct functional form, transcendental
constant folded as decimal — reported separately, never summed)

Engine: https://github.com/Qazi-pk/physics-engine (MIT, tag v3.5)
No neural components. Classical PIR engine (unchanged vanilla configuration
below), followed since pir-engine 3.6.0 by its built-in fallback gates
(gates="all"), tried in a fixed order only when the engine's model is not
already exact:

rational y = P(x)/Q(x), low-degree polynomials (accepted only if exact)
exp y = C*exp(sum of monomials) (accepted only if exact)
noisy y = C*prod x_j**(p/q), exponents snapped to simple fractions
(accepted only if its training MSE <= the engine's)

A gate's model replaces the engine's only when it passes its test; any error
inside a gate keeps the engine's model. Thresholds are fixed in the engine.

Since pir-engine 3.7.0, a safeguard (safeguard=True) then compares the final
formula with a ridge-regression linear model and the mean of y: a formula with
training R^2 >= 0.999 is always kept; otherwise the linear model replaces it
only if its 5-fold cross-validated R^2 is higher by more than 0.05, and the
mean is returned if both are below 0. Rules are fixed in the engine.

Since pir-engine 3.8.0, a separability stage (separability=True) runs after
the engine and before the gates, only when the engine's model is not exact: a
deterministic cross-term test looks for a split of the inputs with
y = g(A)*h(B), the parts are solved separately (at most 4 attempts, each on a
fixed 5,000-row subsample), and the product is accepted only if it reproduces
all training rows exactly (max relative error < 1e-6) and beats the engine.
Since 3.9.0 it also handles targets that change sign and, in a late pass after
the gates, factors that are roots or sin/cos terms; acceptance is still exact.

Since pir-engine 3.10.0, a noise-tolerant stage (noise_tolerant=True) runs
after the late separability pass and before the safeguard, only when no model
so far is exact and there are at least 2,000 training rows. It fits separable,
power-law-times-exp and short rational forms on 75% of (at most 20,000) rows,
snaps exponents and coefficient ratios to simple fractions within 3 standard
errors, accepts a form only if it predicts the other 25% within 5% of a
flexible reference model, and replaces the current model only if it predicts
those rows better. Rules are fixed in the engine.

Engine: https://github.com/Qazi-pk/physics-engine (MIT, tag v3.10.0)
Software DOI: https://doi.org/10.5281/zenodo.24156912
Paper: https://doi.org/10.5281/zenodo.21351039
"""

Expand All @@ -26,11 +57,11 @@
import numpy as np

# The classical engine. algorithms/pir/install.sh pip-installs this from the
# public repo at tag v3.5.
# public repo at tag v3.10.0.
from physics_engine.sklearn_adapter import PIRRegressor
from sklearn.base import BaseEstimator, RegressorMixin

# --- Vanilla config that produced the verified blind Tier A result ------------
# --- Vanilla engine config (unchanged since v3.4) -----------------------------
_PIR_VANILLA_CONFIG = dict(
enforce_dimensions=False, # blind sweep ran with dim-filter OFF
allowed_powers=[1, 2], # powers 1,2 only (structural cap)
Expand All @@ -53,15 +84,37 @@ class PIRClassicRegressor(BaseEstimator, RegressorMixin):
SRBench's own timeout handler (per gAldeia's review on PR #210). The
`max_time` constructor kwarg is still accepted, for API compatibility
with the harness's test_params override, but is currently unused.
`gates` (pir-engine >= 3.6.0), `safeguard` (>= 3.7.0), `separability`
(>= 3.8.0) and `noise_tolerant` (>= 3.10.0) are passed to the engine; they
are explicit constructor arguments so that they are recorded by get_params().
"""

def __init__(self, max_time=3600, random_state=None, **pir_kwargs):
def __init__(
self,
max_time=3600,
random_state=None,
gates="all",
safeguard=True,
separability=True,
noise_tolerant=True,
**pir_kwargs,
):
self.max_time = max_time
self.random_state = random_state
self.gates = gates
self.safeguard = safeguard
self.separability = separability
self.noise_tolerant = noise_tolerant
self.pir_kwargs = {**_PIR_VANILLA_CONFIG, **pir_kwargs}

def _build(self):
kw = dict(self.pir_kwargs)
kw = dict(
self.pir_kwargs,
gates=self.gates,
safeguard=self.safeguard,
separability=self.separability,
noise_tolerant=self.noise_tolerant,
)
seed = 0 if self.random_state is None else self.random_state
try:
return PIRRegressor(random_state=seed, **kw)
Expand Down
Loading