guaranteed Sorted
Optimization flag for statistics. Default is false.
NOTE:
it is not recommended to use this optimization for cGA
use it if you expect performance gains for statistical operators when getting a sorted population, see example below
If true:
executes Best, Worst, Mean with O(1)
statistics operators change their implementation - waiting to receive a sorted population in descending order only
executes it only in safe zones of evolve strategy (see Example below)
If false:
executes Best, Worst with O(N), Mean with O(N*log(N)).
order in population is irrelevant
Example:
statisticsConfig {
guaranteedSorted = true // Set flag to true
}
// create evolution strategy
evolve {
// other genetic operators
// Danger zone: the order of chromosomes is unknown
evaluation(sortAfter = true) // evaluate population and sort in descending order
// Safe zone: population sorted by descending
stat(best(), worst()) // OK but inefficient:
// without sorting: O(N) + O(N)
// with sorting: O(N*log(N)) + O(1) + O(1)
// other genetic operators
// Danger zone: the order of chromosomes is unknown
population.sort()
// Safe zone: population sorted by descending
stat(best(), mean(), worst()) // OK and efficient
// without sorting: O(N) + O(N*log(N)) + O(N)
// with sorting: O(N*log(N)) + O(1) + O(1)
}
Content copied to clipboard
See also
DEFAULT_GUARANTEED_SORTED