private static void FillAdditionalDataColumn(IExcelSheet sheet, ParametersPack args, ref int currentColumnIndex) { var additionalDataColumnIndex = currentColumnIndex++.AsEnum <ExcelColumnIndex>(); sheet[additionalDataColumnIndex, 1].SetValue(ExcelStringsPhaseTwo.AdditionalDataColumnName); sheet[additionalDataColumnIndex, 2].SetValue(args.LaunchesNumber); sheet[additionalDataColumnIndex, 3].SetValue(args.Step); sheet[additionalDataColumnIndex, 4].SetValue(double.Parse(ExcelStringsPhaseTwo.ConfidenceFactorValue)); string significanceLevelFormula = string.Format( ExcelStringsPhaseTwo.SignificanceLevelFormula, sheet[additionalDataColumnIndex, 4].Address ); sheet[additionalDataColumnIndex, 5].SetFormula(significanceLevelFormula); // Provide help information to see which columns contain data. string operationsRange = $"{GetFirstDataRowIndex().ToString()}:" + $"{GetLastDataRowIndex(args).ToString()}"; sheet[additionalDataColumnIndex, 6].SetValue(operationsRange); string normalizedRange = $"{GetFirstNormalizedDataRowIndex(args).ToString()}:" + $"{GetLastNormalizedDataRowIndex(args).ToString()}"; sheet[additionalDataColumnIndex, 7].SetValue(normalizedRange); sheet.AutoSizeColumn(additionalDataColumnIndex); }
public BetaDistributionAnalysisPhaseOnePartTwo( IFrequencyHistogramBuilder histogramBuilder, ParametersPack args) { _histogramBuilder = histogramBuilder.ThrowIfNull(nameof(histogramBuilder)); _args = args.ThrowIfNull(nameof(args)); }
private static void FillLaunchesHeader(IExcelSheet sheet, ParametersPack args, ref int currentColumnIndex) { for (int launchesNumber = args.StartValue; launchesNumber <= args.EndValue; launchesNumber += args.Step) { var launchesColumnIndex = currentColumnIndex++.AsEnum <ExcelColumnIndex>(); sheet[launchesColumnIndex, 1].SetValue(launchesNumber); sheet.AutoSizeColumn(launchesColumnIndex); } }
private static int FillSheetHeader(IExcelSheet sheet, ParametersPack args) { // Columnm index starts with zero because we use doule-conversion trick // (int -> enum -> int). int currentColumnIndex = 0; FillLaunchesHeader(sheet, args, ref currentColumnIndex); FillAdditionalDataColumn(sheet, args, ref currentColumnIndex); FillBasicColumns(sheet, args, ref currentColumnIndex); return(currentColumnIndex); }
public AnalysisIterationContextPhaseTwo( ParametersPack args, AnalysisLaunchContext launchContext, LocalFileWorker fileWorker, string analysisInputArgs, FileInfo finalOutputFile) { Args = args.ThrowIfNull(nameof(args)); LaunchContext = launchContext.ThrowIfNull(nameof(launchContext)); FileWorker = fileWorker.ThrowIfNull(nameof(fileWorker)); AnalysisInputArgs = analysisInputArgs.ThrowIfNullOrWhiteSpace(nameof(analysisInputArgs)); FinalOutputFile = finalOutputFile.ThrowIfNull(nameof(finalOutputFile)); }
private ExcelContextForPhaseOne( ParametersPack args, AnalysisLaunchContext launchContext, FileInfo outputExcelFile, string sheetName, Func <ParametersPack, TAnalysisPhaseOne> analysisFactory) { Args = args.ThrowIfNull(nameof(args)); LaunchContext = launchContext.ThrowIfNull(nameof(launchContext)); OutputExcelFile = outputExcelFile.ThrowIfNull(nameof(outputExcelFile)); SheetName = sheetName.ThrowIfNullOrEmpty(nameof(sheetName)); _partOneFactory = analysisFactory.ThrowIfNull(nameof(analysisFactory)); }
private static void FillBasicColumns(IExcelSheet sheet, ParametersPack args, ref int currentColumnIndex) { int rowIndex = 1; var sampleSizeColumnIndex = currentColumnIndex++.AsEnum <ExcelColumnIndex>(); sheet[sampleSizeColumnIndex, rowIndex].SetValue(ExcelStringsPhaseTwo.SampleSizeColumnName); var theoreticalMinColumnIndex = currentColumnIndex++.AsEnum <ExcelColumnIndex>(); sheet[theoreticalMinColumnIndex, rowIndex].SetValue(ExcelStringsPhaseTwo.TheoreticalMinColumnName); var theoreticalAverageColumnIndex = currentColumnIndex++.AsEnum <ExcelColumnIndex>(); sheet[theoreticalAverageColumnIndex, rowIndex].SetValue(ExcelStringsPhaseTwo.TheoreticalAverageColumnName); var theoreticalMaxColumnIndex = currentColumnIndex++.AsEnum <ExcelColumnIndex>(); sheet[theoreticalMaxColumnIndex, rowIndex].SetValue(ExcelStringsPhaseTwo.TheoreticalMaxColumnName); ++rowIndex; for (int launchesNumber = args.StartValue; launchesNumber <= args.ExtrapolationSegmentValue; launchesNumber += args.Step) { sheet[sampleSizeColumnIndex, rowIndex].SetValue(launchesNumber); string minFormula = ManualFormulaProvider.Min( sheet, sampleSizeColumnIndex, rowIndex, args.AlgorithmType ); sheet[theoreticalMinColumnIndex, rowIndex].SetFormula(minFormula); string averageFormula = ManualFormulaProvider.Average( sheet, sampleSizeColumnIndex, rowIndex, args.AlgorithmType ); sheet[theoreticalAverageColumnIndex, rowIndex].SetFormula(averageFormula); string maxFormula = ManualFormulaProvider.Max( sheet, sampleSizeColumnIndex, rowIndex, args.AlgorithmType ); sheet[theoreticalMaxColumnIndex, rowIndex].SetFormula(maxFormula); ++rowIndex; } sheet.AutoSizeColumn(sampleSizeColumnIndex); sheet.AutoSizeColumn(theoreticalMinColumnIndex); sheet.AutoSizeColumn(theoreticalAverageColumnIndex); sheet.AutoSizeColumn(theoreticalMaxColumnIndex); }
public BetaDistributionAnalysisPhaseTwo(ParametersPack args, IRegression regression) { _args = args.ThrowIfNull(nameof(args)); _regression = regression.ThrowIfNull(nameof(regression)); _iterationsNumber = args.GetIterationsNumber(phaseNumber: 2); _lastSegmentValueRowIndex = _iterationsNumber.SkipHeader(); _additionalDataColumn = ExcelWrapperForPhaseTwo.GetAdditionalDataColumn(_iterationsNumber); _sampleSizeColumnIndex = ExcelWrapperForPhaseTwo.GetSampleSizeColumn(_iterationsNumber); _theoreticalMinColumn = ExcelWrapperForPhaseTwo.GetTheoreticalMinColumn(_iterationsNumber); _theoreticalMaxColumn = ExcelWrapperForPhaseTwo.GetTheoreticalMaxColumn(_iterationsNumber); _alphaColumn = GetAlphaColumn(); _betaColumn = GetBetaColumn(); }
private static void FillAdditionalParametersColumns(IExcelSheet sheet, ParametersPack args) { // Descriptive cells. sheet[ExcelColumnIndex.I, 1].SetValue(ExcelStringsPhaseOnePartTwo.AdditionalParametersColumnName); sheet[ExcelColumnIndex.I, 2].SetValue(ExcelStringsPhaseOnePartTwo.InputDataSize); sheet[ExcelColumnIndex.I, 3].SetValue(ExcelStringsPhaseOnePartTwo.MinFunc); sheet[ExcelColumnIndex.I, 4].SetValue(ExcelStringsPhaseOnePartTwo.AverageFunc); sheet[ExcelColumnIndex.I, 5].SetValue(ExcelStringsPhaseOnePartTwo.MaxFunc); sheet[ExcelColumnIndex.I, 6].SetValue(ExcelStringsPhaseOnePartTwo.ExperimentsNumber); sheet[ExcelColumnIndex.I, 7].SetValue(ExcelStringsPhaseOnePartTwo.ConfidenceFactor); sheet[ExcelColumnIndex.I, 8].SetValue(ExcelStringsPhaseOnePartTwo.SignificanceLevel); sheet[ExcelColumnIndex.I, 9].SetValue(ExcelStringsPhaseOnePartTwo.Epsilon); sheet.AutoSizeColumn(ExcelColumnIndex.I); // Value cells. sheet[ExcelColumnIndex.J, 1].SetValue(ExcelStringsPhaseOnePartTwo.AdditionalParametersValuesColumnName); sheet[ExcelColumnIndex.J, 2].SetValue(args.StartValue); string minFormula = ManualFormulaProvider.Min( sheet, ExcelColumnIndex.J, 2, args.AlgorithmType ); sheet[ExcelColumnIndex.J, 3].SetFormula(minFormula); string averageFormula = ManualFormulaProvider.Average( sheet, ExcelColumnIndex.J, 2, args.AlgorithmType ); sheet[ExcelColumnIndex.J, 4].SetFormula(averageFormula); string maxFormula = ManualFormulaProvider.Max( sheet, ExcelColumnIndex.J, 2, args.AlgorithmType ); sheet[ExcelColumnIndex.J, 5].SetFormula(maxFormula); sheet[ExcelColumnIndex.J, 6].SetValue(args.LaunchesNumber); sheet[ExcelColumnIndex.J, 7].SetValue(double.Parse(ExcelStringsPhaseOnePartTwo.ConfidenceFactorValue)); string formulaJ8 = string.Format( ExcelStringsPhaseOnePartTwo.SignificanceLevelFormula, sheet[ExcelColumnIndex.J, 7].Address ); sheet[ExcelColumnIndex.J, 8].SetFormula(formulaJ8); sheet[ExcelColumnIndex.J, 9].SetValue(double.Parse(ExcelStringsPhaseOnePartTwo.EpsilonValue)); sheet.AutoSizeColumn(ExcelColumnIndex.J); }
public static ExcelContextForPhaseOne <TAnalysisPhaseOne> CreateFor( ParametersPack args, AnalysisLaunchContext launchContext, FileInfo outputExcelFile, string sheetName, Func <ParametersPack, TAnalysisPhaseOne> analysisFactory) { return(new ExcelContextForPhaseOne <TAnalysisPhaseOne>( args: args, launchContext: launchContext, outputExcelFile: outputExcelFile, sheetName: sheetName, analysisFactory: analysisFactory )); }
public async static Task PerformFullAnalysisForPhaseTwoAsync(ParametersPack args, AnalysisLaunchContext launchContext, LocalFileWorker fileWorker, Func <FileObject, Task> asyncCallback) { args.ThrowIfNull(nameof(args)); launchContext.ThrowIfNull(nameof(launchContext)); fileWorker.ThrowIfNull(nameof(fileWorker)); asyncCallback.ThrowIfNull(nameof(asyncCallback)); _logger.Info("Preparing to run full analysis for phase two."); // Contract: output files are located in the same directory as our app. IReadOnlyList <FileInfo> finalOutputFiles = args.GetOutputFilenames(phaseNumber: 2); using var fileDeleter = new FileDeleter(finalOutputFiles); IReadOnlyList <string> analysisInputArgsCollection = args.CollectionPackAsInputArgumentsForPhaseTwo(); var limitedScheduler = new LimitedConcurrencyLevelTaskScheduler(launchContext.MaxDegreeOfParallelism); var processingTasks = new List <Task <FileObject> >(analysisInputArgsCollection.Count); // The last is common analysis data file. // We don't need to read/use the last one. for (int index = 0; index < analysisInputArgsCollection.Count; ++index) { var iterationContext = new AnalysisIterationContextPhaseTwo( args: args, launchContext: launchContext, fileWorker: fileWorker, analysisInputArgs: analysisInputArgsCollection[index], finalOutputFile: finalOutputFiles[index] ); Task <FileObject> processingTask = TaskHelper.StartNew( () => PerformOneIterationOfPhaseTwoAsync(iterationContext), limitedScheduler ); processingTasks.Add(processingTask); } await Task.WhenAll( processingTasks.Select(task => AwaitAndProcessAsync(task, asyncCallback)) ); }
public static async Task <FileObject> PerformOneIterationOfPhaseOneAsync(ParametersPack args, AnalysisLaunchContext launchContext, LocalFileWorker fileWorker) { args.ThrowIfNull(nameof(args)); launchContext.ThrowIfNull(nameof(launchContext)); fileWorker.ThrowIfNull(nameof(fileWorker)); _logger.Info("Preparing to run one iteration of phase one."); // Contract: output files are located in the same directory as our app. IReadOnlyList <FileInfo> finalOutputFiles = args.GetOutputFilenames(phaseNumber: 1); CheckExpectedFilenamesNumber(upperBound: 2, finalOutputFiles); var fileDeleter = new FileDeleter(finalOutputFiles); // Contract: the analysis program is located in the same directory as our app. var processLaunchContext = ProcessLaunchContext.Create( file: args.AnalysisProgramName, args: args.PackAsInputArgumentsForPhaseOne(), showWindow: launchContext.ShowAnalysisWindow ); _logger.Info( $"Starting analysis program. Launch context: {processLaunchContext.ToLogString()}" ); using (var analysisRunner = ProgramRunner.RunProgram(processLaunchContext)) { _logger.Info("Waiting to finish one iteration of phase one."); await analysisRunner.WaitAsync(); } // The first data file is iteration result, the last is common analysis data file. // We don't need to read/use the last one. FileInfo finalOutputFile = finalOutputFiles.First(); DataObject <OutputFileData> data = fileWorker.ReadDataFile(finalOutputFile); _logger.Info("Finished one iteration of phase one."); return(new FileObject(fileDeleter, data)); }
public NormalDistributionAnalysisPhaseOnePartOne(ParametersPack args) { _args = args.ThrowIfNull(nameof(args)); }
private static void FillSheetHeader(IExcelSheet sheet, ParametersPack args) { FillOperationColumn(sheet); FillAdditionalParametersColumns(sheet, args); }
public ScottFrequencyHistogramBuilder(ParametersPack args) { _args = args.ThrowIfNull(nameof(args)); }
public static int GetLastDataRowIndex(ParametersPack args) { return(args.LaunchesNumber.SkipHeader()); }
public static int GetNormalizedDataRowIndex(ParametersPack args, int dataRowIndex) { return(args.LaunchesNumber.SkipHeader() + dataRowIndex); }
public static int GetFirstNormalizedDataRowIndex(ParametersPack args) { int firstDataRowIndex = GetFirstDataRowIndex(); return(GetNormalizedDataRowIndex(args, firstDataRowIndex)); }
public static int GetLastNormalizedDataRowIndex(ParametersPack args) { int lastDataRowIndex = GetLastDataRowIndex(args); return(GetNormalizedDataRowIndex(args, lastDataRowIndex)); }