gep

module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2018 License: Apache-2.0

README

Gene Expression Programming (GEP) in Go

This is an independent implementation of the Gene Expression Programming (GEP) machine learning algorithm created by Dr. Cândida Ferreira. It was written in the Go programming language by Glenn Lewis (gmlewis@google.com).

For more information, please visit http://www.gepsoft.com/

Here is a concise summary of GEP:

The definitive book about GEP is available here:

The lightning talk I gave about GEP at GopherCon 2014 is available here:

This is not an official Google product.

Status

GoDoc Build Status


NAND Function Experiment

To build and run this code, it may help to understand this presentation, specifically about Go workspaces: http://talks.golang.org/2012/tutorial.slide#9

For example, to set up your GOPATH (once only):

$ export GOPATH=$HOME/go
$ mkdir -p $GOPATH/src

To run the NAND gate GEP experiment:

$ go get github.com/gmlewis/gep/experiments/nand
$ $GOPATH/bin/nand
Stopping after generation #0

// gepModel is auto-generated Go source code for the
// nand solution karva expression:
// "Not.And.Or.And.Or.And.d1.d0.d1.d1.d0.d0.d1.d1.d0", score=1000
package gepModel

func gepModel(d []bool) bool {
	y := false

	y = (!(((d[1] || d[1]) || (d[0] && d[0])) && (d[1] && d[0])))

	return y
}

Symbolic Regression Experiment

To run the Symbolic Regression experiment:

$ go get github.com/gmlewis/gep/experiments/symbolic_regression
$ $GOPATH/bin/symbolic_regression
Stopping after generation #86

// gepModel is auto-generated Go source code for the
// (a^4 + a^3 + a^2 + a) solution karva expression:
// "*.d0.d0.d0.d0.d0.d0.*.d0.d0.d0.d0.d0.d0.d0.d0.d0|+|*.*.d0.d0.d0.d0.d0.*.d0.d0.d0.d0.d0.d0.d0.d0.d0|+|d0.d0.d0.*.*.d0.*.*.d0.d0.d0.d0.d0.d0.d0.d0.d0|+|*.*.*.d0.d0.d0.d0.d0.d0.d0.d0.d0.d0.d0.d0.d0.d0", score=11965.591435001414
package gepModel

import (
	"math"
)

func gepModel(d []float64) float64 {
	y := 0.0

	y = (d[0] * d[0])
	y += ((d[0] * d[0]) * d[0])
	y += d[0]
	y += ((d[0] * d[0]) * (d[0] * d[0]))

	return y
}

Unit Tests

To run unit tests, type:

$ go test github.com/gmlewis/gep/...

Grammars

While converting the C++ grammars to Go grammars, it was useful to load in the XML files, parse them, and then dump them out to compare input versus output. This helped to weed out errors.

For example:

$ go get github.com/gmlewis/gep/experiments/load_grammars
$ $GOPATH/bin/load_grammars

Enjoy!


License

Copyright 2014 Google Inc. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Directories

Path Synopsis
experiments
6-multiplexer
6-multiplexer is a simple experiment to run the GEP algorithm using the Boolean logic package.
6-multiplexer is a simple experiment to run the GEP algorithm using the Boolean logic package.
load_grammars
load_grammars loads the XML representation of a GEP grammar for a target language and prints it out again.
load_grammars loads the XML representation of a GEP grammar for a target language and prints it out again.
nand
NAND is a simple experiment to run the GEP algorithm using the Boolean logic package.
NAND is a simple experiment to run the GEP algorithm using the Boolean logic package.
odd-3-parity
odd-3-parity is a simple experiment to run the GEP algorithm using the Boolean logic package.
odd-3-parity is a simple experiment to run the GEP algorithm using the Boolean logic package.
odd-7-parity
odd-7-parity is a simple experiment to run the GEP algorithm using the Boolean logic package.
odd-7-parity is a simple experiment to run the GEP algorithm using the Boolean logic package.
openai-gym/algorithms/Copy-v0
Copy-v0 runs a GEP algorithm on the OpenAI Gym "Copy-v0" Algorithm problem.
Copy-v0 runs a GEP algorithm on the OpenAI Gym "Copy-v0" Algorithm problem.
symbolic_regression
Symbolic_regression is a simple experiment to run the GEP algorithm using the floating-point math package.
Symbolic_regression is a simple experiment to run the GEP algorithm using the floating-point math package.
fitness
bool
Package fitness provides common fitness functions.
Package fitness provides common fitness functions.
float
Package fitness provides common fitness functions.
Package fitness provides common fitness functions.
Package functions provides a map of available functions for the GEP algorithm.
Package functions provides a map of available functions for the GEP algorithm.
bool_nodes
Package boolNodes defines the Boolean function collections available for the GEP algorithm.
Package boolNodes defines the Boolean function collections available for the GEP algorithm.
math_nodes
Package mathNodes defines the floating-point function collection available for the GEP algorithm.
Package mathNodes defines the floating-point function collection available for the GEP algorithm.
Package gene provides the basis for a single gene in GEP.
Package gene provides the basis for a single gene in GEP.
Package genome provides the basis for a single GEP genome.
Package genome provides the basis for a single GEP genome.
gophercon2014
Package grammars parses XML GEP grammar representations for a particular output language.
Package grammars parses XML GEP grammar representations for a particular output language.
Package model provides the complete representation of the model for a given GEP problem.
Package model provides the complete representation of the model for a given GEP problem.

Jump to

Keyboard shortcuts

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