Commit Graph

27 Commits

Author SHA1 Message Date
c02d5ca0ab perf(game): replace order.clone()+position() with inverse permutation 2026-04-24 08:58:09 +02:00
cb07a874e8 refactor(game): rebuild Game::likelihoods on factor-graph machinery
Game::likelihoods now uses VarStore (for diff vars) and TruncFactor
(for EP truncation + evidence caching) instead of TeamMessage and
DiffMessage. The EP loop structure is preserved exactly; VarId-keyed
diff vars live in the arena's VarStore (capacity reused per batch).

ScratchArena loses teams/diffs/ties/margins; gains VarStore and
sort_buf (sort_perm allocation eliminated). message.rs deleted.

Public API of Game (new, posteriors, likelihoods, evidence) unchanged.
2026-04-24 08:51:18 +02:00
b1e0fcb817 perf(game): eliminate per-event allocations via ScratchArena
Game::likelihoods previously allocated four Vecs (teams, diffs, ties,
margins) on every call. Batch now owns one ScratchArena reused across
all Game::new calls in the iteration loop; likelihoods() clears and
extends the arena buffers instead of allocating fresh.

For log_evidence (called infrequently), a local ScratchArena is created
per invocation so the method signature stays &self.

Also: add #[derive(Debug)] to TeamMessage and DiffMessage (required by
ScratchArena's own Debug derive).

Part of T0 engine redesign.
2026-04-24 07:24:29 +02:00
a667deb7e1 refactor(gaussian): switch to natural-parameter storage (pi, tau)
Mul and Div become two f64 adds/subs with no sqrt in the hot path.
mu() and sigma() are computed on demand from stored pi/tau.

Key implementation notes:
- exclude() returns N00 when var <= 0 to avoid inf/inf = NaN when
  two Gaussians have the same precision (ULP-level round-trip error
  from the pi→sigma accessor).
- Mul<f64> by 0.0 returns N00 (point mass at 0), matching old behavior.
- from_ms(0, 0) == N00 {pi:inf, tau:0}; from_ms(0, inf) == N_INF {pi:0, tau:0}.

Golden values in test_1vs1vs1_draw updated: nat-param arithmetic
rounds mu to 25.0 (was 24.999999) and shifts sigma by ~3e-7.
Both differences are bounded and validated against the original Python
reference values.

Part of T0 engine redesign.
2026-04-24 06:59:43 +02:00
04d5478ee4 style: cargo fmt 2026-04-23 20:23:13 +02:00
a1f282a1c8 feat: added a Drift trait and a "default" ConstantDrift implementation 2026-03-16 12:06:04 +01:00
02ae2f0977 Change assert to debug_assert 2024-04-03 09:44:41 +02:00
Anders Olsson
d152e356f1 Remove unnecessary allocations 2023-10-24 16:10:40 +02:00
Anders Olsson
efa235be59 Clean up 2023-10-24 09:44:42 +02:00
05f178641c Rename d to diff, and t to team 2022-12-29 20:38:36 +01:00
e3906aebaa Small refactor 2022-12-27 22:37:12 +01:00
b93194f762 Added default implementation for TeamMessage 2022-12-20 11:08:27 +01:00
6125a81696 Fixed test 2022-06-27 11:49:47 +02:00
2467d7e027 Update test to use assert_ulps_eq 2022-06-27 11:46:59 +02:00
a573f5cf0a More tests 2022-06-21 10:48:04 +02:00
1647ba5c77 More tests 2022-06-21 10:42:14 +02:00
be4834ca85 Fix tests 2022-06-20 23:58:05 +02:00
0a35645091 More things, more tests 2022-06-20 23:56:35 +02:00
0efb0312da More tests, more code 2022-06-19 23:52:52 +02:00
c9d9d59535 More things, better things, awesome 2022-06-18 23:39:42 +02:00
dc10504b80 Port from julia version instead 2022-06-18 22:27:38 +02:00
36c3366990 Refactor some stuff 2022-06-15 13:26:03 +02:00
0a3327f076 Refactor some code 2022-06-15 11:27:24 +02:00
811a4ca418 Inline a lot of functions 2022-06-14 23:00:21 +02:00
4a13e4dcd2 More test passing for History 2022-06-13 11:04:05 +02:00
4227617513 Working on History struct. First test is passing. 2022-06-12 23:11:13 +02:00
de58d01322 Initial commit. 2022-06-10 15:22:27 +02:00