Skip to content

Commit 3dfdbca

Browse files
committed
fixed reports
1 parent 000474e commit 3dfdbca

File tree

8 files changed

+443
-256
lines changed

8 files changed

+443
-256
lines changed

process_results.sh

Lines changed: 38 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -20,45 +20,6 @@ log "Starting processing of benchmark result files..."
2020
processed_count=0
2121
error_count=0
2222

23-
# Use find for recursive search of markdown files
24-
while IFS= read -r -d '' md_file; do
25-
if [ -f "$md_file" ]; then
26-
log "Processing file: $md_file"
27-
md_dir=$(dirname "$md_file")
28-
base_name=$(basename "$md_file" .md)
29-
output_file="${md_dir}/${base_name}.html"
30-
# Skip if output file already exists
31-
if [ -f "$output_file" ]; then
32-
log "Skipping $md_file - output file $output_file already exists"
33-
continue
34-
fi
35-
36-
37-
log "Converting $md_file to $output_file"
38-
39-
# Create a temporary file with updated links
40-
temp_file=$(mktemp)
41-
# Replace .md links with .html links in the markdown content
42-
# Handle both markdown links [text](link.md) and HTML links <a href="link.md">
43-
sed -e 's/\(\[[^]]*\]([^)]*\)\.md\()\)/\1.html\2/g' \
44-
-e 's/\(href="[^"]*\)\.md"/\1.html"/g' \
45-
-e "s/\(href='[^']*\)\.md'/\1.html'/g" "$md_file" > "$temp_file"
46-
47-
if pandoc "$temp_file" -o "$output_file"; then
48-
log "Successfully converted: $md_file -> $output_file"
49-
rm "$temp_file"
50-
((processed_count++))
51-
else
52-
log_error "Failed to convert: $md_file"
53-
rm "$temp_file"
54-
((error_count++))
55-
fi
56-
else
57-
log "Skipping non-file or non-existent: $md_file"
58-
fi
59-
done < <(find results -name "*.md" -type f -print0 2>/dev/null)
60-
61-
6223
# Process all TeX files (table exports) in benchmark results
6324
log "Starting processing of TeX table export files..."
6425
# Use find for recursive search of TeX files
@@ -90,20 +51,50 @@ while IFS= read -r -d '' tex_file; do
9051
((error_count++))
9152
fi
9253

93-
if [ $? -eq 0 ]; then
94-
log "Successfully converted: $tex_file -> $output_file"
95-
# Clean up auxiliary files created by pdflatex
96-
rm -f "${base_name}.aux" "${base_name}.log"
54+
popd
55+
else
56+
log "Skipping non-file or non-existent: $tex_file"
57+
fi
58+
done < <(find results -name "*.tex" -type f -print0 2>/dev/null)
59+
60+
61+
# Use find for recursive search of markdown files
62+
while IFS= read -r -d '' md_file; do
63+
if [ -f "$md_file" ]; then
64+
log "Processing file: $md_file"
65+
md_dir=$(dirname "$md_file")
66+
base_name=$(basename "$md_file" .md)
67+
output_file="${md_dir}/${base_name}.html"
68+
# Skip if output file already exists
69+
if [ -f "$output_file" ]; then
70+
log "Skipping $md_file - output file $output_file already exists"
71+
continue
72+
fi
73+
74+
75+
log "Converting $md_file to $output_file"
76+
77+
# Create a temporary file with updated links (with .md extension for pandoc)
78+
temp_file=$(mktemp --suffix=.md)
79+
# Replace .md links with .html links in the markdown content
80+
# Handle both markdown links [text](link.md) and HTML links <a href="link.md">
81+
sed -e 's/\(\[[^]]*\]([^)]*\)\.md\()\)/\1.html\2/g' \
82+
-e 's/\(href="[^"]*\)\.md"/\1.html"/g' \
83+
-e "s/\(href='[^']*\)\.md'/\1.html'/g" "$md_file" > "$temp_file"
84+
85+
if pandoc "$temp_file" -f markdown -t html -o "$output_file" 2>/dev/null; then
86+
log "Successfully converted: $md_file -> $output_file"
87+
rm "$temp_file"
9788
((processed_count++))
9889
else
99-
log_error "Failed to convert: $tex_file"
90+
log_error "Failed to convert: $md_file"
91+
rm "$temp_file"
10092
((error_count++))
10193
fi
102-
popd
10394
else
104-
log "Skipping non-file or non-existent: $tex_file"
95+
log "Skipping non-file or non-existent: $md_file"
10596
fi
106-
done < <(find results -name "*.tex" -type f -print0 2>/dev/null)
97+
done < <(find results -name "*.md" -type f -print0 2>/dev/null)
10798

10899

109100
# Final summary

process_results_md.sh

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
#!/usr/bin/env bash
2+
# Enable error handling and detailed logging
3+
set -e # Exit on error
4+
set -x # Enable debug output (remove this line to reduce verbosity)
5+
6+
# Function to log messages with timestamp
7+
log() {
8+
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1"
9+
}
10+
11+
# Function to log errors
12+
log_error() {
13+
echo "[$(date '+%Y-%m-%d %H:%M:%S')] ERROR: $1" >&2
14+
}
15+
16+
# Cleanup function
17+
cleanup() {
18+
if [ -n "$temp_file" ] && [ -f "$temp_file" ]; then
19+
rm -f "$temp_file"
20+
log "Cleaned up temporary file: $temp_file"
21+
fi
22+
}
23+
24+
# Set up signal handlers
25+
trap cleanup EXIT
26+
trap 'log_error "Script interrupted by signal"; exit 130' INT TERM
27+
28+
# Check if pandoc is available
29+
if ! command -v pandoc >/dev/null 2>&1; then
30+
log_error "pandoc is not installed or not in PATH"
31+
exit 1
32+
fi
33+
34+
# Process all markdown files in benchmark results
35+
log "Starting processing of benchmark result files..."
36+
37+
# Initialize counters
38+
processed_count=0
39+
error_count=0
40+
41+
# Use find for recursive search of markdown files
42+
while IFS= read -r -d '' md_file; do
43+
if [ -f "$md_file" ]; then
44+
log "Processing file: $md_file"
45+
md_dir=$(dirname "$md_file")
46+
base_name=$(basename "$md_file" .md)
47+
output_file="${md_dir}/${base_name}.html"
48+
49+
# Skip if output file already exists
50+
if [ -f "$output_file" ]; then
51+
log "Skipping $md_file - output file $output_file already exists"
52+
continue
53+
fi
54+
55+
log "Converting $md_file to $output_file"
56+
57+
# Create a temporary file with updated links (with .md extension for pandoc)
58+
temp_file=$(mktemp --suffix=.md)
59+
60+
# Check if temp file was created successfully
61+
if [ ! -f "$temp_file" ]; then
62+
log_error "Failed to create temporary file"
63+
((error_count++))
64+
continue
65+
fi
66+
67+
# Replace .md links with .html links in the markdown content
68+
if ! sed -e 's/\(\[[^]]*\]([^)]*\)\.md\()\)/\1.html\2/g' \
69+
-e 's/\(href="[^"]*\)\.md"/\1.html"/g' \
70+
-e "s/\(href='[^']*\)\.md'/\1.html'/g" "$md_file" > "$temp_file"; then
71+
log_error "Failed to process markdown links in: $md_file"
72+
rm -f "$temp_file"
73+
((error_count++))
74+
continue
75+
fi
76+
77+
# Check file sizes for debugging
78+
original_size=$(wc -c < "$md_file")
79+
temp_size=$(wc -c < "$temp_file")
80+
log "File sizes - Original: ${original_size} bytes, Processed: ${temp_size} bytes"
81+
82+
# Run pandoc with timeout and better error handling
83+
log "Running pandoc conversion..."
84+
if timeout 300 pandoc "$temp_file" -f markdown -t html -o "$output_file" 2>&1; then
85+
log "Successfully converted: $md_file -> $output_file"
86+
((processed_count++))
87+
else
88+
pandoc_exit_code=$?
89+
log_error "Pandoc failed with exit code $pandoc_exit_code for file: $md_file"
90+
91+
# Check if output file was partially created
92+
if [ -f "$output_file" ]; then
93+
log "Removing partially created output file: $output_file"
94+
rm -f "$output_file"
95+
fi
96+
97+
((error_count++))
98+
fi
99+
100+
# Clean up temp file
101+
rm -f "$temp_file"
102+
temp_file=""
103+
104+
else
105+
log "Skipping non-file or non-existent: $md_file"
106+
fi
107+
done < <(find results -name "*.md" -type f -print0 2>/dev/null)
108+
109+
# Final summary
110+
log "Processing complete!"
111+
log "Files processed successfully: $processed_count"
112+
log "Files with errors: $error_count"
113+
114+
if [ $error_count -gt 0 ]; then
115+
log_error "Some files failed to process. Check the logs above for details."
116+
exit 1
117+
else
118+
log "All files processed successfully!"
119+
fi

process_results_tex.sh

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/usr/bin/env bash
2+
# Enable error handling and detailed logging
3+
set +e
4+
set +x
5+
6+
# Function to log messages with timestamp
7+
log() {
8+
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1"
9+
}
10+
11+
# Function to log errors
12+
log_error() {
13+
echo "[$(date '+%Y-%m-%d %H:%M:%S')] ERROR: $1" >&2
14+
}
15+
16+
# Process all markdown files in benchmark results
17+
log "Starting processing of benchmark result files..."
18+
19+
# Initialize counters
20+
processed_count=0
21+
error_count=0
22+
23+
# Process all TeX files (table exports) in benchmark results
24+
log "Starting processing of TeX table export files..."
25+
# Use find for recursive search of TeX files
26+
while IFS= read -r -d '' tex_file; do
27+
if [ -f "$tex_file" ]; then
28+
log "Processing TeX file: $tex_file"
29+
tex_dir=$(dirname "$tex_file")
30+
base_name=$(basename "$tex_file" .tex)
31+
output_file="${tex_dir}/${base_name}.pdf"
32+
# Skip if output file already exists
33+
if [ -f "$output_file" ]; then
34+
log "Skipping $tex_file - output file $output_file already exists"
35+
continue
36+
fi
37+
38+
log "Converting $tex_file to $output_file"
39+
# Use pdflatex to compile TeX to PDF
40+
# Run in the directory containing the TeX file to handle relative paths
41+
pushd "$tex_dir"
42+
pdflatex -interaction=nonstopmode "${base_name}.tex" > /dev/null 2>&1
43+
pdflatex -interaction=nonstopmode "${base_name}.tex" > /dev/null 2>&1
44+
if [ $? -eq 0 ]; then
45+
log "Successfully converted: $tex_file -> $output_file"
46+
# Clean up auxiliary files created by pdflatex
47+
rm -f "${base_name}.aux" "${base_name}.log"
48+
((processed_count++))
49+
else
50+
log_error "Failed to convert: $tex_file"
51+
((error_count++))
52+
fi
53+
54+
popd
55+
else
56+
log "Skipping non-file or non-existent: $tex_file"
57+
fi
58+
done < <(find results -name "*.tex" -type f -print0 2>/dev/null)
59+
60+
# Final summary
61+
log "Processing complete!"
62+
log "Files processed successfully: $processed_count"
63+
log "Files with errors: $error_count"
64+
if [ $error_count -gt 0 ]; then
65+
log_error "Some files failed to process. Check the logs above for details."
66+
exit 1
67+
else
68+
log "All files processed successfully!"
69+
fi

src/experiment_runner/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ pub mod reports;
1010
pub mod statistical_analysis;
1111
pub mod unified_report;
1212
pub mod unified_report_tests;
13+
pub mod test_data;
1314
pub use experiment_runner::*;
1415
pub use report_generator::*;
1516
pub use reports::convergence_analysis::ConvergenceAnalysisReport;

src/experiment_runner/report_generator.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -61,26 +61,26 @@ pub fn get_family(problem_name: &str) -> String {
6161
.unwrap_or(problem_name)
6262
{
6363
// Convex/Unimodal functions - smooth, single global minimum
64-
"Sphere" => "Convex Unimodal".to_string(),
65-
"Matyas" => "Convex Unimodal".to_string(),
64+
"Sphere" => "Sphere".to_string(),
65+
"Matyas" => "Matyas".to_string(),
6666

6767
// Non-convex but unimodal - single global minimum, challenging valleys/ridges
68-
"Rosenbrock" => "Non-Convex Unimodal".to_string(),
69-
"Beale" => "Non-Convex Unimodal".to_string(),
70-
"GoldsteinPrice" => "Non-Convex Unimodal".to_string(),
71-
"Levi" => "Non-Convex Unimodal".to_string(),
68+
"Rosenbrock" => "Rosenbrock".to_string(),
69+
"Beale" => "Beale".to_string(),
70+
"GoldsteinPrice" => "GoldsteinPrice".to_string(),
71+
"Levi" => "Levi".to_string(),
7272

7373
// Highly multimodal - many local minima, very challenging
74-
"Rastrigin" => "Highly Multimodal".to_string(),
75-
"Ackley" => "Highly Multimodal".to_string(),
76-
"Michalewicz" => "Highly Multimodal".to_string(),
77-
"StyblinskiTang" => "Highly Multimodal".to_string(),
74+
"Rastrigin" => "Rastrigin".to_string(),
75+
"Ackley" => "Ackley".to_string(),
76+
"Michalewicz" => "Michalewicz".to_string(),
77+
"StyblinskiTang" => "StyblinskiTang".to_string(),
7878

7979
// Machine Learning problems
80-
name if name.contains("Regression") => "ML Regression".to_string(),
81-
name if name.contains("Neural") => "ML Neural Networks".to_string(),
82-
name if name.contains("SVM") => "ML Classification".to_string(),
83-
name if name.contains("Logistic") => "ML Classification".to_string(),
80+
name if name.contains("Regression") => "Regression".to_string(),
81+
name if name.contains("Neural") => "Neural Networks".to_string(),
82+
name if name.contains("SVM") => "SVM".to_string(),
83+
name if name.contains("Logistic") => "Logistic".to_string(),
8484

8585
// Default fallback
8686
x => x.to_string(),
@@ -765,9 +765,9 @@ fn generate_winner_summary_table(all_results: &[(&ProblemSpec, BenchmarkResults)
765765
);
766766
summary
767767
}
768-
pub(crate) fn shorten_optimizer_name(name: &str) -> String {
768+
pub(crate) fn shorten_optimizer_name(name: &str, max_length: usize) -> String {
769769
// Shorten optimizer names for display in the table
770-
if name.len() <= 10 {
770+
if name.len() <= max_length {
771771
name.to_string()
772772
} else {
773773
// Try to create meaningful abbreviations
@@ -790,11 +790,11 @@ pub(crate) fn shorten_optimizer_name(name: &str) -> String {
790790
.replace("L-BFGS-", "")
791791
.replace("QQN-", "");
792792

793-
if shortened.len() <= 10 {
793+
if shortened.len() <= max_length {
794794
shortened
795795
} else {
796796
// Take first 7 chars + "..."
797-
format!("{}...", &shortened[..7.min(shortened.len())])
797+
format!("{}...", &shortened[..(max_length-3).min(shortened.len())])
798798
}
799799
}
800800
}

0 commit comments

Comments
 (0)