-
Notifications
You must be signed in to change notification settings - Fork 96
/
presets.go
58 lines (55 loc) · 1.16 KB
/
presets.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package gago
// Generational returns a GA instance that uses the generational model.
func Generational(MakeGenome GenomeMaker) GA {
var ga = GA{
MakeGenome: MakeGenome,
Topology: Topology{
NPopulations: 2,
NIndividuals: 50,
},
Model: ModGenerational{
Selector: SelTournament{
NParticipants: 3,
},
MutRate: 0.5,
},
}
ga.Initialize()
return ga
}
// SimulatedAnnealing returns a GA instance that mimicks a basic simulated
// annealing procedure.
func SimulatedAnnealing(MakeGenome GenomeMaker) GA {
var ga = GA{
MakeGenome: MakeGenome,
Topology: Topology{
NPopulations: 1,
NIndividuals: 1,
},
Model: ModSimAnn{
T: 100, // Starting temperature
Tmin: 1, // Stopping temperature
Alpha: 0.99, // Decrease rate per iteration
},
}
ga.Initialize()
return ga
}
// HillClimbing returns a GA instance that mimicks a basic hill-climbing
// procedure.
func HillClimbing(MakeGenome GenomeMaker) GA {
var ga = GA{
MakeGenome: MakeGenome,
Topology: Topology{
NPopulations: 1,
NIndividuals: 1,
},
Model: ModMutationOnly{
NChosen: 1,
Selector: SelElitism{},
Strict: true,
},
}
ga.Initialize()
return ga
}