-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstatistics.go
38 lines (33 loc) · 1.2 KB
/
statistics.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package genetic_algorithm
type StatisticsConstructor func(StatisticsOptionsInterface) StatisticsInterface
type StatisticsAggregatorConstructor func(StatisticsOptionsInterface) StatisticsAggregatorInterface
// Accumulate statistics during optimization
type StatisticsInterface interface {
// Method for duration tracking
// Call without parameters means that optimization is started
Start(keys ...string)
// Should be called when tracked operation is complete.
End()
// Optimizer will call this method on each generation
// First call would be with initial population
OnGeneration(Chromosomes)
Data() StatisticsDataInterface
}
type StatisticsDataInterface interface{}
// Options for statistics
// Defines what data gather and what not
type StatisticsOptionsInterface interface {
// Ensures that other tracks what ensurer tracks
Ensure(other StatisticsOptionsInterface)
}
// Statistics aggregator
type StatisticsAggregatorInterface interface {
Aggregate(StatisticsDataInterface)
// Calcs mean of aggregated data
// Should be called on the end of aggregation
Compute() StatisticsDataInterface
}
type StatisticsAggregatorWithOptions interface {
StatisticsAggregatorInterface
Options() StatisticsOptionsInterface
}