presets.go 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package gago
  2. // Generational returns a GA instance that uses the generational model.
  3. func Generational(GenomeFactory GenomeFactory) GA {
  4. return GA{
  5. GenomeFactory: GenomeFactory,
  6. NPops: 2,
  7. PopSize: 50,
  8. Model: ModGenerational{
  9. Selector: SelTournament{
  10. NContestants: 3,
  11. },
  12. MutRate: 0.5,
  13. },
  14. }
  15. }
  16. // SimulatedAnnealing returns a GA instance that mimicks a basic simulated
  17. // annealing procedure.
  18. func SimulatedAnnealing(GenomeFactory GenomeFactory) GA {
  19. return GA{
  20. GenomeFactory: GenomeFactory,
  21. NPops: 1,
  22. PopSize: 1,
  23. Model: ModSimAnn{
  24. T: 100, // Starting temperature
  25. Tmin: 1, // Stopping temperature
  26. Alpha: 0.99, // Decrease rate per iteration
  27. },
  28. }
  29. }
  30. // HillClimbing returns a GA instance that mimicks a basic hill-climbing
  31. // procedure.
  32. func HillClimbing(GenomeFactory GenomeFactory) GA {
  33. return GA{
  34. GenomeFactory: GenomeFactory,
  35. NPops: 1,
  36. PopSize: 1,
  37. Model: ModMutationOnly{
  38. NChosen: 1,
  39. Selector: SelElitism{},
  40. Strict: true,
  41. },
  42. }
  43. }