feat(factor): introduce Factor trait and BuiltinFactor enum

Adds the trait that all factors implement and the enum dispatcher
used by the schedule to drive heterogeneous factors without dynamic
dispatch in the hot loop.

The three built-in factors (TeamSum, RankDiff, Trunc) are stubbed
out; concrete implementations follow in tasks 4-6.
This commit is contained in:
2026-04-24 08:14:00 +02:00
parent dac4427b65
commit ebccc7b454
4 changed files with 112 additions and 0 deletions

16
src/factor/team_sum.rs Normal file
View File

@@ -0,0 +1,16 @@
use crate::{
factor::{Factor, VarId, VarStore},
gaussian::Gaussian,
};
#[derive(Debug)]
pub(crate) struct TeamSumFactor {
pub(crate) inputs: Vec<(Gaussian, f64)>,
pub(crate) out: VarId,
}
impl Factor for TeamSumFactor {
fn propagate(&mut self, _vars: &mut VarStore) -> (f64, f64) {
unimplemented!("TeamSumFactor stub — implemented in Task 4")
}
}