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:
This is not an official Google product.
I've decided to update this repo using Go with generics (1.18+). It is still very experimental.
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
To run the NAND gate GEP experiment:
$ go run github.com/gmlewis/gep/v2/experiments/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
}
To run the Symbolic Regression experiment:
$ go run github.com/gmlewis/gep/v2/experiments/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
}
To run unit tests, type:
$ go test github.com/gmlewis/gep/v2/...
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 run github.com/gmlewis/gep/v2/experiments/load_grammars > grammars.xml
Enjoy!
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.