private double GetPredictedVelocity(HistoryKind historyKind, NormalizedBurndownHistory normalizedHistory, bool ignoreNonWorkingdays) { int nDays = Project.GetProject(MainProjectID).AverageVelocitySpan; if (cache.predictedVelocityCache != null && cache.predictedVelocityCache[(int)historyKind].ContainsKey(nDays)) { return(cache.predictedVelocityCache[(int)historyKind][nDays]); } double weightedValueSum = 0; double weightedDaysSum = 0; int iDay = nDays; DateTime day = DateTime.Now.Date; if (ignoreNonWorkingdays && !Project.IsWorkingDay(day)) { day = Project.GetPreviousWorkingDay(day); } DateTime previousDay = day.AddDays(-1); if (ignoreNonWorkingdays && !Project.IsWorkingDay(previousDay)) { previousDay = Project.GetPreviousWorkingDay(previousDay); } for (int i = 0; i < nDays; i += 1) { if (previousDay < normalizedHistory.Start) { break; } double velocityOneDay = normalizedHistory.ValueAt(previousDay.Date) - normalizedHistory.ValueAt(day.Date); weightedValueSum += velocityOneDay * iDay; weightedDaysSum += iDay; iDay -= 1; day = previousDay; previousDay = previousDay.AddDays(-1); if (ignoreNonWorkingdays && !Project.IsWorkingDay(previousDay)) { previousDay = Project.GetPreviousWorkingDay(day); } } double prediction = 0; if (weightedDaysSum > 0) { prediction = weightedValueSum / weightedDaysSum; } if (cache.predictedVelocityCache == null) { cache.predictedVelocityCache = new Dictionary <int, double> [3]; for (int i = 0; i < cache.predictedVelocityCache.Length - 1; i += 1) { cache.predictedVelocityCache[i] = new Dictionary <int, double>(); } } cache.predictedVelocityCache[(int)historyKind].Add(nDays, prediction); return(prediction); }
/// <summary> /// データの詳細 /// </summary> /// <param name="historyKind">配列の種類</param> /// <param name="timeScale">分足コード</param> /// <param name="parameter">パラメータ、何個目が何かはテクニカルごとに異なる</param> public HistoryProperty(HistoryKind historyKind, TimeScale timeScale, List <double> parameter) { baseList = new List <double>(); List = new List <List <double> >(); updateCount = -1; HistoryKind = historyKind; TimeScale = timeScale; Parameter = parameter; }
/// <summary> /// Serves as the default hash function. /// </summary> /// <returns>A hash code for the current object.</returns> public override int GetHashCode() { var hashCode = -1955302307; hashCode = (hashCode * -1521134295) + ServiceCleanupDelay.GetHashCode(); hashCode = (hashCode * -1521134295) + HistoryKind.GetHashCode(); hashCode = (hashCode * -1521134295) + HistoryDepth.GetHashCode(); hashCode = (hashCode * -1521134295) + MaxSamples.GetHashCode(); hashCode = (hashCode * -1521134295) + MaxInstances.GetHashCode(); hashCode = (hashCode * -1521134295) + MaxSamplesPerInstance.GetHashCode(); return(hashCode); }
private RawBurndownHistory GetRawHistory(HistoryKind historyKind) { HPMDataHistoryGetHistoryParameters getHistoryParameters = new HPMDataHistoryGetHistoryParameters(); if (historyKind == HistoryKind.Points) { getHistoryParameters.m_FieldID = EHPMStatisticsField.ComplexityPoints; } else if (historyKind == HistoryKind.EstimatedDays) { getHistoryParameters.m_FieldID = EHPMStatisticsField.EstimatedIdealDays; } getHistoryParameters.m_DataIdent0 = EHPMStatisticsScope.Milestone; getHistoryParameters.m_DataIdent1 = (uint)UniqueID.m_ID; int nTries = 0; HPMDataHistory history = null; while (nTries < 25) { // TODO: Consider to move the reponsibility to the client to register a callback instead. It really isn't kosher to do polling here. history = Session.DataHistoryGetHistory(getHistoryParameters); if (history == null) { ++nTries; System.Threading.Thread.Sleep(100); } else { break; } } if (history != null && (cache.rawHistoryCached[(int)historyKind] == null || history.m_Latests.m_Time > cache.rawHistoryCached[(int)historyKind].LastTimeEntry)) { cache.rawHistoryCached[(int)historyKind] = new RawBurndownHistory(history.m_HistoryEntries.Length, history.m_Latests.m_Time); for (uint j = 0; j < history.m_HistoryEntries.Length; j += 1) { HPMDataHistoryEntry historyEntry = history.m_HistoryEntries[j]; ulong time = historyEntry.m_Time; DateTime date = HPMUtilities.FromHPMDateTime(time); if (historyEntry.m_bHasDataRecorded && historyEntry.m_EntryType == EHPMDataHistoryEntryType.Statistics_AbsoluteValue) { HPMVariantData data = Session.DataHistoryGetEntryData(history, j); HPMStatisticsMultiFrequency value = Session.VariantDecode_HPMStatisticsMultiFrequency(data); cache.rawHistoryCached[(int)historyKind].InsertAt(j, date, value.m_FrequencyEntries[1].m_FrequencyFP); } } cache.normalizedHistoryCached[(int)historyKind] = null; } return(cache.rawHistoryCached[(int)historyKind]); }
public void Create(HistoryKind historyKind = HistoryKind.Mock) { _factory = new MockRepository(MockBehavior.Strict); _statusUtil = _factory.Create <IStatusUtil>(); _textView = CreateTextView(); _textBuffer = _textView.TextBuffer; var editorOperationsFactoryService = _factory.Create <IEditorOperationsFactoryService>(); FSharpOption <ITextUndoHistory> textUndoHistory; switch (historyKind) { case HistoryKind.Mock: _mockUndoHistory = _factory.Create <ITextUndoHistory>(); _mockUndoHistory.Setup(x => x.Undo(It.IsAny <int>())).Callback <int>(count => { _undoCount += count; }); _mockUndoHistory.Setup(x => x.Redo(It.IsAny <int>())).Callback <int>(count => { _redoCount += count; }); _mockUndoHistory.Setup(x => x.CreateTransaction(It.IsAny <string>())) .Returns <string>( name => { var transaction = _factory.Create <ITextUndoTransaction>(); transaction.Setup(x => x.Complete()); transaction.Setup(x => x.Dispose()); return(transaction.Object); } ); textUndoHistory = FSharpOption.Create(_mockUndoHistory.Object); break; case HistoryKind.Basic: textUndoHistory = FSharpOption.Create(BasicUndoHistoryRegistry.TextUndoHistoryRegistry.RegisterHistory(_textBuffer)); break; case HistoryKind.None: textUndoHistory = FSharpOption.CreateForReference <ITextUndoHistory>(null); break; default: Assert.True(false); textUndoHistory = null; break; } _undoRedoOperationsRaw = new UndoRedoOperations( VimHost, _statusUtil.Object, textUndoHistory, editorOperationsFactoryService.Object); _undoRedoOperations = _undoRedoOperationsRaw; }
public void Create(HistoryKind historyKind = HistoryKind.Mock) { _factory = new MockRepository(MockBehavior.Strict); _statusUtil = _factory.Create<IStatusUtil>(); _textView = CreateTextView(); _textBuffer = _textView.TextBuffer; var editorOperationsFactoryService = _factory.Create<IEditorOperationsFactoryService>(); FSharpOption<ITextUndoHistory> textUndoHistory; switch (historyKind) { case HistoryKind.Mock: _mockUndoHistory = _factory.Create<ITextUndoHistory>(); _mockUndoHistory.Setup(x => x.Undo(It.IsAny<int>())).Callback<int>(count => { _undoCount += count; }); _mockUndoHistory.Setup(x => x.Redo(It.IsAny<int>())).Callback<int>(count => { _redoCount += count; }); textUndoHistory = FSharpOption.Create(_mockUndoHistory.Object); break; case HistoryKind.Basic: textUndoHistory = FSharpOption.Create(BasicUndoHistoryRegistry.TextUndoHistoryRegistry.RegisterHistory(_textBuffer)); break; case HistoryKind.None: textUndoHistory = FSharpOption.CreateForReference<ITextUndoHistory>(null); break; default: Assert.True(false); textUndoHistory = null; break; } _undoRedoOperationsRaw = new UndoRedoOperations( VimHost, _statusUtil.Object, textUndoHistory, editorOperationsFactoryService.Object); _undoRedoOperations = _undoRedoOperationsRaw; }
private List<ProductBacklogItem>[] RemainingItemsByRisk(List<ProductBacklogItem> remainingItemsPriorityOrder, HistoryKind historyKind, double[] limits) { List<ProductBacklogItem>[] remainingItemsByRisk = new List<ProductBacklogItem>[3]; remainingItemsByRisk[0] = new List<ProductBacklogItem>(); remainingItemsByRisk[1] = new List<ProductBacklogItem>(); remainingItemsByRisk[2] = new List<ProductBacklogItem>(); double aggregated = 0; foreach (ProductBacklogItem item in remainingItemsPriorityOrder) { double delta = 0; if (historyKind == HistoryKind.Points) delta = item.Points; else if (historyKind == HistoryKind.EstimatedDays) delta = item.EstimatedDays; if (aggregated+delta >= limits[1]) remainingItemsByRisk[2].Add(item); else if (aggregated+delta >= limits[0]) remainingItemsByRisk[1].Add(item); else remainingItemsByRisk[0].Add(item); aggregated += delta; } return remainingItemsByRisk; }
private NormalizedBurndownHistory NormalizeHistory(HistoryKind historyKind, RawBurndownHistory rawHistory, double remainingValue) { if (!Started || rawHistory == null) { cache.predictedVelocityCache = null; return null; } if (cache.normalizedHistoryCached[(int)historyKind] != null && cache.normalizedHistoryCached[(int)historyKind].End.Date == DateTime.Now.Date) { if (remainingValue != cache.normalizedHistoryCached[(int)historyKind].Values[cache.normalizedHistoryCached[(int)historyKind].Length - 1]) { cache.normalizedHistoryCached[(int)historyKind].SetValueAt(cache.normalizedHistoryCached[(int)historyKind].Length - 1, remainingValue); cache.predictedVelocityCache = null; } } else { cache.predictedVelocityCache = null; DateTime end = DateTime.Now.Date; cache.normalizedHistoryCached[(int)historyKind] = new NormalizedBurndownHistory(Start, end); DateTime dayToCalculate = Start.Date; int pruneTo = -1; int rawInd = 0; while (rawHistory.Times[rawInd].AddDays(-1).Date < dayToCalculate) rawInd = NextDay(rawInd, rawHistory); for (int iValue = 0; iValue < cache.normalizedHistoryCached[(int)historyKind].Length; iValue += 1) { if (dayToCalculate.Date == end.Date) { cache.normalizedHistoryCached[(int)historyKind].SetValueAt(iValue, remainingValue); break; } if (dayToCalculate.Date < rawHistory.Times[0].AddDays(-1).Date) { pruneTo = iValue; cache.normalizedHistoryCached[(int)historyKind].SetValueAt(iValue, 0); dayToCalculate = dayToCalculate.AddDays(1); } else if (dayToCalculate.Date > rawHistory.Times[rawHistory.Length - 1].AddDays(-1).Date) { cache.normalizedHistoryCached[(int)historyKind].SetValueAt(iValue, rawHistory.Values[rawHistory.Length - 1]); dayToCalculate = dayToCalculate.AddDays(1); } else if (rawInd >= rawHistory.Length) { cache.normalizedHistoryCached[(int)historyKind].SetValueAt(iValue, rawHistory.Values[rawHistory.Length - 1]); dayToCalculate = dayToCalculate.AddDays(1); } else if (dayToCalculate.Date == rawHistory.Times[rawInd].AddDays(-1).Date) { cache.normalizedHistoryCached[(int)historyKind].SetValueAt(iValue, rawHistory.Values[rawInd]); dayToCalculate = dayToCalculate.AddDays(1); rawInd = NextDay(rawInd, rawHistory); } else if (dayToCalculate.Date < rawHistory.Times[rawInd].Date.AddDays(-1)) { // There is a missing value in the middle of the sequence interpolate a value DateTime precedingDate; double precedingValue; if (iValue > 0) { precedingDate = dayToCalculate.AddDays(-1); precedingValue = cache.normalizedHistoryCached[(int)historyKind].Values[iValue - 1]; } else { precedingDate = rawHistory.Times[rawInd-1].Date; precedingValue = rawHistory.Values[rawInd - 1]; } DateTime followingDate = rawHistory.Times[rawInd].Date; double followingValue = rawHistory.Values[rawInd]; if (Project.GetProject(MainProjectID).IsWorkingDay(dayToCalculate)) { TimeSpan span = followingDate - precedingDate; double delta = (followingValue - precedingValue) / span.Days; cache.normalizedHistoryCached[(int)historyKind].SetValueAt(iValue, precedingValue + delta); dayToCalculate = dayToCalculate.AddDays(1); } else { cache.normalizedHistoryCached[(int)historyKind].SetValueAt(iValue, precedingValue); dayToCalculate = dayToCalculate.AddDays(1); } } } cache.normalizedHistoryCached[(int)historyKind].PruneTo(pruneTo); } return cache.normalizedHistoryCached[(int)historyKind]; }
private RawBurndownHistory GetRawHistory(HistoryKind historyKind) { HPMDataHistoryGetHistoryParameters getHistoryParameters = new HPMDataHistoryGetHistoryParameters(); if (historyKind == HistoryKind.Points) getHistoryParameters.m_FieldID = EHPMStatisticsField.ComplexityPoints; else if (historyKind == HistoryKind.EstimatedDays) getHistoryParameters.m_FieldID = EHPMStatisticsField.EstimatedIdealDays; getHistoryParameters.m_DataIdent0 = EHPMStatisticsScope.Milestone; getHistoryParameters.m_DataIdent1 = (uint)UniqueID.m_ID; int nTries = 0; HPMDataHistory history = null; while (nTries < 25) { // TODO: Consider to move the reponsibility to the client to register a callback instead. It really isn't kosher to do polling here. history = Session.DataHistoryGetHistory(getHistoryParameters); if (history == null) { ++nTries; System.Threading.Thread.Sleep(100); } else break; } if (history != null && (cache.rawHistoryCached[(int)historyKind] == null || history.m_Latests.m_Time > cache.rawHistoryCached[(int)historyKind].LastTimeEntry)) { cache.rawHistoryCached[(int)historyKind] = new RawBurndownHistory(history.m_HistoryEntries.Length, history.m_Latests.m_Time); for (uint j = 0; j < history.m_HistoryEntries.Length; j += 1 ) { HPMDataHistoryEntry historyEntry = history.m_HistoryEntries[j]; ulong time = historyEntry.m_Time; DateTime date = HPMUtilities.FromHPMDateTime(time); if (historyEntry.m_bHasDataRecorded && historyEntry.m_EntryType == EHPMDataHistoryEntryType.Statistics_AbsoluteValue) { HPMVariantData data = Session.DataHistoryGetEntryData(history, j); HPMStatisticsMultiFrequency value = Session.VariantDecode_HPMStatisticsMultiFrequency(data); cache.rawHistoryCached[(int)historyKind].InsertAt(j, date, value.m_FrequencyEntries[1].m_FrequencyFP); } } cache.normalizedHistoryCached[(int)historyKind] = null; } return cache.rawHistoryCached[(int)historyKind]; }
private double GetPredictedVelocity(HistoryKind historyKind, NormalizedBurndownHistory normalizedHistory, bool ignoreNonWorkingdays) { int nDays = Project.GetProject(MainProjectID).AverageVelocitySpan; if (cache.predictedVelocityCache != null && cache.predictedVelocityCache[(int)historyKind].ContainsKey(nDays)) return cache.predictedVelocityCache[(int)historyKind][nDays]; double weightedValueSum = 0; double weightedDaysSum = 0; int iDay = nDays; DateTime day = DateTime.Now.Date; if (ignoreNonWorkingdays && !Project.IsWorkingDay(day)) day = Project.GetPreviousWorkingDay(day); DateTime previousDay = day.AddDays(-1); if (ignoreNonWorkingdays && !Project.IsWorkingDay(previousDay)) previousDay = Project.GetPreviousWorkingDay(previousDay); for (int i = 0; i < nDays; i += 1) { if (previousDay < normalizedHistory.Start) break; double velocityOneDay = normalizedHistory.ValueAt(previousDay.Date) - normalizedHistory.ValueAt(day.Date); weightedValueSum += velocityOneDay * iDay; weightedDaysSum += iDay; iDay -= 1; day = previousDay; previousDay = previousDay.AddDays(-1); if (ignoreNonWorkingdays && !Project.IsWorkingDay(previousDay)) previousDay = Project.GetPreviousWorkingDay(day); } double prediction = 0; if (weightedDaysSum > 0) prediction = weightedValueSum / weightedDaysSum; if (cache.predictedVelocityCache == null) { cache.predictedVelocityCache = new Dictionary<int, double>[3]; for (int i = 0; i < cache.predictedVelocityCache.Length - 1; i += 1) cache.predictedVelocityCache[i] = new Dictionary<int, double>(); } cache.predictedVelocityCache[(int)historyKind].Add(nDays, prediction); return prediction; }
private History(HistoryKind kind, int depth) { _kind = kind; _depth = depth; }
public HistoryQosPolicy(HistoryKind kind, int depth) { _kind = kind; _depth = depth; }
private List <ProductBacklogItem>[] RemainingItemsByRisk(List <ProductBacklogItem> remainingItemsPriorityOrder, HistoryKind historyKind, double[] limits) { List <ProductBacklogItem>[] remainingItemsByRisk = new List <ProductBacklogItem> [3]; remainingItemsByRisk[0] = new List <ProductBacklogItem>(); remainingItemsByRisk[1] = new List <ProductBacklogItem>(); remainingItemsByRisk[2] = new List <ProductBacklogItem>(); double aggregated = 0; foreach (ProductBacklogItem item in remainingItemsPriorityOrder) { double delta = 0; if (historyKind == HistoryKind.Points) { delta = item.Points; } else if (historyKind == HistoryKind.EstimatedDays) { delta = item.EstimatedDays; } if (aggregated + delta >= limits[1]) { remainingItemsByRisk[2].Add(item); } else if (aggregated + delta >= limits[0]) { remainingItemsByRisk[1].Add(item); } else { remainingItemsByRisk[0].Add(item); } aggregated += delta; } return(remainingItemsByRisk); }
private NormalizedBurndownHistory NormalizeHistory(HistoryKind historyKind, RawBurndownHistory rawHistory, double remainingValue) { if (!Started || rawHistory == null) { cache.predictedVelocityCache = null; return(null); } if (cache.normalizedHistoryCached[(int)historyKind] != null && cache.normalizedHistoryCached[(int)historyKind].End.Date == DateTime.Now.Date) { if (remainingValue != cache.normalizedHistoryCached[(int)historyKind].Values[cache.normalizedHistoryCached[(int)historyKind].Length - 1]) { cache.normalizedHistoryCached[(int)historyKind].SetValueAt(cache.normalizedHistoryCached[(int)historyKind].Length - 1, remainingValue); cache.predictedVelocityCache = null; } } else { cache.predictedVelocityCache = null; DateTime end = DateTime.Now.Date; cache.normalizedHistoryCached[(int)historyKind] = new NormalizedBurndownHistory(Start, end); DateTime dayToCalculate = Start.Date; int pruneTo = -1; int rawInd = 0; while (rawHistory.Times[rawInd].AddDays(-1).Date < dayToCalculate) { rawInd = NextDay(rawInd, rawHistory); } for (int iValue = 0; iValue < cache.normalizedHistoryCached[(int)historyKind].Length; iValue += 1) { if (dayToCalculate.Date == end.Date) { cache.normalizedHistoryCached[(int)historyKind].SetValueAt(iValue, remainingValue); break; } if (dayToCalculate.Date < rawHistory.Times[0].AddDays(-1).Date) { pruneTo = iValue; cache.normalizedHistoryCached[(int)historyKind].SetValueAt(iValue, 0); dayToCalculate = dayToCalculate.AddDays(1); } else if (dayToCalculate.Date > rawHistory.Times[rawHistory.Length - 1].AddDays(-1).Date) { cache.normalizedHistoryCached[(int)historyKind].SetValueAt(iValue, rawHistory.Values[rawHistory.Length - 1]); dayToCalculate = dayToCalculate.AddDays(1); } else if (rawInd >= rawHistory.Length) { cache.normalizedHistoryCached[(int)historyKind].SetValueAt(iValue, rawHistory.Values[rawHistory.Length - 1]); dayToCalculate = dayToCalculate.AddDays(1); } else if (dayToCalculate.Date == rawHistory.Times[rawInd].AddDays(-1).Date) { cache.normalizedHistoryCached[(int)historyKind].SetValueAt(iValue, rawHistory.Values[rawInd]); dayToCalculate = dayToCalculate.AddDays(1); rawInd = NextDay(rawInd, rawHistory); } else if (dayToCalculate.Date < rawHistory.Times[rawInd].Date.AddDays(-1)) { // There is a missing value in the middle of the sequence interpolate a value DateTime precedingDate; double precedingValue; if (iValue > 0) { precedingDate = dayToCalculate.AddDays(-1); precedingValue = cache.normalizedHistoryCached[(int)historyKind].Values[iValue - 1]; } else { precedingDate = rawHistory.Times[rawInd - 1].Date; precedingValue = rawHistory.Values[rawInd - 1]; } DateTime followingDate = rawHistory.Times[rawInd].Date; double followingValue = rawHistory.Values[rawInd]; if (Project.GetProject(MainProjectID).IsWorkingDay(dayToCalculate)) { TimeSpan span = followingDate - precedingDate; double delta = (followingValue - precedingValue) / span.Days; cache.normalizedHistoryCached[(int)historyKind].SetValueAt(iValue, precedingValue + delta); dayToCalculate = dayToCalculate.AddDays(1); } else { cache.normalizedHistoryCached[(int)historyKind].SetValueAt(iValue, precedingValue); dayToCalculate = dayToCalculate.AddDays(1); } } } cache.normalizedHistoryCached[(int)historyKind].PruneTo(pruneTo); } return(cache.normalizedHistoryCached[(int)historyKind]); }