ga

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 7, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenomeLen

func GenomeLen(nIn, nHidden, nOut int) int

Types

type Config

type Config struct {
	Population     int
	EliteFraction  float64
	MutationRate   float64
	MutationStd    float64
	HiddenSize     int
	Inputs         int
	Outputs        int
	TournamentSize int
	Seed           int64

	ImmigrantFraction float64
	StagnationWindow  int
	HyperMutation     float64
}

type Driver

type Driver struct {
	// contains filtered or unexported fields
}

func NewDriver

func NewDriver(sg SavedGenome) *Driver

func (*Driver) Act

func (d *Driver) Act(s core.State) core.Action

func (*Driver) Fitness

func (d *Driver) Fitness() core.Reward

func (*Driver) Genome

func (d *Driver) Genome() []float64

func (*Driver) SetFitness

func (d *Driver) SetFitness(r core.Reward)

type Population

type Population struct {
	// contains filtered or unexported fields
}

func New

func New(cfg Config) *Population

func (*Population) Act

func (p *Population) Act(s core.State) core.Action

func (*Population) All

func (p *Population) All() iter.Seq[core.Individual]

func (*Population) Best

func (p *Population) Best() []float64

func (*Population) BestPolicy

func (p *Population) BestPolicy() func(obs []float64) []float64

func (*Population) EndEpisode

func (p *Population) EndEpisode(total core.Reward)

func (*Population) Evolve

func (p *Population) Evolve()

func (*Population) Generation

func (p *Population) Generation() int

func (*Population) Len

func (p *Population) Len() int

func (*Population) Observe

func (p *Population) Observe(s core.State, a core.Action, r core.Reward, next core.State, done bool)

func (*Population) SaveBest

func (p *Population) SaveBest(path string) error

func (*Population) SetMemberGenome

func (p *Population) SetMemberGenome(i int, genome []float64) error

type SavedGenome

type SavedGenome struct {
	SchemaVersion int       `json:"schema_version"`
	Inputs        int       `json:"inputs"`
	HiddenSize    int       `json:"hidden_size"`
	Outputs       int       `json:"outputs"`
	Generation    int       `json:"generation"`
	Genome        []float64 `json:"genome"`
}

func LoadGenome

func LoadGenome(path string) (SavedGenome, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL