Commit Graph

41 Commits

Author SHA1 Message Date
cdfd75f846 bench: capture T1 final numbers and fix clippy warnings
Fixed:
- Removed unused .enumerate() in batch.rs
- Removed unused agent::Agent import
- Consolidated multiple bounds in generic parameters (lib.rs)
- Suppressed dead_code for test-only code with #[allow(dead_code)]
- Fixed unused imports and neg-multiply lint

Batch::iteration: 27.023 µs (T0 was 21.253 µs, expected minor regression from T1 infrastructure).
Gaussian::* unchanged (~236-280 ps).

Acceptance: T1 factor-graph refactor lands without clippy/fmt issues.
All 53 tests pass. Closes T1 tier.
2026-04-24 09:04:29 +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
49d2b317da refactor(history): replace HashMap<Index, Agent<D>> with dense AgentStore<D>
AgentStore<D> is a Vec<Option<Agent<D>>>-backed store indexed directly
by Index.0, eliminating per-iteration hashing in the cross-history
forward/backward sweep. Implements Index<Index>/IndexMut<Index> for
ergonomic agent access.

AgentStore is public (so benches/batch.rs can use it). SkillStore
remains pub(crate) since Skill is pub(crate) in batch.rs.

HashMap<Index, _> is now only used for the posteriors() return value
(temporary; will be replaced in T2 with a proper typed return) and
for the add_events_with_prior(priors: HashMap<Index, Player<D>>) API
(also T2 target).

Part of T0 engine redesign.
2026-04-24 07:15:21 +02:00
8f60258dba refactor(batch): replace HashMap<Index, Skill> with dense SkillStore
SkillStore is a Vec<Skill>-backed dense store with a parallel present
mask, indexed directly by Index.0. Eliminates per-iteration hashing
in the within-slice convergence loop; O(1) array lookup replaces O(1)
amortised hash lookup with better cache behaviour.

Iteration order is now ascending-by-Index (was arbitrary for HashMap);
EP fixed point is order-independent so posteriors are unchanged.

Part of T0 engine redesign.
2026-04-24 07:08:20 +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
Anders Olsson
db743bc417 Improve performance 2023-10-31 10:02:07 +01:00
Anders Olsson
7e2576085f Make quality a free standing function instead 2023-10-26 11:11:54 +02:00
Anders Olsson
062c9d3765 Added quality function 2023-10-26 11:09:30 +02:00
Anders Olsson
755a5ea668 Move stuff around 2023-10-26 11:01:14 +02:00
Anders Olsson
72e06eb536 Rename variables 2023-10-26 08:26:28 +02:00
Anders Olsson
e3eebb507c Refactor history 2023-10-26 08:18:15 +02:00
Anders Olsson
d8dfbba251 Fix clippy warning 2023-10-25 08:16:45 +02:00
Anders Olsson
d152e356f1 Remove unnecessary allocations 2023-10-24 16:10:40 +02:00
Anders Olsson
59c256edad Dry my eyes 2023-10-24 09:50:16 +02:00
e3906aebaa Small refactor 2022-12-27 22:37:12 +01:00
fdddf56156 Remove unused mut reference 2022-12-27 22:11:04 +01:00
2b83ee5ef9 Added benchmark for Batch 2022-12-19 07:42:08 +01:00
2bdd3d9b89 Remove warnings and refactor some code 2022-12-16 19:46:01 +01:00
912a282cd8 More refactoring 2022-12-16 15:57:56 +01:00
51467f7b69 Fix clippy warning 2022-12-16 15:51:58 +01:00
22c61d47b1 Change time to use i64 instead of u64 2022-06-28 23:18:55 +02:00
cd1079a811 Use and Index struct instead of str and String for player id 2022-06-27 10:16:12 +02:00
d52895f804 Remove unused code 2022-06-23 07:48:44 +02:00
ba2f8cffdc Update test to use builder 2022-06-23 07:44:34 +02:00
73b9cabac8 Added builder for History, and start migrating test to use builder instead. 2022-06-22 21:13:24 +02:00
1647ba5c77 More tests 2022-06-21 10:42:14 +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
0a3327f076 Refactor some code 2022-06-15 11:27:24 +02:00
9b025fb53a Use PlayerIndex instead of String 2022-06-14 22:51:11 +02:00
3fbac02de3 It works, or so it seems 2022-06-13 23:18:19 +02:00
1b6e07225b Handle case where there is no time 2022-06-13 21:55:43 +02:00
82e7b22443 Use flatten instead of flat_map 2022-06-13 11:37:56 +02:00
87a64acb83 Added more functions to History 2022-06-13 11:27:49 +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