コード例 #1
0
ファイル: locality.go プロジェクト: akiross/gogp
func main() {
	seed := time.Now().UTC().UnixNano()
	rand.Seed(seed)
	fmt.Println("Using seed:", seed)

	// Test expr
	// The initialization function creates a tree with specified max depth
	// And it's a closure over the primitives
	exprInit := func(maxDep int) *node.Node {
		return node.MakeTreeHalfAndHalf(maxDep, expr.Functionals, expr.Terminals)
	}
	exprMutate := node.MakeSubtreeMutation(MAX_D, exprInit)
	fmt.Println("Testing representation: expr")
	exprErrorAvg, exprErrorVar := testRepr(exprInit, exprMutate, expr.Draw)
	fmt.Println("expr error avg:", exprErrorAvg, "var:", exprErrorVar)

	// Test ts
	tsInit := func(maxDep int) *node.Node {
		return node.MakeTreeHalfAndHalf(maxDep, ts.Functionals, ts.Terminals)
	}
	tsMutate := node.MakeSubtreeMutation(MAX_D, tsInit)
	fmt.Println("Testing representation: TS")
	tsErrorAvg, tsErrorVar := testRepr(tsInit, tsMutate, ts.Draw)
	fmt.Println("TS error avg:", tsErrorAvg, "var:", tsErrorVar)

	// Test vhs
	vhsInit := func(maxDep int) *node.Node {
		return node.MakeTreeHalfAndHalf(maxDep, vhs.Functionals, vhs.Terminals)
	}
	vhsMutate := node.MakeSubtreeMutation(MAX_D, vhsInit)
	fmt.Println("Testing representation: VHS")
	vhsErrorAvg, vhsErrorVar := testRepr(vhsInit, vhsMutate, vhs.Draw)
	fmt.Println("VHS error avg:", vhsErrorAvg, "var:", vhsErrorVar)
}
コード例 #2
0
ファイル: search.go プロジェクト: akiross/gogp
func (c *Configuration) RandomSolution() hc.Solution {
	n := node.MakeTreeHalfAndHalf(c.MaxDepth, c.Functionals, c.Terminals)
	tmpImg := imgut.Create(c.ImgTarget.W, c.ImgTarget.H, c.ImgTarget.ColorSpace)
	return &Solution{n, tmpImg, c}
}
コード例 #3
0
ファイル: search.go プロジェクト: akiross/gogp
func (s *Solution) Mutate() {
	subtrMut := node.MakeSubtreeMutation(s.Conf.MaxDepth, func(maxDep int) *node.Node {
		return node.MakeTreeHalfAndHalf(maxDep, s.Conf.Functionals, s.Conf.Terminals)
	})
	subtrMut(s.Node)
}