@@ 241,15 241,35 @@ fn calculate_success_probability(
fn calculate_averaged_success_probability_with_deviation(
algorithm_data: &HashMap<String, Vec<DataPoint>>,
targets: &[f64],
+ max_evaluations: u32,
) -> Vec<ProbabilityPointWithDeviation> {
if algorithm_data.is_empty() || targets.is_empty() {
return Vec::new();
}
- // Calculate probability for each target
+ // Calculate probability for each target with global max evaluation extension
let target_probabilities: Vec<Vec<ProbabilityPoint>> = targets
.iter()
- .map(|&target| calculate_success_probability(algorithm_data, target))
+ .map(|&target| {
+ // First extend data to global max for this target calculation
+ let mut extended_algorithm_data = HashMap::new();
+ for (run_key, points) in algorithm_data {
+ let mut extended_points = points.clone();
+ if !extended_points.is_empty() {
+ extended_points.sort_by_key(|point| point.evaluations);
+ let last_point = extended_points.last().unwrap();
+ if last_point.evaluations < max_evaluations {
+ extended_points.push(DataPoint {
+ evaluations: max_evaluations,
+ fitness: last_point.fitness,
+ percentage_deviation: last_point.percentage_deviation,
+ });
+ }
+ }
+ extended_algorithm_data.insert(run_key.clone(), extended_points);
+ }
+ calculate_success_probability(&extended_algorithm_data, target)
+ })
.collect();
if target_probabilities.is_empty() {
@@ 304,29 324,22 @@ fn calculate_averaged_success_probability_with_deviation(
fn calculate_averaged_fitness_with_deviation(
algorithm_data: &HashMap<String, Vec<DataPoint>>,
+ max_evaluations: u32,
) -> Vec<DataPointWithDeviation> {
if algorithm_data.is_empty() {
return Vec::new();
}
- // Find the maximum evaluation point across all data
- let max_evaluation = algorithm_data
- .values()
- .flat_map(|points| points.iter())
- .map(|p| p.evaluations)
- .max()
- .unwrap_or(0);
-
- // Extend all data to the maximum evaluation point
+ // Extend all data to the global maximum evaluation point
let mut extended_algorithm_data = HashMap::new();
for (run_key, points) in algorithm_data {
let mut extended_points = points.clone();
if !extended_points.is_empty() {
extended_points.sort_by_key(|point| point.evaluations);
let last_point = extended_points.last().unwrap();
- if last_point.evaluations < max_evaluation {
+ if last_point.evaluations < max_evaluations {
extended_points.push(DataPoint {
- evaluations: max_evaluation,
+ evaluations: max_evaluations,
fitness: last_point.fitness,
percentage_deviation: last_point.percentage_deviation,
});
@@ 604,13 617,13 @@ fn create_plot(plot_data: &PlotData, config: &PlotConfig) -> Result<(), Box<dyn
if config.average_runs {
// Calculate averaged fitness data with deviation
- let averaged_data = calculate_averaged_fitness_with_deviation(algorithm_data);
+ let averaged_data = calculate_averaged_fitness_with_deviation(algorithm_data, max_evaluations);
if !averaged_data.is_empty() {
// Conditionally draw standard deviation bands
if config.show_std_dev {
// Create transparent confidence band
- let transparent_color = color.mix(0.3); // 30% opacity
+ let transparent_color = color.mix(0.15); // 15% opacity
// Create upper and lower bound points for the filled area
let upper_points: Vec<(f64, f64)> = averaged_data
@@ 829,7 842,7 @@ fn create_success_probability_plot(plot_data: &PlotData, config: &PlotConfig) ->
// Plot one averaged curve per algorithm with error bars
for algorithm in &config.algorithms {
if let Some(algorithm_data) = plot_data.data.get(algorithm) {
- let probability_data = calculate_averaged_success_probability_with_deviation(algorithm_data, &config.targets);
+ let probability_data = calculate_averaged_success_probability_with_deviation(algorithm_data, &config.targets, max_evaluations);
if !probability_data.is_empty() {
let color = colors[color_index % colors.len()];
@@ 838,7 851,7 @@ fn create_success_probability_plot(plot_data: &PlotData, config: &PlotConfig) ->
// Conditionally draw standard deviation bands
if config.show_std_dev {
// Create transparent confidence band
- let transparent_color = color.mix(0.3); // 30% opacity
+ let transparent_color = color.mix(0.15); // 15% opacity
// Create upper and lower bound points for the filled area
let upper_points: Vec<(f64, f64)> = probability_data