Exemplo n.º 1
0
Arquivo: ocr.go Projeto: NioTeX/neat
func main() {
	flag.Parse()
	//defer profile.Start(profile.CPUProfile).Stop()

	if *Phased {
		fmt.Println("Using phased mutator")
	} else {
		fmt.Println("Using complexifying-only mutator")
	}
	fmt.Println("Each trial will run for a maximum of", *Duration, "minutes.")

	if err := trials.Run(func(i int) (*neat.Experiment, error) {
		eval := &Evaluator{stopTime: time.Now().Add(time.Minute * time.Duration(*Duration))}
		var ctx *starter.Context
		if *Phased {
			ctx = starter.NewContext(eval, func(ctx *starter.Context) {
				ctx.SetMutator(mutator.NewComplete(ctx, ctx, ctx, ctx, ctx, ctx))
			})
		} else {
			ctx = starter.NewContext(eval)
		}
		if exp, err := starter.NewExperiment(ctx, ctx, i); err != nil {
			return nil, err
		} else {
			return exp, nil
		}

	}); err != nil {
		log.Fatal("Could not run OCR: ", err)
	}
}
Exemplo n.º 2
0
Arquivo: run.go Projeto: NioTeX/neat
func main() {
	flag.Parse()
	//defer profile.Start(profile.CPUProfile).Stop()
	if *Novelty {
		fmt.Println("Using Novelty search")
	} else {
		fmt.Println("Using Fitness search")
	}
	if *RealTime {
		fmt.Println("Using Real-Time generator")
	} else {
		fmt.Println("Using Classic generator")
	}
	fmt.Println("Using", *Steps, "time steps per evaluation")
	fmt.Println("Loading maze file:", *MazeFile)
	var err error
	orig := Evaluator{}
	if orig.Environment, err = loadEnv(*MazeFile); err != nil {
		log.Fatalf("Could not load maze file %s: %v", *MazeFile, err)
	}

	if err = trials.Run(func(i int) (*neat.Experiment, error) {

		var ctx *starter.Context
		var eval neat.Evaluator
		var gen neat.Generator
		if *RealTime {
			eval = &RTEvaluator{Evaluator: Evaluator{Environment: orig.clone()}}
			gen = &generator.RealTime{RealTimeSettings: ctx}
		} else {
			eval = &Evaluator{Environment: orig.clone()}
			gen = &generator.Classic{ClassicSettings: ctx}
		}
		if *Novelty {
			ctx = starter.NewContext(eval, func(ctx *starter.Context) {
				ctx.SetGenerator(gen)
				ctx.SetSearcher(&searcher.Novelty{NoveltySettings: ctx, Searcher: &searcher.Concurrent{}})
			})
		} else {
			ctx = starter.NewContext(eval, func(ctx *starter.Context) {
				ctx.SetGenerator(gen)
			})
		}

		if exp, err := starter.NewExperiment(ctx, ctx, i); err != nil {
			return nil, err
		} else {
			//ctx.Settings.ArchivePath = path.Join(ctx.Settings.ArchivePath, "fit")
			//ctx.Settings.ArchiveName = ctx.Settings.ArchiveName + "-fit"
			//ctx.Settings.WebPath = path.Join(ctx.Settings.WebPath, "fit")
			return exp, nil
		}
	}); err != nil {
		log.Fatal("Could not run maze experiment: ", err)
	}
}
Exemplo n.º 3
0
Arquivo: neat.go Projeto: NioTeX/neat
func neatContext() *starter.Context {
	cfg := initSettings()
	cfg.ExperimentName = "NEAT"
	cfg.ArchivePath = "./proof-out/neat"
	cfg.ArchiveName = "neat"
	cfg.WebPath = cfg.ArchivePath

	ctx := starter.NewContext(&NEATEval{})
	ctx.Settings = cfg
	return ctx
}
Exemplo n.º 4
0
func main() {
	flag.Parse()
	//defer profile.Start(profile.CPUProfile).Stop()
	if err := trials.Run(func(i int) (*neat.Experiment, error) {
		ctx := starter.NewContext(&Evaluator{})
		if exp, err := starter.NewExperiment(ctx, ctx, i); err != nil {
			return nil, err
		} else {
			return exp, nil
		}

	}); err != nil {
		log.Fatal("Could not run XOR: ", err)
	}

}
Exemplo n.º 5
0
func phasedContext() *starter.Context {
	cfg := initSettings()
	cfg.ExperimentName = "Phased"
	cfg.ArchivePath = "./proof-out/phased"
	cfg.ArchiveName = "phased"
	cfg.WebPath = cfg.ArchivePath
	cfg.PruningPhaseThreshold = 10
	cfg.MaxMPCAge = 5
	cfg.MaxImprovementAge = 5
	cfg.ImprovementType = neat.Absolute
	cfg.DelNodeProbability = 0.015
	cfg.DelConnProbability = 0.025

	ctx := starter.NewContext(&NEATEval{})
	ctx.Settings = cfg
	return ctx
}
Exemplo n.º 6
0
func hyperneatContext() *starter.Context {
	cfg := initSettings()
	cfg.ExperimentName = "HyperNEAT"
	cfg.ArchivePath = "./proof-out/hyperneat"
	cfg.ArchiveName = "hyperneat"
	cfg.WebPath = cfg.ArchivePath
	cfg.MutateActivationProbability = 0.25
	cfg.OutputActivation = neat.Tanh
	cfg.NumInputs = 4
	cfg.NumOutputs = 2

	ctx := starter.NewContext(&NEATEval{}, func(ctx *starter.Context) {
		ctx.SetMutator(mutator.NewComplete(ctx, ctx, ctx, ctx, ctx, ctx))
		ctx.SetDecoder(&decoder.HyperNEAT{CppnDecoder: decoder.Classic{}, HyperNEATSettings: hyperneatSettings(ctx)})
	})
	ctx.Settings = cfg
	return ctx
}