/// <summary> /// Initializes a new instance of the <see cref="GenerationInformationScorer{TInstance, TResult}"/> class. /// </summary> /// <param name="genomeSorter"> /// A <see cref="IActorRef"/> to a <see cref="GenomeSorter{TInstance, TResult}"/> which can be used to provoke /// evaluations. /// </param> /// <param name="resultStorageActor"> /// A <see cref="IActorRef" /> to a <see cref="ResultStorageActor{TInstance,TResult}" /> /// which knows about all executed target algorithm runs and their results. /// </param> /// <param name="runEvaluator"> /// The <see cref="IMetricRunEvaluator{TResult}"/> to score the target algorithm run results. /// </param> /// <exception cref="NullReferenceException"> /// Thrown if <paramref name="genomeSorter"/>, <paramref name="resultStorageActor"/> or /// <paramref name="runEvaluator"/> are <c>null</c>. /// </exception> public GenerationInformationScorer( IActorRef genomeSorter, IActorRef resultStorageActor, IMetricRunEvaluator <TResult> runEvaluator) { this._genomeSorter = genomeSorter ?? throw new ArgumentNullException(nameof(genomeSorter)); this._resultStorageActor = resultStorageActor ?? throw new ArgumentNullException(nameof(resultStorageActor)); this._runEvaluator = runEvaluator ?? throw new ArgumentNullException(nameof(runEvaluator)); }
/// <summary> /// Track convergence behavior. /// </summary> /// <param name="incumbentGenomeWrapper"> /// The incumbent genome wrapper. /// </param> /// <param name="runEvaluator"> /// A <see cref="IMetricRunEvaluator{TResult}"/> to evaluate the incumbent's results. /// </param> /// <typeparam name="TResult"> /// Type of single instance evaluation result. /// </typeparam> /// <returns> /// The <see cref="double"/> average <see cref="IMetricRunEvaluator{TResult}.GetMetricRepresentation"/> of the /// current incumbent. /// </returns> public static double TrackConvergenceBehavior <TResult>( IncumbentGenomeWrapper <TResult> incumbentGenomeWrapper, IMetricRunEvaluator <TResult> runEvaluator) where TResult : ResultBase <TResult>, new() { if (runEvaluator == null) { throw new ArgumentNullException(nameof(runEvaluator)); } var currentAverage = incumbentGenomeWrapper.IncumbentInstanceResults.Average(r => runEvaluator.GetMetricRepresentation(r)); LoggingHelper.WriteLine( VerbosityLevel.Info, $"Incumbent solved {incumbentGenomeWrapper.IncumbentInstanceResults.Count(i => !i.IsCancelled)}/{incumbentGenomeWrapper.IncumbentInstanceResults.Count} instances."); LoggingHelper.WriteLine( VerbosityLevel.Info, $"Average compare-value score: {currentAverage}."); return(currentAverage); }