Oracles¶
Analytic oracles: exact functions with synthetic cost models.
Useful for unit tests and for controlled driver-benchmarking experiments where the ground truth and the cost model are both known exactly.
- class cadaques.oracles.analytic.AnalyticOracle(fn, price_fn=<function AnalyticOracle.<lambda>>, name='analytic')[source]¶
Wrap
fn(params) -> floatas a metered Oracle.price_fnmaps a query to its declared cost (default: a flat one-second tariff), letting tests exercise heterogeneous-cost scenarios deterministically. The settled cost equals the declared cost plus the (negligible) measured evaluation wall time, keeping the declared/settled distinction alive even in toy settings.
- cadaques.oracles.analytic.quadratic_bowl(center)[source]¶
Negative squared distance to
center(maximum 0 at the center).
Canonical illustrative oracle: the two-dimensional Ising model.
The campaign it supports is a textbook discovery task with an exact analytic answer: locate the critical temperature of the 2D Ising model by maximizing the magnetic susceptibility. Onsager (1944):
T_c = 2 / ln(1 + sqrt(2)) ≈ 2.269185 (J = k_B = 1)
The oracle is a checkerboard-Metropolis Monte Carlo simulation whose
fidelity knobs — lattice size L and number of measurement
sweeps — carry genuine, heterogeneous cost: accuracy is bought
with compute. This makes it a faithful miniature of real discovery
oracles, where every answer has a price and better answers cost more.
- cadaques.oracles.ising.T_C_EXACT: float = np.float64(2.269185314213022)¶
Onsager’s exact critical temperature (J = k_B = 1).
- class cadaques.oracles.ising.Ising2DOracle(default_L=24, default_sweeps=400, default_equilibration=200, seconds_per_spin_sweep=2.5e-08, seed=None)[source]¶
Metered Monte Carlo oracle for the 2D Ising model.
- Parameters:
default_L (int) – Fidelity defaults used when a query does not specify them.
default_sweeps (int) – Fidelity defaults used when a query does not specify them.
default_equilibration (int) – Fidelity defaults used when a query does not specify them.
seconds_per_spin_sweep (float) – Ex-ante cost model: declared price is proportional to
L**2 * (equilibration + sweeps). The settled cost inside each Result is the measured wall time, so declared/settled discrepancies are visible in the ledger by construction.seed (int | None) – Base seed; each evaluation derives an independent stream.