harmonic

package
v0.0.0-...-3c91b98 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2019 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NetworkSize = 7
	Iterations  = 10000
)
View Source
const Threshold = 8 * fixed.FixedOne

Variables

View Source
var (
	Notes = [...]uint8{
		60,
		62,
		64,
		65,
		67,
		69,
		71,
	}
	MaxEntropy         = math.Log2(float64(len(Notes)))
	MaxMarkov          = 2 * MaxEntropy
	MaxSpectrumEntropy = math.Log(Iterations)
)

Functions

func Bench

func Bench()

func Entropy

func Entropy(values []complex128) (entropy float64)

func HarmonicGenomeFactory

func HarmonicGenomeFactory(rnd *rand.Rand) eaopt.Genome

HarmonicGenomeFactory create a new harmonic genome

func Inference

func Inference(name string)

func Learn

func Learn()

Types

type Channel

type Channel struct {
	Delay  uint8
	Buffer [8]Message
	Out    chan<- fixed.Fixed
}

Channel is an delayed output channel to another harmonic node

func (*Channel) Send

func (c *Channel) Send(value fixed.Fixed)

Send sends a delayed message to another harmonic node

func (*Channel) Step

func (c *Channel) Step()

Step steps the state of the channel which can send messages

type Harmonic

type Harmonic struct {
	Note    uint8
	States  [2]fixed.Fixed
	Weights [4]fixed.Fixed
	Outbox  []Channel
	Inbox   []<-chan fixed.Fixed
}

Harmonic is a harmonic node

func (*Harmonic) Step

func (h *Harmonic) Step() bool

Step steps the state of the harmonic node

type HarmonicGenome

type HarmonicGenome struct {
	Connections slices.Uint8
	States      slices.Fixed
	Weights     slices.Fixed
}

HarmonicGenome is a genome representing the parameters of a harmonic network

func ReadHarmonicGenome

func ReadHarmonicGenome(name string) *HarmonicGenome

func (*HarmonicGenome) Clone

func (g *HarmonicGenome) Clone() eaopt.Genome

Clone produces a copy of a harmonic genome

func (*HarmonicGenome) Crossover

func (g *HarmonicGenome) Crossover(r eaopt.Genome, rng *rand.Rand)

Crossover mates two harmonic genomes

func (*HarmonicGenome) Evaluate

func (g *HarmonicGenome) Evaluate() (float64, error)

Evaluate computes the fitness of the harmonic genome

func (*HarmonicGenome) Mutate

func (g *HarmonicGenome) Mutate(rng *rand.Rand)

Mutate mutates the harmonic genome

func (*HarmonicGenome) NewHarmonicNetwork

func (g *HarmonicGenome) NewHarmonicNetwork() HarmonicNetwork

NewHarmonicNetwork create a harmonic network for a harmonic genome

func (*HarmonicGenome) Write

func (g *HarmonicGenome) Write(name string)

type HarmonicNetwork

type HarmonicNetwork []Harmonic

HarmonicNetwork is a network of harmonic nodes

func (HarmonicNetwork) Step

func (h HarmonicNetwork) Step(states [][]float64) (notes []uint8)

Step steps the state of the harmonic network

type Message

type Message struct {
	Delay uint8
	Value fixed.Fixed
}

Message is a message sent from one harmonic node to another harmonic node

Jump to

Keyboard shortcuts

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