diff options
| author | tslil <tslil@posteo.de> | 2026-07-14 12:20:44 +0100 |
|---|---|---|
| committer | tslil <tslil@posteo.de> | 2026-07-14 13:02:51 +0100 |
| commit | 156cbfe2b0383521f540109682d98d35c88d65f8 (patch) | |
| tree | e4607f60c1c58ad566d2d86488a601d58eee4220 /src/learner.rs | |
| parent | 861fb134ad6d77faeb23e9571a31e0c6031d7374 (diff) | |
don't cache album list, use compression only on json for ease of inspection
Diffstat (limited to 'src/learner.rs')
| -rw-r--r-- | src/learner.rs | 36 |
1 files changed, 3 insertions, 33 deletions
diff --git a/src/learner.rs b/src/learner.rs index 59db567..942d52e 100644 --- a/src/learner.rs +++ b/src/learner.rs @@ -53,30 +53,6 @@ enum Episode { }, } -impl Episode { - fn prune_mut(&mut self, valid: &HashSet<String>) -> bool { - match self { - Episode::Continue { group, avoid, .. } => { - if let Some(a) = avoid - && valid.contains(a) - { - } else { - *avoid = None; - }; - group.retain(|g| valid.contains(g)); - !group.is_empty() - } - Episode::Escape { from, to, .. } => { - if !valid.contains(to) { - return false; - }; - from.retain(|f| valid.contains(f)); - !from.is_empty() - } - } - } -} - #[derive(Serialize, Deserialize, Default)] pub struct Learner { history: Vec<Episode>, @@ -88,14 +64,8 @@ pub enum Learning { } impl Learner { - pub fn prune(&mut self, valid: &HashSet<String>) { - self.history.retain_mut(|e| e.prune_mut(valid)); - } -} - -impl Learner { pub fn learn(&mut self, learning: &Learning) { - let stamp = chrono::Utc::now().format("U%Y%m%d-%H%M%S").to_string(); + let stamp = chrono::Utc::now().format("%+").to_string(); match learning { Learning::SkipToMore(trajectory, new) => { self.history.push(Episode::Escape { @@ -111,7 +81,7 @@ impl Learner { committed: stamp, }); } - }; + } } pub fn sample( @@ -135,7 +105,7 @@ impl Learner { let mut items: HashMap<String, f32> = candidates.into_iter().map(|c| (c.clone(), 0.0)).collect(); - for episode in self.history.iter() { + for episode in &self.history { match (episode, action) { (Episode::Escape { from, to, .. }, Action::Skip) => { let w = compute_weight(from, &trajectory); |
