/// <summary> /// Called before every test. /// </summary> protected override void InitializeDefault() { var configuration = this.GetDefaultAlgorithmTunerConfiguration(); var targetAlgorithmFactory = new ExtractIntegerValueCreator(); this.ParameterTree = GenomeAssistedSorterBaseTest <TSearchPoint> .CreateParameterTree(); this.ActorSystem = ActorSystem.Create(TestBase.ActorSystemName, configuration.AkkaConfiguration); var resultStorageActor = this.ActorSystem.ActorOf( Props.Create(() => new ResultStorageActor <TestInstance, IntegerResult>()), AkkaNames.ResultStorageActor); this.GenerationEvaluationActor = this.ActorSystem.ActorOf( Props.Create( () => new GenerationEvaluationActor <ExtractIntegerValue, TestInstance, IntegerResult>( targetAlgorithmFactory, this._runEvaluator, configuration, resultStorageActor, this.ParameterTree, null)), AkkaNames.GenerationEvaluationActor); this.GenomeBuilder = this.CreateGenomeBuilderWithForbiddenValue(configuration); this.InitializeSorter(this.GenerationEvaluationActor); // Ensure sorting data exists. this.GenomeAssistedSorter.UpdateInstances(new[] { new TestInstance("test") }); }
/// <summary> /// Builds up a <see cref="TournamentSelector{TTargetAlgorithm,TInstance,TResult}"/>. /// This is necessary to have <see cref="EvaluationActor{TTargetAlgorithm,TInstance,TResult}"/>s. /// </summary> /// <param name="actorSystem">The <see cref="ActorSystem"/> to add the actors to.</param> /// <param name="configuration">The <see cref="AlgorithmTunerConfiguration"/> for the actors.</param> private void BuildUpRelatedActors(ActorSystem actorSystem, AlgorithmTunerConfiguration configuration) { var resultStorageActor = actorSystem.ActorOf( Props.Create(() => new ResultStorageActor <TestInstance, IntegerResult>()), AkkaNames.ResultStorageActor); var targetAlgorithmFactory = new ExtractIntegerValueCreator(); var tournamentSelector = actorSystem.ActorOf( Props.Create( () => new TournamentSelector <ExtractIntegerValue, TestInstance, IntegerResult>( targetAlgorithmFactory, this._runEvaluator, configuration, resultStorageActor, this.ParameterTree)), AkkaNames.TournamentSelector); }