/// <summary> /// Конструктор /// </summary> /// <param name="conditions">Условия проведения эксперимента</param> public StatisticsResult(StatisticCollectCondition <TInput, TOutput> conditions) { TimeStamp = DateTime.Now; Conditions = conditions; OutputFrequency = new Dictionary <TOutput, int>(); StateFrequency = new Dictionary <FSMState <TInput, TOutput>, int>(); RejectionCount = 0; }
/// <summary> /// Собрать статистику /// </summary> /// <param name="conditions">Условия сбора статистики</param> /// <returns>Результаты сбора статистики</returns> public StatisticsResult <TInput, TOutput> CollectStatistics(StatisticCollectCondition <TInput, TOutput> conditions) { if (conditions == null) { throw new ArgumentNullException("conditions"); } if (conditions.InitialState == null) { throw new ArgumentNullException("conditions.InitialState"); } if (TargetFSM.StateSet.FirstOrDefault(s => s.StateCore == conditions.InitialState.StateCore) == null) { throw new ArgumentException("Не совместимое начальное состояние", "conditions.InitialState"); } StatisticsResult <TInput, TOutput> result = new StatisticsResult <TInput, TOutput>(conditions); DebugTimer dt = new DebugTimer(); dt.Start(); for (int i = 0; i < conditions.RepeatsNumber; ++i) { TargetFSM.CurrentState = conditions.InitialState; //result.ProcessData(TargetFSM.CurrentState); TargetFSM.Randomize(); for (int j = 0; j < conditions.InputSequence.Count; ++j) { var r = TargetFSM.Random; var s = TargetFSM.CurrentState; var z = conditions.InputSequence[j]; TOutput output = TargetFSM.ProcessInput(conditions.InputSequence[j]); result.ProcessData(TargetFSM.CurrentState, output); TargetFSM.Randomize(); } } result.WorkTime = dt.GetSeconds(); return(result); }