diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 332e7b9..6d2ea62 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v2 with: - go-version: 1.17 + go-version: 1.21 - name: Build run: go build -v ./... diff --git a/README.md b/README.md index 33e286c..c2644de 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,8 @@ [![version](https://img.shields.io/github/v/tag/yaricom/goNEAT_NS.svg?sort=semver)](https://github.com/yaricom/goNEAT_NS/releases/latest) [![Build Status](https://travis-ci.org/yaricom/goNEAT_NS.svg?branch=master)](https://travis-ci.org/yaricom/goNEAT_NS) [![GoDoc](https://godoc.org/github.com/yaricom/goNEAT_NS/neatns?status.svg)](https://godoc.org/github.com/yaricom/goNEAT_NS/neatns) [![Go version](https://img.shields.io/badge/go-1.17-blue.svg)](https://github.com/moovweb/gvm) [![license](https://img.shields.io/github/license/yaricom/goNEAT_NS.svg)](https://github.com/yaricom/goNEAT_NS/blob/master/LICENSE) [![yaricom/goNEAT](https://tokei.rs/b1/github/yaricom/goNEAT_NS?category=lines)](https://github.com/yaricom/goNEAT_NS) -| Branch | Tests | Coverage | Linting | Code Security | -|--------|--------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------|----------------------------------------------------------------------------| +| Branch | Tests | Coverage | Linting | Code Security | +|--------|-------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | master | [![CI](https://github.com/yaricom/goNEAT_NS/actions/workflows/ci.yml/badge.svg)](https://github.com/yaricom/goNEAT_NS/actions/workflows/ci.yml) | [![codecov](https://codecov.io/gh/yaricom/goNEAT_NS/branch/master/graph/badge.svg?token=as31613DnV)](https://codecov.io/gh/yaricom/goNEAT_NS) | [![Lint](https://github.com/yaricom/goNEAT_NS/actions/workflows/lint.yml/badge.svg)](https://github.com/yaricom/goNEAT_NS/actions/workflows/lint.yml) | [![CodeQL](https://github.com/yaricom/goNEAT_NS/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/yaricom/goNEAT_NS/actions/workflows/codeql-analysis.yml) | ## Overview @@ -24,7 +24,7 @@ research is to test this hypothesis. ## Minimum Requirements -The source code written and compiled against GO 1.17.x. +The source code written and compiled against GO 1.21.x. ## Installation diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..608b4dc --- /dev/null +++ b/codecov.yml @@ -0,0 +1,4 @@ +# Ignore maze runners +ignore: + - "examples/maze/maze_ns.go" + - "examples/maze/maze_obj.go" \ No newline at end of file diff --git a/examples/maze/common.go b/examples/maze/common.go index adbab8f..a4ad204 100644 --- a/examples/maze/common.go +++ b/examples/maze/common.go @@ -4,10 +4,11 @@ package maze import ( "fmt" - "github.com/yaricom/goNEAT/v3/neat" - "github.com/yaricom/goNEAT/v3/neat/genetics" - "github.com/yaricom/goNEAT/v3/neat/network" - "github.com/yaricom/goNEAT_NS/v3/neatns" + "github.com/pkg/errors" + "github.com/yaricom/goNEAT/v4/neat" + "github.com/yaricom/goNEAT/v4/neat/genetics" + "github.com/yaricom/goNEAT/v4/neat/network" + "github.com/yaricom/goNEAT_NS/v4/neatns" "math" ) @@ -49,7 +50,11 @@ func mazeSimulationEvaluate(env *Environment, org *genetics.Organism, record *Ag nItem := neatns.NewNoveltyItem() // get Organism phenotype's network depth - netDepth, err := org.Phenotype.MaxActivationDepthFast(1) // The max depth of the network to be activated + phenotype, err := org.Phenotype() + if err != nil { + return nil, false, err + } + netDepth, err := phenotype.MaxActivationDepthWithCap(1) // The max depth of the network to be activated if err != nil { neat.DebugLog(fmt.Sprintf( "Failed to estimate maximal depth of the network. Using default depth: %d", netDepth)) @@ -62,7 +67,7 @@ func mazeSimulationEvaluate(env *Environment, org *genetics.Organism, record *Ag // initialize maze simulation's environment specific to the provided organism - this will be a copy // of primordial environment provided - orgEnv, err := mazeSimulationInit(*env, org, netDepth) + orgEnv, err := mazeSimulationInit(*env, phenotype, netDepth) if err != nil { return nil, false, err } @@ -70,7 +75,7 @@ func mazeSimulationEvaluate(env *Environment, org *genetics.Organism, record *Ag // do a specified amount of time steps emulations or while exit not found steps := 0 for i := 0; i < orgEnv.TimeSteps && !orgEnv.ExitFound; i++ { - if err = mazeSimulationStep(orgEnv, org, netDepth); err != nil { + if err = mazeSimulationStep(orgEnv, phenotype, netDepth); err != nil { return nil, false, err } // store agent path points at given sample size @@ -117,9 +122,9 @@ func mazeSimulationEvaluate(env *Environment, org *genetics.Organism, record *Ag // To initialize the maze simulation within provided environment copy and for given organism. // Returns new environment for simulation against given organism -func mazeSimulationInit(env Environment, org *genetics.Organism, netDepth int) (*Environment, error) { +func mazeSimulationInit(env Environment, phenotype *network.Network, netDepth int) (*Environment, error) { // flush the neural net - if _, err := org.Phenotype.Flush(); err != nil { + if _, err := phenotype.Flush(); err != nil { neat.ErrorLog("Failed to flush phenotype") return nil, err } @@ -132,14 +137,14 @@ func mazeSimulationInit(env Environment, org *genetics.Organism, netDepth int) ( // create neural net inputs from environment if inputs, err := env.GetInputs(); err != nil { return nil, err - } else if err = org.Phenotype.LoadSensors(inputs); err != nil { // load into neural net + } else if err = phenotype.LoadSensors(inputs); err != nil { // load into neural net return nil, err } // propagate input through the phenotype net // Use depth to ensure full relaxation - if _, err := org.Phenotype.ForwardSteps(netDepth); err != nil && err != network.ErrNetExceededMaxActivationAttempts { + if _, err := phenotype.ForwardSteps(netDepth); err != nil && !errors.Is(err, network.ErrNetExceededMaxActivationAttempts) { neat.ErrorLog(fmt.Sprintf("Failed to activate network at simulation init: %s", err)) return nil, err } @@ -148,21 +153,21 @@ func mazeSimulationInit(env Environment, org *genetics.Organism, netDepth int) ( } // To execute a time step of the maze simulation evaluation within given Environment for provided Organism -func mazeSimulationStep(env *Environment, org *genetics.Organism, netDepth int) error { +func mazeSimulationStep(env *Environment, phenotype *network.Network, netDepth int) error { // get simulation parameters as inputs to organism's network if inputs, err := env.GetInputs(); err != nil { return err - } else if err = org.Phenotype.LoadSensors(inputs); err != nil { + } else if err = phenotype.LoadSensors(inputs); err != nil { neat.ErrorLog("Failed to load sensors") return err } - if _, err := org.Phenotype.ForwardSteps(netDepth); err != nil && err != network.ErrNetExceededMaxActivationAttempts { + if _, err := phenotype.ForwardSteps(netDepth); err != nil && !errors.Is(err, network.ErrNetExceededMaxActivationAttempts) { neat.ErrorLog(fmt.Sprintf("Failed to activate network at simulation init: %s", err)) return err } // use the net's outputs to change heading and velocity of maze agent - if err := env.ApplyOutputs(org.Phenotype.Outputs[0].Activation, org.Phenotype.Outputs[1].Activation); err != nil { + if err := env.ApplyOutputs(phenotype.Outputs[0].Activation, phenotype.Outputs[1].Activation); err != nil { neat.ErrorLog("Failed to apply outputs") return err } diff --git a/examples/maze/common_test.go b/examples/maze/common_test.go index d1c9fb8..d5d2fa1 100644 --- a/examples/maze/common_test.go +++ b/examples/maze/common_test.go @@ -2,7 +2,7 @@ package maze import ( "github.com/stretchr/testify/assert" - "github.com/yaricom/goNEAT/v3/neat" + "github.com/yaricom/goNEAT/v4/neat" "testing" ) diff --git a/examples/maze/maze_ns.go b/examples/maze/maze_ns.go index 7b3dd66..210ec73 100644 --- a/examples/maze/maze_ns.go +++ b/examples/maze/maze_ns.go @@ -3,11 +3,12 @@ package maze import ( "context" "fmt" - "github.com/yaricom/goNEAT/v3/experiment" - "github.com/yaricom/goNEAT/v3/experiment/utils" - "github.com/yaricom/goNEAT/v3/neat" - "github.com/yaricom/goNEAT/v3/neat/genetics" - "github.com/yaricom/goNEAT_NS/v3/neatns" + "github.com/pkg/errors" + "github.com/yaricom/goNEAT/v4/experiment" + "github.com/yaricom/goNEAT/v4/experiment/utils" + "github.com/yaricom/goNEAT/v4/neat" + "github.com/yaricom/goNEAT/v4/neat/genetics" + "github.com/yaricom/goNEAT_NS/v4/neatns" "math" "os" ) @@ -48,7 +49,7 @@ type noveltySearchEvaluator struct { compatAdjustFreq int } -func (e noveltySearchEvaluator) TrialRunStarted(trial *experiment.Trial) { +func (e *noveltySearchEvaluator) TrialRunStarted(trial *experiment.Trial) { opts := neatns.DefaultNoveltyArchiveOptions() opts.KNNNoveltyScore = 10 trialSim = mazeSimResults{ @@ -58,17 +59,17 @@ func (e noveltySearchEvaluator) TrialRunStarted(trial *experiment.Trial) { } } -func (e noveltySearchEvaluator) TrialRunFinished(_ *experiment.Trial) { +func (e *noveltySearchEvaluator) TrialRunFinished(_ *experiment.Trial) { // the last epoch executed e.storeRecorded() } -func (e noveltySearchEvaluator) EpochEvaluated(_ *experiment.Trial, _ *experiment.Generation) { +func (e *noveltySearchEvaluator) EpochEvaluated(_ *experiment.Trial, _ *experiment.Generation) { // just stub } // GenerationEvaluate this method evaluates one epoch for given population and prints results into output directory if any. -func (e noveltySearchEvaluator) GenerationEvaluate(ctx context.Context, pop *genetics.Population, epoch *experiment.Generation) error { +func (e *noveltySearchEvaluator) GenerationEvaluate(ctx context.Context, pop *genetics.Population, epoch *experiment.Generation) error { options, ok := neat.FromContext(ctx) if !ok { return neat.ErrNEATOptionsNotFound @@ -110,9 +111,7 @@ func (e noveltySearchEvaluator) GenerationEvaluate(ctx context.Context, pop *gen if epoch.Solved { // print winner organism org := epoch.Champion - if depth, err := org.Phenotype.MaxActivationDepthFast(0); err == nil { - neat.InfoLog(fmt.Sprintf("Activation depth of the winner: %d\n", depth)) - } + utils.PrintActivationDepth(org, true) genomeFile := "mazens_winner" // Prints the winner organism's Genome to the file! @@ -189,7 +188,7 @@ func (e *noveltySearchEvaluator) orgEvaluate(org *genetics.Organism, pop *geneti // evaluate individual organism and get novelty point nItem, solved, err := mazeSimulationEvaluate(e.mazeEnv, org, &record, nil) if err != nil { - if err == ErrOutputIsNaN { + if errors.Is(err, ErrOutputIsNaN) { // corrupted genome, but OK to continue evolutionary process return false, nil } diff --git a/examples/maze/maze_obj.go b/examples/maze/maze_obj.go index 03b0d1e..4fd0b68 100644 --- a/examples/maze/maze_obj.go +++ b/examples/maze/maze_obj.go @@ -3,11 +3,12 @@ package maze import ( "context" "fmt" - "github.com/yaricom/goNEAT/v3/experiment" - "github.com/yaricom/goNEAT/v3/experiment/utils" - "github.com/yaricom/goNEAT/v3/neat" - "github.com/yaricom/goNEAT/v3/neat/genetics" - "github.com/yaricom/goNEAT_NS/v3/neatns" + "github.com/pkg/errors" + "github.com/yaricom/goNEAT/v4/experiment" + "github.com/yaricom/goNEAT/v4/experiment/utils" + "github.com/yaricom/goNEAT/v4/neat" + "github.com/yaricom/goNEAT/v4/neat/genetics" + "github.com/yaricom/goNEAT_NS/v4/neatns" "os" ) @@ -38,7 +39,7 @@ type objectiveEvaluator struct { compatAdjustFreq int } -func (e objectiveEvaluator) TrialRunStarted(trial *experiment.Trial) { +func (e *objectiveEvaluator) TrialRunStarted(trial *experiment.Trial) { trialSim = mazeSimResults{ trialID: trial.Id, records: new(RecordStore), @@ -46,17 +47,17 @@ func (e objectiveEvaluator) TrialRunStarted(trial *experiment.Trial) { } } -func (e objectiveEvaluator) TrialRunFinished(_ *experiment.Trial) { +func (e *objectiveEvaluator) TrialRunFinished(_ *experiment.Trial) { // the last epoch executed e.storeRecorded() } -func (e objectiveEvaluator) EpochEvaluated(_ *experiment.Trial, _ *experiment.Generation) { +func (e *objectiveEvaluator) EpochEvaluated(_ *experiment.Trial, _ *experiment.Generation) { // just stub } // GenerationEvaluate evaluates one epoch for given population and prints results into output directory if any. -func (e objectiveEvaluator) GenerationEvaluate(ctx context.Context, pop *genetics.Population, epoch *experiment.Generation) error { +func (e *objectiveEvaluator) GenerationEvaluate(ctx context.Context, pop *genetics.Population, epoch *experiment.Generation) error { options, ok := neat.FromContext(ctx) if !ok { return neat.ErrNEATOptionsNotFound @@ -90,9 +91,7 @@ func (e objectiveEvaluator) GenerationEvaluate(ctx context.Context, pop *genetic if epoch.Solved { // print winner organism org := epoch.Champion - if depth, err := org.Phenotype.MaxActivationDepthFast(0); err == nil { - neat.InfoLog(fmt.Sprintf("Activation depth of the winner: %d\n", depth)) - } + utils.PrintActivationDepth(org, true) genomeFile := "maze_obj_winner" // Prints the winner organism to file! @@ -154,7 +153,7 @@ func (e *objectiveEvaluator) orgEvaluate(org *genetics.Organism, _ *genetics.Pop // evaluate individual organism and get novelty point holding simulation results nItem, solved, err := mazeSimulationEvaluate(e.mazeEnv, org, &record, nil) if err != nil { - if err == ErrOutputIsNaN { + if errors.Is(err, ErrOutputIsNaN) { // corrupted genome, but OK to continue evolutionary process return false, nil } diff --git a/executor.go b/executor.go index cc1e725..f88dd24 100644 --- a/executor.go +++ b/executor.go @@ -4,10 +4,10 @@ import ( "context" "flag" "fmt" - "github.com/yaricom/goNEAT/v3/experiment" - "github.com/yaricom/goNEAT/v3/neat" - "github.com/yaricom/goNEAT/v3/neat/genetics" - "github.com/yaricom/goNEAT_NS/v3/examples/maze" + "github.com/yaricom/goNEAT/v4/experiment" + "github.com/yaricom/goNEAT/v4/neat" + "github.com/yaricom/goNEAT/v4/neat/genetics" + "github.com/yaricom/goNEAT_NS/v4/examples/maze" "log" "math/rand" "os" diff --git a/go.mod b/go.mod index 4691d20..231af11 100644 --- a/go.mod +++ b/go.mod @@ -1,22 +1,22 @@ -module github.com/yaricom/goNEAT_NS/v3 +module github.com/yaricom/goNEAT_NS/v4 -go 1.17 +go 1.21 require ( github.com/fogleman/gg v1.3.0 - github.com/stretchr/testify v1.7.1 - github.com/yaricom/goNEAT/v3 v3.0.1 + github.com/pkg/errors v0.9.1 + github.com/stretchr/testify v1.8.4 + github.com/yaricom/goNEAT/v4 v4.0.1 ) require ( - github.com/davecgh/go-spew v1.1.0 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect - github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/sbinet/npyio v0.6.0 // indirect - github.com/spf13/cast v1.5.0 // indirect - golang.org/x/exp v0.0.0-20191002040644-a1355ae1e2c3 // indirect - golang.org/x/image v0.0.0-20220302094943-723b81ca9867 // indirect - gonum.org/v1/gonum v0.11.0 // indirect + github.com/sbinet/npyio v0.7.0 // indirect + github.com/spf13/cast v1.5.1 // indirect + golang.org/x/exp v0.0.0-20230321023759-10a507213a29 // indirect + golang.org/x/image v0.6.0 // indirect + gonum.org/v1/gonum v0.13.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 669307c..c2d62e8 100644 --- a/go.sum +++ b/go.sum @@ -1,96 +1,71 @@ -dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -gioui.org v0.0.0-20210308172011-57750fc8a0a6/go.mod h1:RSH6KIUZ0p2xy5zHDxgAM4zumjgTw83q2ge/PI+yyw8= -github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw= -github.com/boombuler/barcode v1.0.0/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= -github.com/campoy/embedmd v1.0.0/go.mod h1:oxyr9RCiSXg0M3VJ3ks0UGfp98BpSSGr0kpiX3MzVl8= -github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/fogleman/gg v1.3.0 h1:/7zJX8F6AaYQc57WQCyN9cAIz+4bCJGO9B+dyW29am8= github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= -github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= -github.com/go-fonts/dejavu v0.1.0/go.mod h1:4Wt4I4OU2Nq9asgDCteaAaWZOV24E+0/Pwo0gppep4g= -github.com/go-fonts/latin-modern v0.2.0/go.mod h1:rQVLdDMK+mK1xscDwsqM5J8U2jrRa3T0ecnM9pNujks= -github.com/go-fonts/liberation v0.1.1/go.mod h1:K6qoJYypsmfVjWg8KOVDQhLc8UDgIK2HYqyqAO9z7GY= -github.com/go-fonts/stix v0.1.0/go.mod h1:w/c1f0ldAUlJmLBvlbkvVXLAD+tAMqobIIQpmnUIzUY= -github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= -github.com/go-latex/latex v0.0.0-20210118124228-b3d85cf34e07/go.mod h1:CO1AlKB2CSIqUrmQPqA0gdRIlnLEY0gK5JGjh37zN5U= +github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY= +github.com/frankban/quicktest v1.14.4/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= -github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o= -github.com/jung-kurt/gofpdf v1.0.0/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= -github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= -github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/phpdave11/gofpdf v1.4.2/go.mod h1:zpO6xFn9yxo3YLyMvW8HcKWVdbNqgIfOOp2dXMnm1mY= -github.com/phpdave11/gofpdi v1.0.12/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k= -github.com/ruudk/golang-pdf417 v0.0.0-20181029194003-1af4ab5afa58/go.mod h1:6lfFZQK844Gfx8o5WFuvpxWRwnSoipWe/p622j1v06w= -github.com/sbinet/npyio v0.6.0 h1:IyqqQIzRjDym9xnIXsToCKei/qCzxDP+Y74KoMlMgXo= -github.com/sbinet/npyio v0.6.0/go.mod h1:/q3BNr6dJOy+t6h7RZchTJ0nwRJO52mivaem29WE1j8= -github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w= -github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU= -github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/yaricom/goNEAT/v3 v3.0.1 h1:C5gYl2ErevPFDl5gcbav3JhFRADKCkiWEa4jUM/y9hA= -github.com/yaricom/goNEAT/v3 v3.0.1/go.mod h1:gkZxHLDW3dRwacNk0ITgt9okkCSnFeTbosWfLFnYucg= +github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/sbinet/npyio v0.7.0 h1:KH8n5VrI1O2FeNAHwa0WmC1f9nGNtXNzQHBkyoU8tuE= +github.com/sbinet/npyio v0.7.0/go.mod h1:4jmxspVr/RFRPc6zSGR/8FP6nb9m7EpypUXrU/cf/nU= +github.com/spf13/cast v1.5.1 h1:R+kOtfhWQE6TVQzY+4D7wJLBgkdVasCEFxSUBYBYIlA= +github.com/spf13/cast v1.5.1/go.mod h1:b9PdjNptOpzXr7Rq1q9gJML/2cdGQAo69NKzQ10KN48= +github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/yaricom/goNEAT/v4 v4.0.1 h1:1B1icrmovHsmntWK4gur6QX09vmML2Fl3PbH38Woa9g= +github.com/yaricom/goNEAT/v4 v4.0.1/go.mod h1:SKqd8CRgc3Bnj/ViM2mHcPn4ImKEmoGsun4ZJKdZdI4= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190125153040-c74c464bbbf2/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20191002040644-a1355ae1e2c3 h1:n9HxLrNxWWtEb1cA950nuEEj3QnKbtsCJ6KjcgisNUs= -golang.org/x/exp v0.0.0-20191002040644-a1355ae1e2c3/go.mod h1:NOZ3BPKG0ec/BKJQgnvsSFpcKLM5xXVWnvZS97DWHgE= -golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= -golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= -golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/image v0.0.0-20190910094157-69e4b8554b2a/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/image v0.0.0-20200119044424-58c23975cae1/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/image v0.0.0-20200430140353-33d19683fad8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/image v0.0.0-20200618115811-c13761719519/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/image v0.0.0-20201208152932-35266b937fa6/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/image v0.0.0-20210216034530-4410531fe030/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/image v0.0.0-20220302094943-723b81ca9867 h1:TcHcE0vrmgzNH1v3ppjcMGbhG5+9fMuvOmUYwNEF4q4= -golang.org/x/image v0.0.0-20220302094943-723b81ca9867/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM= -golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= -golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/exp v0.0.0-20230321023759-10a507213a29 h1:ooxPy7fPvB4kwsA2h+iBNHkAbp/4JxTSwCmvdjEYmug= +golang.org/x/exp v0.0.0-20230321023759-10a507213a29/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= +golang.org/x/image v0.6.0 h1:bR8b5okrPI3g/gyZakLZHeWxAR8Dn5CyxXv1hLH5g/4= +golang.org/x/image v0.6.0/go.mod h1:MXLdDR43H7cDJq5GEGXEVeeNhPgi+YYEQ2pC1byI1x0= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210304124612-50617c2ba197/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190206041539-40960b6deb8e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190927191325-030b2cf1153e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= -gonum.org/v1/gonum v0.0.0-20180816165407-929014505bf4/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo= -gonum.org/v1/gonum v0.8.2/go.mod h1:oe/vMfY3deqTw+1EZJhuvEW2iwGF1bW9wwu7XCu0+v0= -gonum.org/v1/gonum v0.9.3/go.mod h1:TZumC3NeyVQskjXqmyWt4S3bINhy7B4eYwW69EbyX+0= -gonum.org/v1/gonum v0.11.0 h1:f1IJhK4Km5tBJmaiJXtk/PkL4cdVX6J+tGiM187uT5E= -gonum.org/v1/gonum v0.11.0/go.mod h1:fSG4YDCxxUZQJ7rKsQrj0gMOg00Il0Z96/qMA4bVQhA= -gonum.org/v1/netlib v0.0.0-20190313105609-8cb42192e0e0/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw= -gonum.org/v1/plot v0.0.0-20190515093506-e2840ee46a6b/go.mod h1:Wt8AAjI+ypCyYX3nZBvf6cAIx93T+c/OS2HFAYskSZc= -gonum.org/v1/plot v0.9.0/go.mod h1:3Pcqqmp6RHvJI72kgb8fThyUnav364FOsdDo2aGW5lY= +gonum.org/v1/gonum v0.13.0 h1:a0T3bh+7fhRyqeNbiC3qVHYmkiQgit3wnNan/2c0HMM= +gonum.org/v1/gonum v0.13.0/go.mod h1:/WPYRckkfWrhWefxyYTfrTtQR0KH4iyHNuzxqXAKyAU= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= diff --git a/neatns/novelty_archive.go b/neatns/novelty_archive.go index 1692eb5..09fc6c3 100644 --- a/neatns/novelty_archive.go +++ b/neatns/novelty_archive.go @@ -3,8 +3,8 @@ package neatns import ( "errors" "fmt" - "github.com/yaricom/goNEAT/v3/neat" - "github.com/yaricom/goNEAT/v3/neat/genetics" + "github.com/yaricom/goNEAT/v4/neat" + "github.com/yaricom/goNEAT/v4/neat/genetics" "sort" ) diff --git a/neatns/novelty_archive_test.go b/neatns/novelty_archive_test.go index 0dc4d7c..c250615 100644 --- a/neatns/novelty_archive_test.go +++ b/neatns/novelty_archive_test.go @@ -3,8 +3,9 @@ package neatns import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/yaricom/goNEAT/v3/neat" - "github.com/yaricom/goNEAT/v3/neat/genetics" + "github.com/yaricom/goNEAT/v4/neat" + "github.com/yaricom/goNEAT/v4/neat/genetics" + "github.com/yaricom/goNEAT/v4/neat/math" "math/rand" "strings" "testing" @@ -133,6 +134,7 @@ func createRandomPopulation(in, out, maxHidden int, linkProb float64) (*genetics conf := &neat.Options{ CompatThreshold: 0.5, PopSize: 10, + NodeActivators: []math.NodeActivationType{math.SigmoidSteepenedActivation}, } pop, err := genetics.NewPopulationRandom(in, out, maxHidden, false, linkProb, conf) if err != nil { diff --git a/tools/maze_utils.go b/tools/maze_utils.go index 0bbf4b1..d1b028e 100644 --- a/tools/maze_utils.go +++ b/tools/maze_utils.go @@ -5,7 +5,7 @@ import ( "flag" "fmt" "github.com/fogleman/gg" - "github.com/yaricom/goNEAT_NS/v3/examples/maze" + "github.com/yaricom/goNEAT_NS/v4/examples/maze" "image" "image/color" "io"