diff options
Diffstat (limited to 'crates/fparkan-script')
| -rw-r--r-- | crates/fparkan-script/src/lib.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/crates/fparkan-script/src/lib.rs b/crates/fparkan-script/src/lib.rs index 60b3a9d7..4dd73efd 100644 --- a/crates/fparkan-script/src/lib.rs +++ b/crates/fparkan-script/src/lib.rs @@ -1957,6 +1957,13 @@ impl Handler2RecordScheduler { self.records.retain(|record| record.key != key); } + /// Reweights an existing problem without refreshing its arguments or counter. + pub fn set_priority(&mut self, key: Handler2RecordKey, priority: f32) { + if let Some(record) = self.records.iter_mut().find(|record| record.key == key) { + record.scalar_1 = priority; + } + } + /// Inserts or refreshes one resolved handler input. /// /// The original compares the three identity words bit-for-bit. On an @@ -2517,6 +2524,18 @@ mod tests { } #[test] + fn handler_sixty_two_changes_only_the_current_problem_priority() { + let mut scheduler = Handler2RecordScheduler::default(); + let current = handler_two_input(1.5, -0.0, 3.0, 9.0, 4); + scheduler.submit(current); + scheduler.submit(handler_two_input(2.5, 0.0, 3.0, 12.0, 1)); + let mut expected = scheduler.records().to_vec(); + expected[0].scalar_1 = 17.75; + scheduler.set_priority(current.into(), 17.75); + assert_eq!(scheduler.records(), expected); + } + + #[test] fn handler_two_scheduler_refreshes_nan_and_wraps_counter() { let mut scheduler = Handler2RecordScheduler::default(); scheduler.submit(handler_two_input(f32::NAN, 1.0, 2.0, 3.0, u32::MAX)); |
