public static StatisticsByEntropyViewModel ToStatisticsByEntropy(StatisticsByEntropy elem) { return(new StatisticsByEntropyViewModel { Id = elem.Id, SeriesDiscriptionId = elem.SeriesDiscriptionId, NumberSituation = elem.NumberSituation, Description = elem.Description, StartStateLingvistUX = elem.StartStateLingvistUX, StartStateLingvistFT = elem.StartStateLingvistFT, EndStateLingvistUX = elem.EndStateLingvistUX, EndStateLingvistFT = elem.EndStateLingvistFT, CountMeet = elem.CountMeet }); }
public static StatisticsByEntropy ToStatisticsByEntropy(StatisticsByEntropyBindingModel model, StatisticsByEntropy elem = null) { if (elem == null) { elem = new StatisticsByEntropy(); } elem.SeriesDiscriptionId = model.SeriesDiscriptionId; elem.NumberSituation = model.NumberSituation; elem.Description = model.Description; elem.StartStateLingvistUX = (LingvistUX)Enum.Parse(typeof(LingvistUX), model.StartStateLingvistUX); elem.StartStateLingvistFT = (LingvistFT)Enum.Parse(typeof(LingvistFT), model.StartStateLingvistFT); elem.EndStateLingvistUX = (LingvistUX)Enum.Parse(typeof(LingvistUX), model.EndStateLingvistUX); elem.EndStateLingvistFT = (LingvistFT)Enum.Parse(typeof(LingvistFT), model.EndStateLingvistFT); return(elem); }
/// <summary> /// Определение ситуации по энтропиям, увеличение статистики по этой ситуации /// </summary> /// <param name="point"></param> /// <returns></returns> private StatisticsByEntropy GetStateEntropy(PointInfo point) { using (var _context = new DissertationDbContext()) { var startEntropyUX = Converter.ToLingvistUX(_points[_points.Count - 1].EntropuUX, _points[_points.Count - 1].PositionFUX); var startEntropyFT = Converter.ToLingvistFT(_points[_points.Count - 1].EntropyFT); var endEntropyUX = Converter.ToLingvistUX(point.EntropuUX, point.PositionFUX); var endEntropyFT = Converter.ToLingvistFT(point.EntropyFT); var stateEntropy = _context.StatisticsByEntropys.SingleOrDefault(r => r.StartStateLingvistUX == startEntropyUX && r.StartStateLingvistFT == startEntropyFT && r.EndStateLingvistUX == endEntropyUX && r.EndStateLingvistFT == endEntropyFT && r.SeriesDiscriptionId == point.SeriesDiscriptionId); if (stateEntropy == null) { var number = _context.StatisticsByEntropys .Where(sbf => sbf.SeriesDiscriptionId == point.SeriesDiscriptionId) .Select(sbf => sbf.NumberSituation) .DefaultIfEmpty() .Max() + 1; stateEntropy = new StatisticsByEntropy { SeriesDiscriptionId = point.SeriesDiscriptionId, StartStateLingvistUX = startEntropyUX, StartStateLingvistFT = startEntropyFT, EndStateLingvistUX = endEntropyUX, EndStateLingvistFT = endEntropyFT, NumberSituation = number, CountMeet = 1 }; _context.StatisticsByEntropys.Add(stateEntropy); } else { stateEntropy.CountMeet++; } _context.SaveChanges(); return(stateEntropy); } }
/// <summary> /// Вычисляется точка по значении меры энтропии по нечеткой тенденции и точке фазовой плоскости по предыдущей тенденции (для прогнозирования) /// </summary> /// <param name="lastPointFTN"></param> /// <param name="beforeLastPointFTN"></param> /// <param name="tempStateEntropy"></param> /// <returns></returns> public static int CalcPointFromFFT(FuzzyTrendLabel lastPointFTN, FuzzyTrendLabel beforeLastPointFTN, StatisticsByEntropy tempStateEntropy, int seriesId) { var xLast = Converter.ToFuzzyTrendLabelWeight(lastPointFTN); if (xLast == Converter.TrendWeightNotFound) { throw new Exception("Не найден вес для тенденции " + lastPointFTN); } var xLastLast = Converter.ToFuzzyTrendLabelWeight(beforeLastPointFTN); if (xLastLast == Converter.TrendWeightNotFound) { throw new Exception("Не найден вес для тенденции " + beforeLastPointFTN); } var speedTrendLast = xLastLast - xLast; return(CalcPointFromFFT(Converter.ToEntropyByFT(tempStateEntropy.EndStateLingvistFT), CalcPointOnPhasePlane(lastPointFTN, speedTrendLast), seriesId)); }