forked from MaxHalford/eaopt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpresets.go
46 lines (43 loc) · 1.03 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
package gago
// Generational returns a GA instance that uses the generational model.
func Generational(GenomeFactory GenomeFactory) GA {
return GA{
GenomeFactory: GenomeFactory,
NPops: 2,
PopSize: 50,
Model: ModGenerational{
Selector: SelTournament{
NContestants: 3,
},
MutRate: 0.5,
},
}
}
// SimulatedAnnealing returns a GA instance that mimicks a basic simulated
// annealing procedure.
func SimulatedAnnealing(GenomeFactory GenomeFactory) GA {
return GA{
GenomeFactory: GenomeFactory,
NPops: 1,
PopSize: 1,
Model: ModSimAnn{
T: 100, // Starting temperature
Tmin: 1, // Stopping temperature
Alpha: 0.99, // Decrease rate per iteration
},
}
}
// HillClimbing returns a GA instance that mimicks a basic hill-climbing
// procedure.
func HillClimbing(GenomeFactory GenomeFactory) GA {
return GA{
GenomeFactory: GenomeFactory,
NPops: 1,
PopSize: 1,
Model: ModMutationOnly{
NChosen: 1,
Selector: SelElitism{},
Strict: true,
},
}
}