コード例 #1
0
ファイル: ocr.go プロジェクト: 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)
	}
}
コード例 #2
0
ファイル: run.go プロジェクト: 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)
	}
}
コード例 #3
0
ファイル: flappy.go プロジェクト: NioTeX/neat
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)
	}

}