public async Task <AnalysisResult> AnalyzeAsync(AnalysisContext context) { _logger.Info("Starting analysis phase one."); _logger.Info($"Context: {context.ToLogString()}"); // Find appropriate launches number iteratively (part 1 of phase 1). AnalysisPhaseOnePartOneResult partOneResult = await PerformPartOneAsync(context); AnalysisContext updatedContext = context.CreateWith( args: context.Args.CreateWith(partOneResult.CalculatedSampleSize) ); // Check H0 hypothesis on calculated launches number (part 2 of phase 1). AnalysisPhaseOnePartTwoResult partTwoResult = await PerfromPartTwoAsync(updatedContext, partOneResult); if (partTwoResult.IsH0HypothesisProved) { return(AnalysisResult.CreateSuccess( "H0 hypothesis for the algorithm was proved.", updatedContext )); } return(AnalysisResult.CreateFailure( "H0 hypothesis for the algorithm was not proved.", updatedContext )); }
public AnalysisPhaseOnePartTwoResult( AnalysisPhaseOnePartOneResult partOneResult, bool isH0HypothesisProved) { PartOneResult = partOneResult.ThrowIfNull(nameof(partOneResult)); IsH0HypothesisProved = isH0HypothesisProved; }
private static ExcelContextForPhaseOne <IAnalysisPhaseOnePartTwo> CreateExcelContextPartTwo( AnalysisContext context, AnalysisPhaseOnePartOneResult partOneResult) { string sheetName = ExcelHelper.CreateSheetName(PhaseNumber, partOneResult.TotalIterationNumber); Func <ParametersPack, IAnalysisPhaseOnePartTwo> analysisFactory = args => AnalysisHelper.CreateAnalysisPhaseOnePartTwo(context.PhaseOnePartTwo, args); return(ExcelContextForPhaseOne <IAnalysisPhaseOnePartTwo> .CreateFor( args : context.Args, launchContext : context.LaunchContext, outputExcelFile : context.OutputExcelFile, sheetName : sheetName, analysisFactory : analysisFactory )); }
private async Task <AnalysisPhaseOnePartTwoResult> PerfromPartTwoAsync( AnalysisContext context, AnalysisPhaseOnePartOneResult partOneResult) { _logger.Info("Starting analysis phase one part two."); var excelContext = CreateExcelContextPartTwo(context, partOneResult); _logger.Info($"Final parameters pack: {excelContext.Args.ToLogString()}"); // Perform the final iteration to get actual data using calculated sample size. using FileObject fileObject = await AnalysisRunner.PerformOneIterationOfPhaseOneAsync( excelContext.Args, excelContext.LaunchContext, _fileWorker ); bool isH0HypothesisProved = _excelWrapperPartTwo.ApplyAnalysisAndSaveData( fileObject.Data.GetData(item => item.operationNumber), excelContext ); _logger.Info("Finished analysis phase one part two."); _logger.Info( $"H0 hypothesis for the algorithm was proved: '{isH0HypothesisProved.ToString()}'." ); return(new AnalysisPhaseOnePartTwoResult(partOneResult, isH0HypothesisProved)); }