예제 #1
0
        /// <summary>
        /// The <see cref="FetchingResultsFromStorage"/> state is responsible for handling genome result messages.
        /// </summary>
        private void FetchingResultsFromStorage()
        {
            this.Receive <GenomeResults <TInstance, TResult> >(
                genomeResults =>
            {
                if (this._genomesWaitingForResultsFromStorage.Remove(genomeResults.Genome))
                {
                    foreach (var instance in this._currentGenerationEvaluation.Instances)
                    {
                        var genomeInstancePair = new GenomeInstancePair <TInstance>(genomeResults.Genome, instance);
                        if (genomeResults.RunResults.TryGetValue(instance, out var result))
                        {
                            this._evaluationStrategy.GenomeInstanceEvaluationFinished(
                                genomeInstancePair,
                                result);
                        }
                        else
                        {
                            this._evaluationStrategy.RequeueEvaluation(genomeInstancePair);
                        }
                    }
                }

                if (this._evaluationStrategy.IsGenerationFinished)
                {
                    this._generationEvaluationIssuer?.Tell(this._evaluationStrategy.CreateResultMessageForPopulationStrategy());
                    this.BecomeReady();
                    return;
                }

                if (!this._genomesWaitingForResultsFromStorage.Any())
                {
                    this.BecomeWorking();
                }
            });

            // Unreachable member events should always be handled to keep the Akka.NET cluster clean.
            this.Receive <ClusterEvent.UnreachableMember>(
                this.HandleUnreachableMessage);
        }
예제 #2
0
 /// <summary>
 /// Checks for equality.
 /// </summary>
 /// <param name="other">The other.</param>
 /// <returns>True, if equal.</returns>
 protected bool Equals(GenomeInstancePair <TInstance> other)
 {
     return(ImmutableGenome.GenomeComparer.Equals(this.Genome, other?.Genome) && object.Equals(this.Instance, other?.Instance));
 }