FA-12016 / Optimization solver contracts / Open access
Conjugate gradient search direction uses the residual delta · case 01
Conjugate gradient search direction uses the residual delta.
ROOT CAUSE
Direction recurrence substitutes new-old residual for the new residual.
VERIFIED REPAIR
Use p_new=r_new+beta*p_old for the residual b-Ax convention.
Unsuccessful approach: Using a negative new residual applies the gradient sign convention to a residual recurrence.
Case contract
Return one CG direction vector given residual b-Ax, old direction and nonnegative beta; lengths agree.
Why this case matters
This deterministic solver-step model isolates an algorithmic invariant used by iterative optimization implementations.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(residual, old_residual, direction, beta):
return [r-o+beta*p for r,o,p in zip(residual,old_residual,direction)]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('nonzero history', solve([N], [2*N], [4*N], 0.5), [3*N])
check('restart', solve([N,-N], [1,1], [9,9], 0), [N,-N])
check('zero residual', solve([0], [N], [2*N], 0.5), [N])
check('orthogonal coordinates', solve([N,0], [0,N], [0,2*N], 0.5), [N,N])
check('negative direction', solve([N], [N], [-2*N], 1), [-N])
check('empty vectors', solve([], [], [], 1), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| nonzero history | [1.0] | [3] | Failed |
| restart | [0, -2] | [1, -1] | Failed |
| zero residual | [0.0] | [1] | Failed |
| orthogonal coordinates | [1.0, 0.0] | [1, 1] | Failed |
| negative direction | [-2] | [-1] | Failed |
| empty vectors | [] | [] | Passed |
SHA-256 / b626a817d7b8a0ef2942ea8626631e1bae578e458c402ecebb29e59fa481050d
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(residual, old_residual, direction, beta):
return [-r+beta*p for r,p in zip(residual,direction)]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('nonzero history', solve([N], [2*N], [4*N], 0.5), [3*N])
check('restart', solve([N,-N], [1,1], [9,9], 0), [N,-N])
check('zero residual', solve([0], [N], [2*N], 0.5), [N])
check('orthogonal coordinates', solve([N,0], [0,N], [0,2*N], 0.5), [N,N])
check('negative direction', solve([N], [N], [-2*N], 1), [-N])
check('empty vectors', solve([], [], [], 1), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| nonzero history | [1.0] | [3] | Failed |
| restart | [-1, 1] | [1, -1] | Failed |
| zero residual | [1.0] | [1] | Passed |
| orthogonal coordinates | [-1.0, 1.0] | [1, 1] | Failed |
| negative direction | [-3] | [-1] | Failed |
| empty vectors | [] | [] | Passed |
SHA-256 / 76918154f15487de065c4d7881be7a6e18ddbb25fbd6c7c7ae71174081333dbc
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(residual, old_residual, direction, beta):
return [r+beta*p for r,p in zip(residual,direction)]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('nonzero history', solve([N], [2*N], [4*N], 0.5), [3*N])
check('restart', solve([N,-N], [1,1], [9,9], 0), [N,-N])
check('zero residual', solve([0], [N], [2*N], 0.5), [N])
check('orthogonal coordinates', solve([N,0], [0,N], [0,2*N], 0.5), [N,N])
check('negative direction', solve([N], [N], [-2*N], 1), [-N])
check('empty vectors', solve([], [], [], 1), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| nonzero history | [3.0] | [3] | Passed |
| restart | [1, -1] | [1, -1] | Passed |
| zero residual | [1.0] | [1] | Passed |
| orthogonal coordinates | [1.0, 1.0] | [1, 1] | Passed |
| negative direction | [-1] | [-1] | Passed |
| empty vectors | [] | [] | Passed |
SHA-256 / 849cce9422fdde72c04947148445cfb414c9d32b2e3d19acd5826c452fdd7218
Verification & scope
Controlled finite inputs and explicit one-step contracts; this is not a production solver or a numerical stability benchmark. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.
Observations recorded using Python 3.12.14 at 2026-09-29T14:38:53.038340+00:00.
Case digest / d848915f5b468704ddcd4239f51f3d8f953b70f87c7e8f6f28e662111f8a338e