feat: 完成四轮子独立pid调试
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#![allow(clippy::unwrap_used, clippy::expect_used)]
|
||||
|
||||
use std::sync::Mutex;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
|
||||
pub mod report {
|
||||
//! 报告与产物写出:CSV / TOML / JSON / Markdown(可选 SVG)。
|
||||
@@ -1656,6 +1657,7 @@ struct TuningBench {
|
||||
continue_on_abort: bool,
|
||||
best: Mutex<Option<(f64, experiment::Trace)>>,
|
||||
aborts: Mutex<Vec<String>>,
|
||||
stopped: AtomicBool,
|
||||
describe: String,
|
||||
}
|
||||
|
||||
@@ -1682,6 +1684,7 @@ impl TuningBench {
|
||||
continue_on_abort,
|
||||
best: Mutex::new(None),
|
||||
aborts: Mutex::new(Vec::new()),
|
||||
stopped: AtomicBool::new(false),
|
||||
describe,
|
||||
})
|
||||
}
|
||||
@@ -1701,12 +1704,18 @@ impl TuningBench {
|
||||
|
||||
impl Evaluator for TuningBench {
|
||||
fn evaluate(&self, gains: &VelocityGains) -> Score {
|
||||
if self.stopped.load(Ordering::Relaxed) {
|
||||
return Score::penalized(Verdict::Rejected);
|
||||
}
|
||||
let outcome = self.runner.run_trial(gains);
|
||||
let score = if let Some(reason) = outcome.abort {
|
||||
self.aborts
|
||||
.lock()
|
||||
.unwrap_or_else(std::sync::PoisonError::into_inner)
|
||||
.push(format!("{}: {reason}", self.describe));
|
||||
if !self.continue_on_abort {
|
||||
self.stopped.store(true, Ordering::Relaxed);
|
||||
}
|
||||
Score::penalized(verdict_for(&reason))
|
||||
} else {
|
||||
match experiment::StepMetrics::from_trace(&outcome.trace, &self.scenario()) {
|
||||
|
||||
Reference in New Issue
Block a user