Documentation
¶
Index ¶
- Constants
- func AStep3(omega float64) func(float64) float64
- func Atan(omega float64) func(float64) float64
- func CStep1(omega float64) func(float64) float64
- func ConservedGenomeSites(mg1, vg1 Vec, gvecs []Vec) (map[int]int, []int)
- func CorrVecs(vs0, vs1 Vec) (float64, float64)
- func CovarianceMatrix(xs []Vec, x0 Vec, ys []Vec, y0 Vec) *mat.Dense
- func DotVecs(v0, v1 Vec) float64
- func JustFail(err error)
- func LCatan(omega float64) func(float64) float64
- func LCtanh(omega float64) func(float64) float64
- func MatTotVar(vecs []Vec, mv Vec) float64
- func SCtanh(omega float64) func(float64) float64
- func SStep3(omega float64) func(float64) float64
- func SStep5(omega float64) func(float64) float64
- func Tanh(omega float64) func(float64) float64
- func XPCA(xs []Vec, x0 Vec, ys []Vec, y0 Vec) (Vec, []Vec, []Vec)
- type Cell
- func (c *Cell) Bottom(s *Setting) Vec
- func (c *Cell) DevStep(s *Setting, g Genome, istep int) float64
- func (c *Cell) Face(s *Setting, iface int) Vec
- func (c *Cell) Initialize(s *Setting)
- func (c *Cell) Left(s *Setting) Vec
- func (c *Cell) OppositeFace(s *Setting, iface int) Vec
- func (c *Cell) Right(s *Setting) Vec
- func (c *Cell) ToVec() Vec
- func (c *Cell) Top(s *Setting) Vec
- type CellEnvs
- type Environment
- func (env Environment) AddNoise(p float64) Environment
- func (env Environment) BlockFlip(s *Setting, ref Environment) Environment
- func (env Environment) BlockFlipNR(s *Setting, ref Environment) Environment
- func (env Environment) BlockNoise(s *Setting) Environment
- func (env Environment) Bottom(s *Setting) Vec
- func (env Environment) ChangeEnv(s *Setting) Environment
- func (env Environment) ChangeEnvBlock(s *Setting) Environment
- func (env Environment) Compare(env0 Environment) float64
- func (env Environment) Face(s *Setting, iface int) Vec
- func (env Environment) GenerateEnvs(s *Setting, nepochs int) EnvironmentS
- func (env Environment) Left(s *Setting) Vec
- func (env Environment) Len() int
- func (env Environment) MarkovFlip(s *Setting, ref Environment) Environment
- func (env Environment) Right(s *Setting) Vec
- func (env Environment) SelectingEnv(s *Setting) Vec
- func (env Environment) Top(s *Setting) Vec
- type EnvironmentS
- type Genome
- type GenomeDist
- type Individual
- func (indiv *Individual) Clone(s *Setting, env Environment) Individual
- func (indiv *Individual) CueVec(s *Setting) Vec
- func (indiv *Individual) Develop(s *Setting, env Environment) Individual
- func (indiv *Individual) Initialize(s *Setting, env Environment)
- func (indiv *Individual) NumCells() int
- func (indiv *Individual) Phenotype(s *Setting) []Vec
- func (indiv *Individual) PhenotypeVec(s *Setting) Vec
- func (indiv *Individual) SelectedPhenotype(s *Setting) []Vec
- func (indiv *Individual) SelectedPhenotypeVec(s *Setting) Vec
- func (indiv *Individual) SelectingCue(s *Setting) []Vec
- func (indiv *Individual) SelectingCueVec(s *Setting) Vec
- func (indiv *Individual) SetFitness(s *Setting, env Environment, conv float64)
- func (indiv *Individual) StateVec() Vec
- type PopStats
- type Population
- func (pop *Population) AnalyzeVarEnvs(s *Setting, env0 Environment, n int)
- func (pop *Population) Clone(s *Setting, env Environment) Population
- func (pop *Population) CueVecs(s *Setting) []Vec
- func (pop *Population) Develop(s *Setting, env Vec)
- func (pop *Population) Dump(s *Setting) string
- func (pop *Population) DumpJSON(s *Setting) string
- func (pop0 *Population) Evolve(s *Setting, env Environment) (Population, string)
- func (pop *Population) GenoPhenoPlot(s *Setting, p0, paxis, g0, gaxis, env0 Vec)
- func (pop *Population) GenoPhenoPlot2(s *Setting, gd0 GenomeDist, env1, env0 Environment)
- func (pop *Population) GenomeVecs(s *Setting) []Vec
- func (pop *Population) GetGenomeDist(s *Setting) GenomeDist
- func (pop *Population) GetMaxFitness() float64
- func (pop *Population) GetPopStats() PopStats
- func (pop *Population) GetProjected1(s *Setting, fout *os.File, label string, xs []Vec, x0 Vec, axis, ps Vec) (Vec, Vec)
- func (pop *Population) GetProjected2(s *Setting, fout *os.File, label string, xs []Vec, x0 Vec, ys []Vec, y0 Vec, ...) (Vec, Vec)
- func (pop *Population) Initialize(s *Setting, env Environment)
- func (pop *Population) PGCov(s *Setting, p0, paxis, g0, gaxis, env0, env1 Vec)
- func (pop *Population) PhenoVecs(s *Setting) []Vec
- func (pop *Population) PrintPopStats(fout *os.File, gs, ps, ali0 Vec)
- func (pop *Population) Reproduce(s *Setting) Population
- func (pop *Population) SVDProject(s *Setting, p0, paxis, g0, gaxis, c0, caxis Vec)
- func (pop *Population) Select(s *Setting) Population
- func (pop *Population) SelectedPhenoVecs(s *Setting) []Vec
- func (pop *Population) Sort()
- func (pop *Population) StateVecs() []Vec
- type Setting
- func (s *Setting) AnalyzeAPRGeno(env0, env1 Environment, pop0, pop1 Population)
- func (s *Setting) CellId(i, j int) int
- func (s *Setting) Dump()
- func (s *Setting) GetCueAxis(env0, env1 Environment) (Vec, Vec)
- func (s *Setting) GetGenomeAxis(pop0, pop1 Population) (Vec, Vec)
- func (s *Setting) GetPhenoAxis(pop0, pop1 Population, env0, env1 Environment) (Vec, Vec)
- func (s *Setting) GetSelectedPhenoAxis(pop0, pop1 Population, env0, env1 Environment) (Vec, Vec)
- func (s *Setting) LoadEnvs(filename string) []Environment
- func (s *Setting) LoadPopulation(filename string) Population
- func (s *Setting) LoadPopulationJSON(filename string, env Environment) Population
- func (s *Setting) MateIndividuals(indiv0, indiv1 Individual, env Environment) (Individual, Individual)
- func (s *Setting) NewCell(id int) Cell
- func (s *Setting) NewEnvironment() Environment
- func (s *Setting) NewGenome() Genome
- func (s *Setting) NewGenomeDist() GenomeDist
- func (s *Setting) NewIndividual(id int, env Environment) Individual
- func (s *Setting) NewPopulation(env Environment) Population
- func (s *Setting) RandomGenomeVariance() float64
- func (s *Setting) SaveEnvs(filename string, nepochs int) EnvironmentS
- func (s *Setting) SetCellEnv(cells []Cell, env Environment)
- func (s *Setting) SetCellInt(cells []Cell)
- func (s *Setting) SetDevelop(flag bool)
- func (s *Setting) SetLayerM1(n int)
- func (s *Setting) SetLayerSL(n int)
- func (s *Setting) SetModel(basename string)
- func (s *Setting) SetOmega()
- func (s *Setting) TrajectoryFilename(iepoch, igen int, suffix string) string
- type SliceOfMaps
- type SpMat
- func (sp *SpMat) Clone() SpMat
- func (sp SpMat) Density() float64
- func (sp0 SpMat) Equal(sp1 SpMat) bool
- func (mat0 SpMat) MateWith(mat1 SpMat) (SpMat, SpMat)
- func (sp SpMat) Mutate(rate float64, density float64)
- func (sp SpMat) Ncols() int
- func (sp SpMat) Nrows() int
- func (sp SpMat) PickRandomElements(n int) SliceOfMaps[float64]
- func (sp SpMat) Randomize(density float64)
- func (sp SpMat) ScaleBy(scale float64) SpMat
- func (sp *SpMat) ToVec() Vec
- type Vec
- func (vout Vec) Acc(vin Vec) Vec
- func (vout Vec) Add(v0, v1 Vec) Vec
- func (vout Vec) ApplyFVec(f func(float64) float64, vin Vec)
- func (vec Vec) Clone() Vec
- func (vout Vec) Diff(v0, v1 Vec) Vec
- func (vec0 Vec) MateWith(vec1 Vec) (Vec, Vec)
- func (vec Vec) Mean() float64
- func (vout Vec) MultSpMatVec(sp SpMat, vin Vec)
- func (vec Vec) Mutate(rate float64)
- func (v Vec) Norm1() float64
- func (v Vec) Norm2() float64
- func (v Vec) NormInf() float64
- func (v Vec) Normalize() Vec
- func (vout Vec) ScaleAcc(s float64, vin Vec) Vec
- func (vec Vec) ScaleBy(f float64) Vec
- func (vec Vec) SetAll(v float64)
- func (vec Vec) Sum() float64
Constants ¶
View Source
const ( Left = iota Top Right Bottom NumFaces // Numbef of faces per cell )
faces
View Source
const (
Sqrt3 = 1.7320508075688772
)
Variables ¶
This section is empty.
Functions ¶
func ConservedGenomeSites ¶
Types ¶
type Cell ¶
type Cell struct {
Id int // Identifier within an individual
Facing [NumFaces]int // Facing Cell's Id; -1 if none.
Cue []Vec // points to neighboring cell face or environment
S []Vec // state vectors
Pave Vec
Pvar Vec
}
func (*Cell) Initialize ¶
type Environment ¶
type Environment = Vec
func (Environment) AddNoise ¶
func (env Environment) AddNoise(p float64) Environment
func (Environment) BlockFlip ¶
func (env Environment) BlockFlip(s *Setting, ref Environment) Environment
func (Environment) BlockFlipNR ¶
func (env Environment) BlockFlipNR(s *Setting, ref Environment) Environment
less random block flip
func (Environment) BlockNoise ¶
func (env Environment) BlockNoise(s *Setting) Environment
func (Environment) Bottom ¶
func (env Environment) Bottom(s *Setting) Vec
func (Environment) ChangeEnv ¶
func (env Environment) ChangeEnv(s *Setting) Environment
func (Environment) ChangeEnvBlock ¶
func (env Environment) ChangeEnvBlock(s *Setting) Environment
func (Environment) Compare ¶
func (env Environment) Compare(env0 Environment) float64
func (Environment) GenerateEnvs ¶
func (env Environment) GenerateEnvs(s *Setting, nepochs int) EnvironmentS
func (Environment) Left ¶
func (env Environment) Left(s *Setting) Vec
func (Environment) Len ¶
func (env Environment) Len() int
func (Environment) MarkovFlip ¶
func (env Environment) MarkovFlip(s *Setting, ref Environment) Environment
func (Environment) Right ¶
func (env Environment) Right(s *Setting) Vec
func (Environment) SelectingEnv ¶
func (env Environment) SelectingEnv(s *Setting) Vec
func (Environment) Top ¶
func (env Environment) Top(s *Setting) Vec
type EnvironmentS ¶
type EnvironmentS []Environment
func (EnvironmentS) DumpEnvs ¶
func (envs EnvironmentS) DumpEnvs(filename string)
type Genome ¶
type Genome struct {
B []Vec
SliceOfMaps[SpMat]
}
type GenomeDist ¶
type GenomeDist struct {
Nelems int
P [3]SliceOfMaps[SpMat] // 0, +1, -1
}
func (GenomeDist) KLDivergenceFrom ¶
func (gd1 GenomeDist) KLDivergenceFrom(gd0 GenomeDist) float64
type Individual ¶
type Individual struct {
Id int
MomId int
DadId int
Genome Genome
Cells []Cell
Ndev int
Align float64
Fitness float64
}
func (*Individual) Clone ¶
func (indiv *Individual) Clone(s *Setting, env Environment) Individual
func (*Individual) CueVec ¶
func (indiv *Individual) CueVec(s *Setting) Vec
func (*Individual) Develop ¶
func (indiv *Individual) Develop(s *Setting, env Environment) Individual
func (*Individual) Initialize ¶
func (indiv *Individual) Initialize(s *Setting, env Environment)
func (*Individual) NumCells ¶
func (indiv *Individual) NumCells() int
func (*Individual) Phenotype ¶
func (indiv *Individual) Phenotype(s *Setting) []Vec
func (*Individual) PhenotypeVec ¶
func (indiv *Individual) PhenotypeVec(s *Setting) Vec
func (*Individual) SelectedPhenotype ¶
func (indiv *Individual) SelectedPhenotype(s *Setting) []Vec
func (*Individual) SelectedPhenotypeVec ¶
func (indiv *Individual) SelectedPhenotypeVec(s *Setting) Vec
func (*Individual) SelectingCue ¶
func (indiv *Individual) SelectingCue(s *Setting) []Vec
func (*Individual) SelectingCueVec ¶
func (indiv *Individual) SelectingCueVec(s *Setting) Vec
func (*Individual) SetFitness ¶
func (indiv *Individual) SetFitness(s *Setting, env Environment, conv float64)
func (*Individual) StateVec ¶
func (indiv *Individual) StateVec() Vec
type Population ¶
type Population struct {
Iepoch int // epoch
Igen int // generation
Env Environment
Indivs []Individual
}
func (*Population) AnalyzeVarEnvs ¶
func (pop *Population) AnalyzeVarEnvs(s *Setting, env0 Environment, n int)
Analyze adaptive plastic responses to various environmental changes.
func (*Population) Clone ¶
func (pop *Population) Clone(s *Setting, env Environment) Population
func (*Population) CueVecs ¶
func (pop *Population) CueVecs(s *Setting) []Vec
func (*Population) Develop ¶
func (pop *Population) Develop(s *Setting, env Vec)
func (*Population) Dump ¶
func (pop *Population) Dump(s *Setting) string
Dump the Population in a gzipped binary file.
func (*Population) DumpJSON ¶
func (pop *Population) DumpJSON(s *Setting) string
func (*Population) Evolve ¶
func (pop0 *Population) Evolve(s *Setting, env Environment) (Population, string)
func (*Population) GenoPhenoPlot ¶
func (pop *Population) GenoPhenoPlot(s *Setting, p0, paxis, g0, gaxis, env0 Vec)
func (*Population) GenoPhenoPlot2 ¶
func (pop *Population) GenoPhenoPlot2(s *Setting, gd0 GenomeDist, env1, env0 Environment)
func (*Population) GenomeVecs ¶
func (pop *Population) GenomeVecs(s *Setting) []Vec
func (*Population) GetGenomeDist ¶
func (pop *Population) GetGenomeDist(s *Setting) GenomeDist
func (*Population) GetMaxFitness ¶
func (pop *Population) GetMaxFitness() float64
func (*Population) GetPopStats ¶
func (pop *Population) GetPopStats() PopStats
func (*Population) GetProjected1 ¶
func (*Population) GetProjected2 ¶
func (*Population) Initialize ¶
func (pop *Population) Initialize(s *Setting, env Environment)
func (*Population) PGCov ¶
func (pop *Population) PGCov(s *Setting, p0, paxis, g0, gaxis, env0, env1 Vec)
func (*Population) PhenoVecs ¶
func (pop *Population) PhenoVecs(s *Setting) []Vec
func (*Population) PrintPopStats ¶
func (pop *Population) PrintPopStats(fout *os.File, gs, ps, ali0 Vec)
func (*Population) Reproduce ¶
func (pop *Population) Reproduce(s *Setting) Population
func (*Population) SVDProject ¶
func (pop *Population) SVDProject(s *Setting, p0, paxis, g0, gaxis, c0, caxis Vec)
func (*Population) Select ¶
func (pop *Population) Select(s *Setting) Population
func (*Population) SelectedPhenoVecs ¶
func (pop *Population) SelectedPhenoVecs(s *Setting) []Vec
func (*Population) Sort ¶
func (pop *Population) Sort()
func (*Population) StateVecs ¶
func (pop *Population) StateVecs() []Vec
type Setting ¶
type Setting struct {
Basename string // name of the model
Seed uint64 // random seed
Outdir string // output directory for trajectory
EnvFlip bool // learn plasticity
MaxPopulation int // maximum population size
MaxGeneration int // maximum number of generations per epoch
NumCellX int // number of cells in the x-axis
NumCellY int // number of cells in the y-axis
LenFace int // face length
ProductionRun bool // true if production run (i.e. "test" phase)
LenBlock int // noise block length
Penv01 float64
Penv10 float64
MutRate float64 // mutation rate
ConvDevelop float64 // convergence limit
Denv float64 // size of an environmental change
EnvNoise float64
SelStrength float64 // selection strength
WithCue bool // with cue or not
MaxDevelop int // maximum number of developmental steps
Alpha float64 // weight for exponential moving average
NumLayers int // number of middle layers
LenLayer []int // Length of each state vector
Topology SliceOfMaps[float64] // densities of genome matrices
Omega Vec // scaling factors of activation functions
}
various set-ups
func GetDefaultSetting ¶
func LoadSetting ¶
func (*Setting) AnalyzeAPRGeno ¶
func (s *Setting) AnalyzeAPRGeno(env0, env1 Environment, pop0, pop1 Population)
Comparing adaptive plastic response in env0 to evolutionary adaptation to env1
func (*Setting) GetCueAxis ¶
func (s *Setting) GetCueAxis(env0, env1 Environment) (Vec, Vec)
func (*Setting) GetGenomeAxis ¶
func (s *Setting) GetGenomeAxis(pop0, pop1 Population) (Vec, Vec)
func (*Setting) GetPhenoAxis ¶
func (s *Setting) GetPhenoAxis(pop0, pop1 Population, env0, env1 Environment) (Vec, Vec)
func (*Setting) GetSelectedPhenoAxis ¶
func (s *Setting) GetSelectedPhenoAxis(pop0, pop1 Population, env0, env1 Environment) (Vec, Vec)
func (*Setting) LoadEnvs ¶
func (s *Setting) LoadEnvs(filename string) []Environment
func (*Setting) LoadPopulation ¶
func (s *Setting) LoadPopulation(filename string) Population
func (*Setting) LoadPopulationJSON ¶
func (s *Setting) LoadPopulationJSON(filename string, env Environment) Population
func (*Setting) MateIndividuals ¶
func (s *Setting) MateIndividuals(indiv0, indiv1 Individual, env Environment) (Individual, Individual)
func (*Setting) NewEnvironment ¶
func (s *Setting) NewEnvironment() Environment
func (*Setting) NewGenomeDist ¶
func (s *Setting) NewGenomeDist() GenomeDist
func (*Setting) NewIndividual ¶
func (s *Setting) NewIndividual(id int, env Environment) Individual
func (*Setting) NewPopulation ¶
func (s *Setting) NewPopulation(env Environment) Population
func (*Setting) RandomGenomeVariance ¶
Expected variance of a random genome.
func (*Setting) SetCellEnv ¶
func (s *Setting) SetCellEnv(cells []Cell, env Environment)
func (*Setting) SetCellInt ¶
func (*Setting) SetDevelop ¶
func (*Setting) SetLayerM1 ¶
Feedback loop to the previous layer
type SliceOfMaps ¶
sparse matrix of anything.
func NewSliceOfMaps ¶
func NewSliceOfMaps[T any](n int) SliceOfMaps[T]
func (SliceOfMaps[T]) At ¶
func (sm SliceOfMaps[T]) At(i, j int) T
func (SliceOfMaps[T]) Do ¶
func (sm SliceOfMaps[T]) Do(f func(i, j int, v T))
func (SliceOfMaps[T]) EachRow ¶
func (sm SliceOfMaps[T]) EachRow(f func(i int, mi map[int]T))
func (SliceOfMaps[T]) Set ¶
func (sm SliceOfMaps[T]) Set(i, j int, v T)
type SpMat ¶
type SpMat struct {
Ncol int
SliceOfMaps[float64]
}
sparse matrix
func (SpMat) PickRandomElements ¶
func (sp SpMat) PickRandomElements(n int) SliceOfMaps[float64]
type Vec ¶
type Vec []float64
vector
func (Vec) MultSpMatVec ¶
multiply a sparse matrix to a vector. vout is NOT initialized!!
Click to show internal directories.
Click to hide internal directories.