PREREG_flat_order_point outcome: ACCEPTED, and the GOAL is reached - below Chandrupatla on BOTH sets (server numbers, all projection cells equal to the smoke).

Splitting in the flat regime at the point from the analogous pair's order (t = |FA|^(1/m) / (|FA|^(1/m) + |FB|^(1/m))) instead of the midpoint:
  G2 + analogy + order point         APS 2780  CHA 2221  both 5001   (P1-P4 all hold; vs Chandrupatla 2787 / 2441 / 5228)
  G2 + contra + remembered + point   APS 2775  CHA 2119  both 4894   (P3 fails by 2 against its midpoint twin)
  defect + remembered + point        APS 2532  CHA 2164  both 4696   (P3 fails by 2)
Flat fun3-6: 1234 -> 847 (analogy), 1151 -> 743 (remembered) - below pure bisection 1044 and Chandrupatla 1068.
Per problem on the wide set vs Chandrupatla now 20-24 wins / 13-17 losses (p 0.1-0.7, not significant); on the canonical set the edge is kept (95/20/38 p=8e-7).
Guarantee: 0 violations and >= 193 solved in every project/safe/credit cell.
Server regression x2: 1150 passed, 1 failed = the paper-number check.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
vvs
2026-09-21 18:13:10 +01:00
co-authored by Claude Opus 5
parent d1be3bbd05
commit 08863c170c
8 changed files with 156 additions and 19 deletions
+52 -16
View File
@@ -607,25 +607,33 @@ def _config3(x, fx, xp, fp, xp2, fp2):
return xi, phi, abs(x - xp), abs(fx - fp)
def _analogous_and_steep(cur, past):
"""Is the configuration nearer to its own past than to the line phi = xi, and does the
analogous pair scale like a power of order m >= 2? Two ordinal judgments and the
flag's own break-even (1/4 = (1 - 1/2)^2 <-> m = 2); no new constant.
def _analogy_order(cur, past):
"""The order m of the analogous pair, or None when the configuration is not nearer to
its own past than to the line phi = xi (or the pair's scales are undefined). The judgment
is ordinal; m = ln(f ratio) / ln(x ratio) is read, not chosen.
Nearness: Euclidean in the (xi, phi) plane, the line by its perpendicular. Order: the
pair shrank x by L and f by L^m, m = ln(f ratio) / ln(x ratio)."""
if cur is None or not past:
return False
return None
xi, phi = cur[0], cur[1]
best = min(past, key=lambda q: math.hypot(xi - q[0], phi - q[1]))
if not math.hypot(xi - best[0], phi - best[1]) < abs(phi - xi) / math.sqrt(2.0):
return False
return None
if best[2] <= 0.0 or best[3] <= 0.0 or cur[2] <= 0.0 or cur[3] <= 0.0:
return False
return None
lx, lf = cur[2] / best[2], cur[3] / best[3]
if not (math.isfinite(lx) and math.isfinite(lf)) or lx == 1.0 or lf <= 0.0:
return False
return math.log(lf) / math.log(lx) >= 2.0
return None
return math.log(lf) / math.log(lx)
def _analogous_and_steep(cur, past):
"""Is the configuration nearer to its own past than to the line phi = xi, and does the
analogous pair scale like a power of order m >= 2? Two ordinal judgments and the
flag's own break-even (1/4 = (1 - 1/2)^2 <-> m = 2); no new constant."""
m = _analogy_order(cur, past)
return m is not None and m >= 2.0
def _local_order(x2, f2, x1, f1, x0, f0):
@@ -750,17 +758,23 @@ def pure_root(f, a, b, xtol, maxfev, similarity="ratio", scale="derived",
# category variables below then carry the same string the old tests compared.
if "+" in prestep:
parts = prestep.split("+")
cats = ({"defect"}, {"contra"}, {"flatanalog", "flatanalogmem"})
cats = ({"defect"}, {"contra"}, {"flatanalog", "flatanalogmem", "flatanalogpt",
"flatanalogmempt"})
if (len(parts) != len(set(parts)) or any(not any(p in c for c in cats) for p in parts)
or any(sum(p in c for p in parts) > 1 for c in cats)):
raise ValueError(f"unknown composite prestep {prestep!r}")
elif prestep not in ("none", "progress", "slope", "band", "defect", "simpair", "flat",
"flat2", "flatcreep", "flatstick", "flatstickmid", "flatstickexit",
"flatjudge", "flatanalog", "flatanalogmem", "contra"):
"flatjudge", "flatanalog", "flatanalogmem", "contra",
"flatanalogpt", "flatanalogmempt"):
raise ValueError(f"unknown prestep {prestep!r}")
parts = prestep.split("+")
pre_dec = next((p for p in parts if p in ("band", "defect", "simpair")), "none")
pre_flat = next((p for p in parts if p in ("flatanalog", "flatanalogmem")), "none")
pre_flat = next((p for p in parts if p in ("flatanalog", "flatanalogmem", "flatanalogpt",
"flatanalogmempt")), "none")
# PREREG_flat_order_point: the "pt" twins split at the point from the pair's order
flat_mem = pre_flat in ("flatanalogmem", "flatanalogmempt")
flat_pt = pre_flat in ("flatanalogpt", "flatanalogmempt")
pre_contra = "contra" in parts
if pre_dec != "none" and scale not in (
"derived3", "derived3_cap", "derived3_m", "bracket", "far"):
@@ -819,6 +833,8 @@ def pure_root(f, a, b, xtol, maxfev, similarity="ratio", scale="derived",
judged = 0 # flatjudge: +1 the last point looked flat, -1 linear, 0 tie
configs = [] # flatanalog: the run's memory of (xi, phi, |dx|, |df|)
analogy_seen = False # flatanalogmem: the run has been judged analogous to its past
analogy_m = math.inf # flatanalog*pt: the order read from the latest analogous pair
regime_target = None # flatanalog*pt: the point the regime step aimed at
if stats is not None:
stats['forced'] = 0
stats['pre_refused'] = 0
@@ -1049,12 +1065,17 @@ def pure_root(f, a, b, xtol, maxfev, similarity="ratio", scale="derived",
cur = _config3(x, fx, x_prev, f_prev, x_prev2, f_prev2)
flag = (sticky_m is None and last_model and f_prev != 0.0
and fx / f_prev >= 0.25)
if pre_flat == "flatanalogmem":
if _analogous_and_steep(cur, configs):
m_pair = _analogy_order(cur, configs)
steep = m_pair is not None and m_pair >= 2.0
if flat_mem:
if steep:
analogy_seen = True
analogy_m = m_pair
enter = flag and analogy_seen
else:
enter = flag and _analogous_and_steep(cur, configs)
enter = flag and steep
if enter:
analogy_m = m_pair
if enter:
sticky_m = math.inf
if stats is not None:
@@ -1064,7 +1085,13 @@ def pure_root(f, a, b, xtol, maxfev, similarity="ratio", scale="derived",
if sticky_m is not None:
if step is None:
pre_refused += 1
step = 0.5 * (A + B) - x
if flat_pt:
# PREREG_flat_order_point 2026-09-21: split where |f| ~
# |x - r|^m puts the root, m read from the analogous pair
regime_target = _order_split(A, FA, B, FB, analogy_m)
step = regime_target - x
else:
step = 0.5 * (A + B) - x
if step is None and pre_contra and x != x_prev:
# PREREG_defect_contra_flat 2026-09-21 (contra). The bracket says
# which way f must go between its ends; the last two points say which
@@ -1197,6 +1224,15 @@ def pure_root(f, a, b, xtol, maxfev, similarity="ratio", scale="derived",
w_before = abs(B - A)
mid_now, lin_mid = 0.5 * (A + B), 0.5 * (FA + FB) # before the bracket moves
fnew = g(x_new)
if flat_pt and sticky_m is not None and regime_target is not None:
# PREREG_flat_order_point: the exit judgment at whatever point the regime
# aimed at - the line through the bracket ends predicts FA(1-t) + FB t there
# (at the midpoint this is (FA+FB)/2, the rule below). A point the
# safeguard moved is judged at its own t, the same line.
t_at = (x_new - A) / (B - A)
lin_mid = FA * (1.0 - t_at) + FB * t_at
mid_now = x_new
regime_target = None
if ((prestep == "flatstickexit" or pre_flat != "none") and sticky_m is not None
and x_new == mid_now
and abs(fnew - lin_mid) < abs(fnew)):