Skip to content

Commit 7e24051

Browse files
committed
wip
1 parent f400a9d commit 7e24051

8 files changed

Lines changed: 438 additions & 70 deletions

File tree

src/benchmarks/evaluation.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,6 +1080,9 @@ impl ProblemSpec {
10801080
.clone()
10811081
.unwrap_or_else(|| self.problem.name().to_string())
10821082
}
1083+
pub fn get_family(&self) -> String {
1084+
self.family.clone()
1085+
}
10831086
}
10841087

10851088
pub fn new_initial_point(

src/experiment_runner/adaptive_runner.rs

Lines changed: 395 additions & 58 deletions
Large diffs are not rendered by default.

src/experiment_runner/experiment_runner.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,8 @@ pub fn get_optimizer_family(optimizer_name: &str) -> String {
451451
"L-BFGS".to_string()
452452
} else if optimizer_name.starts_with("Trust Region") {
453453
"Trust Region".to_string()
454+
} else if optimizer_name.starts_with("TrustRegion") {
455+
"Trust Region".to_string()
454456
} else if optimizer_name.starts_with("GD") {
455457
"GD".to_string()
456458
} else if optimizer_name.starts_with("Adam") {

src/experiment_runner/parameter_evolution.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ use std::sync::Arc;
1515
/// Represents a genome for an optimizer configuration
1616
#[derive(Clone, Debug, Serialize, Deserialize)]
1717
pub struct OptimizerGenome {
18+
pub success_rate: Option<f64>,
19+
pub mean_final_value: Option<f64>,
20+
pub total_evaluations: Option<usize>,
1821
pub optimizer_type: OptimizerType,
1922
pub parameters: HashMap<String, f64>,
2023
pub fitness: Option<f64>,
@@ -67,6 +70,9 @@ impl OptimizerGenome {
6770
parameters
6871
);
6972
Self {
73+
success_rate: None,
74+
mean_final_value: None,
75+
total_evaluations: None,
7076
optimizer_type,
7177
parameters,
7278
fitness: None,
@@ -565,6 +571,9 @@ impl ParameterEvolution {
565571

566572
// Create offspring with selected type
567573
let mut offspring = OptimizerGenome {
574+
success_rate: None,
575+
mean_final_value: None,
576+
total_evaluations: None,
568577
optimizer_type: offspring_type.clone(),
569578
parameters: HashMap::new(),
570579
fitness: None,
@@ -849,6 +858,9 @@ mod tests {
849858

850859
for i in 0..5 {
851860
let mut genome = OptimizerGenome {
861+
success_rate: None,
862+
mean_final_value: None,
863+
total_evaluations: None,
852864
optimizer_type: OptimizerType::QQN,
853865
parameters: HashMap::new(),
854866
fitness: Some(i as f64),

src/experiment_runner/report_generator.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,9 +1157,13 @@ pub(crate) fn shorten_optimizer_name(name: &str, max_length: usize) -> String {
11571157
.replace("Quadratic", "Quad")
11581158
.replace("Trust Region ", "")
11591159
.replace("Trust Region-", "")
1160+
.replace("TrustRegion-", "")
11601161
.replace("Adam-", "")
11611162
.replace("GD-", "")
11621163
.replace("L-BFGS-", "")
1164+
.replace("LBFGS-", "")
1165+
.replace("Evolved-", "")
1166+
.replace("Family-", "")
11631167
.replace("QQN-", "");
11641168

11651169
if shortened.len() <= max_length {

src/experiment_runner/reports/family_vs_family.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -587,17 +587,19 @@ pub(crate) fn calculate_family_performance_data(
587587
// Sort by success rate first, then by mean final value, then by total evaluations
588588
perf_data.sort_by(|a, b| {
589589
if is_no_threshold_mode() {
590-
// In no-threshold mode, sort by best value, then by total evaluations
591-
match a.2.total_cmp(&b.2) {
592-
std::cmp::Ordering::Equal => a.3.total_cmp(&b.3),
593-
ord => ord,
594-
}
590+
// In no-threshold mode, sort by best value (mean_final)
591+
a.2.total_cmp(&b.2)
595592
} else {
593+
// Sort by success rate first, then by total evaluations
594+
use std::cmp::Ordering;
596595
match b.1.total_cmp(&a.1) {
597-
std::cmp::Ordering::Equal => match a.2.total_cmp(&b.2) {
598-
std::cmp::Ordering::Equal => a.3.total_cmp(&b.3),
599-
ord => ord,
600-
},
596+
Ordering::Equal => {
597+
if b.1 > 0.0 {
598+
a.3.total_cmp(&b.3)
599+
} else {
600+
a.2.total_cmp(&b.2)
601+
}
602+
}
601603
ord => ord,
602604
}
603605
}

src/experiment_runner/reports/optimizer_problems.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ pub fn generate_problem_table_content(
8787
));
8888
}
8989

90+
// Canonical ranking sort
9091
if is_no_threshold_mode() {
9192
// In no-threshold mode, sort by best value
9293
perf_data.sort_by(|a, b| a.3.total_cmp(&b.3));
@@ -346,7 +347,6 @@ pub fn generate_problem_section(
346347
} else {
347348
(f64::NAN, f64::NAN, f64::NAN)
348349
};
349-
350350
let std_final = {
351351
let variance = final_values
352352
.iter()
@@ -384,6 +384,7 @@ pub fn generate_problem_section(
384384
));
385385
}
386386

387+
// Canonical ranking sort
387388
if is_no_threshold_mode() {
388389
// In no-threshold mode, sort by best value
389390
perf_data.sort_by(|a, b| a.3.total_cmp(&b.3));
@@ -729,7 +730,13 @@ fn generate_problem_performance_table(results: &BenchmarkResults) -> anyhow::Res
729730
} else {
730731
// Sort by success rate first, then by mean final value
731732
perf_data.sort_by(|a, b| match b.2.total_cmp(&a.2) {
732-
std::cmp::Ordering::Equal => a.1.total_cmp(&b.1),
733+
std::cmp::Ordering::Equal => {
734+
if (b.2 > 0.0) {
735+
a.3.total_cmp(&b.3)
736+
} else {
737+
a.1.total_cmp(&b.1)
738+
}
739+
}
733740
other => other,
734741
});
735742
}

tests/adaptive_benchmark_reports.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ use tokio::task::LocalSet;
1515
#[tokio::test]
1616
async fn test_adaptive_simple_problems() -> Result<(), Box<dyn Error + Send + Sync>> {
1717
init_logging(false)?;
18-
enable_no_threshold_mode();
18+
disable_no_threshold_mode();
19+
// enable_no_threshold_mode();
1920

2021
let local = LocalSet::new();
2122
local

0 commit comments

Comments
 (0)