Merge claude/zeitbank-takt 72949f787 (deadline and bank logic read uhr::jetzt everywhere; bank specs on the test clock)

Also moves the three solver-to-target specs in flopbib.rs and flop_exakt.rs from a 60 s wall-clock
deadline onto the test clock with a deadline no run reaches (reichlich_zeit); under Mac load the
wall-clock deadline cut the solve short and the assertions failed. The assertions are unchanged.
Suite 450 green.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Marc Mintel
2026-12-05 16:45:01 +01:00
co-authored by Claude Opus 5.5
parent 0ae2da75f3
commit 53a4a84aa5
2 changed files with 23 additions and 3 deletions
+11 -1
View File
@@ -213,6 +213,16 @@ mod spec {
use std::collections::HashMap;
use std::time::Duration;
/// Solve "with time to spare" on the deterministic test clock (uhr::setze_takt): the deadline lies far beyond any number of clock
/// reads the solver makes, so the result never depends on the load of the machine.
fn reichlich_zeit<T>(f: impl FnOnce(Instant) -> T) -> T {
let start = Instant::now();
crate::uhr::setze_takt(Some((start, Duration::from_millis(1))));
let r = f(start + Duration::from_secs(24 * 3600));
crate::uhr::setze_takt(None);
r
}
fn umgebung(paare: &[(&str, &str)]) -> impl Fn(&str) -> Option<String> {
let m: HashMap<String, String> = paare.iter().map(|(a, b)| (a.to_string(), b.to_string())).collect();
move |n| m.get(n).cloned()
@@ -337,7 +347,7 @@ mod spec {
#[test]
fn loesen_mit_frist_erreicht_das_ziel_wenn_zeit_ist() {
let g = river();
let r = loese_bis(&g, 600, 0.01, Instant::now() + Duration::from_secs(60));
let r = reichlich_zeit(|frist| loese_bis(&g, 600, 0.01, frist));
assert!(r.fertig, "{r:?}");
assert!(r.ausbeutung <= 0.01, "{r:?}");
assert!(r.iterationen > 0 && r.iterationen % 10 == 0, "{r:?}");
+12 -2
View File
@@ -573,6 +573,16 @@ pub fn lauf(a: &[String]) {
mod spec {
use super::*;
/// Solve "with time to spare" on the deterministic test clock (uhr::setze_takt): the deadline lies far beyond any number of clock
/// reads the solver makes, so the result never depends on the load of the machine.
fn reichlich_zeit<T>(f: impl FnOnce(Instant) -> T) -> T {
let start = Instant::now();
crate::uhr::setze_takt(Some((start, Duration::from_millis(1))));
let r = f(start + Duration::from_secs(24 * 3600));
crate::uhr::setze_takt(None);
r
}
#[test]
fn es_gibt_1755_iso_flops_mit_gesamtgewicht_22100() {
let v = iso_flops();
@@ -659,7 +669,7 @@ mod spec {
}
let a = Aufgabe { ranges: [oop, ip], brett: flop.to_vec(), pot: 550, stack: 2000, rake: (0.05, 1000.0) };
let g = nachrechnen::bau_mit(&a, &[vec![]], false).unwrap();
crate::flop_exakt::loese_bis(&g, a.pot, 0.005, Instant::now() + Duration::from_secs(60));
reichlich_zeit(|frist| crate::flop_exakt::loese_bis(&g, a.pot, 0.005, frist));
(a, g)
}
@@ -830,7 +840,7 @@ mod spec {
assert!(w[0] + w[1] <= a.pot as f64 / 100.0 + 1e-3 && w[0] + w[1] > 0.8 * a.pot as f64 / 100.0, "{w:?}");
// OOP mit breitem Menue ist (bis auf die Konvergenz) nicht schlechter als mit engem
let mut b = nachrechnen::bau_mit_flopmenue(&a, &[vec![]], false, Menue::BreitOop.groessen()).unwrap();
crate::flop_exakt::loese_bis(&b, a.pot, 0.005, Instant::now() + Duration::from_secs(60));
reichlich_zeit(|frist| crate::flop_exakt::loese_bis(&b, a.pot, 0.005, frist));
postflop_solver::finalize(&mut b);
let wb = wurzelwerte(&mut b);
assert!(wb[0] >= w[0] - 2.0 * 0.005 * a.pot as f64 / 100.0, "breit {} eng {}", wb[0], w[0]);