File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -986,18 +986,21 @@ def get_island_stats(self) -> List[dict]:
986986 return stats
987987
988988 def _calculate_island_diversity (self , programs : List [Program ]) -> float :
989- """Calculate diversity within an island (optimized version)"""
989+ """Calculate diversity within an island (deterministic version)"""
990990 if len (programs ) < 2 :
991991 return 0.0
992992
993993 total_diversity = 0
994994 comparisons = 0
995995
996- # Sample fewer programs for performance
996+ # Use deterministic sampling instead of random.sample() to ensure consistent results
997997 sample_size = min (5 , len (programs )) # Reduced from 10 to 5
998- sample_programs = (
999- random .sample (programs , sample_size ) if len (programs ) > sample_size else programs
1000- )
998+
999+ # Sort programs by ID for deterministic ordering
1000+ sorted_programs = sorted (programs , key = lambda p : p .id )
1001+
1002+ # Take first N programs instead of random sampling
1003+ sample_programs = sorted_programs [:sample_size ]
10011004
10021005 # Limit total comparisons for performance
10031006 max_comparisons = 6 # Maximum comparisons to prevent long delays
You can’t perform that action at this time.
0 commit comments