Exemplo n.º 1
0
 public static void Refresh(Stone_DBEntities db)
 {
     foreach (var group in Groups)
     {
         group.Refresh(db);
     }
 }
Exemplo n.º 2
0
        private void PersistClusters(Stone_DBEntities db)
        {
            foreach
            (
                var groupClusterHistory in db.GroupClusterHistories
                .Where
                (
                    x =>
                    x.Day <= ApplicationSettings.Instance.HistoryDaysCount &&
                    x.GroupNumber == this.Number
                )
            )
            {
                groupClusterHistory.Day = groupClusterHistory.Day + 1;
            }

            foreach (StoneCluster cluster in this.Clusters)
            {
                db.GroupClusterHistories.AddObject
                (
                    new GroupClusterHistory()
                {
                    Day           = 0,
                    GroupNumber   = this.Number,
                    ClusterPrefix = cluster.Prefix
                }
                );
            }
        }
Exemplo n.º 3
0
 public static void Persist(Stone_DBEntities db)
 {
     foreach (StoneGroup group in Groups)
     {
         group.Persist(db);
     }
 }
Exemplo n.º 4
0
        private void RefreshRatioHistory(Stone_DBEntities db)
        {
            double sumS = 0;
            double sumM = 0;

            foreach (var day in ProfileMaintainer.Days)
            {
                var dayHistory = db.GroupRatioHistories.Where(x => x.Day == day.Number);
                if (dayHistory.IsEmpty())
                {
                    //throw HelperMethods.CreateException("GroupRatioHistoriy does not exist in the day {0}.", day.ToString());
                    this.Re = 1;
                    return;
                }

                var groupHistory = dayHistory.Where(x => x.GroupNumber == this.Number);

                if (groupHistory.IsEmpty())
                {
                    //throw HelperMethods.CreateException("GroupRatioHistoriy History does not exist in the day {0} for the group {1}.", day.Number, this.Number);
                    this.Re = 1;
                    return;
                }

                sumS += groupHistory.First().Ratio *day.Weight;
                sumM += dayHistory.Sum(x => x.Ratio) * day.Weight;
            }
            this.Re = sumS / sumM;
        }
Exemplo n.º 5
0
        private void PersistRatios(Stone_DBEntities db)
        {
            foreach
            (
                var ratioHistory in db.GroupRatioHistories
                .Where
                (
                    x =>
                    x.Day <= ApplicationSettings.Instance.HistoryDaysCount &&
                    x.GroupNumber == this.Number
                )
            )
            {
                ratioHistory.Day = ratioHistory.Day + 1;
            }

            db.GroupRatioHistories.AddObject
            (
                new GroupRatioHistory()
            {
                Day         = 0,
                GroupNumber = this.Number,
                Ratio       = this.Clusters.Count
            }
            );
        }
 public static void Refresh(Stone_DBEntities db)
 {
     AcquaintanceList = new List <StoneCluster>();
     foreach (var dbCluster in db.ClusterHistories.Where(x => x.Day < ApplicationSettings.Instance.HistoryDaysCount))
     {
         var cluster = new StoneCluster(dbCluster.ClusterPrefix, dbCluster.W, dbCluster.T, dbCluster.F);
         AcquaintanceList.Add(cluster);
     }
 }
Exemplo n.º 7
0
        private void RefreshRateHistory(Stone_DBEntities db)
        {
            double Sums = 0;
            double Summ = 0;

            foreach (var day in ProfileMaintainer.Days)
            {
                Sums += day.Weight * this.Rate(day.Number);
                Summ += day.Weight * DCC.Groups.Sum(x => x.Rate(day.Number));
            }
            this.Weight = Sums / Summ;
        }
Exemplo n.º 8
0
        public static void UpdateOrigin(Stone_DBEntities db)
        {
            int D = ApplicationSettings.Instance.HistoryDaysCount;

            var clusterHistories = db.ClusterHistories
                                   .Where(x => x.Day < D)
                                   .ToList();

            var clusters = clusterHistories
                           .Select(x => x.ClusterPrefix)
                           .Distinct()
                           .ToList();

            double[] wSourceCluster = new double[clusters.Count];
            double[] weightedF      = new double[clusters.Count];
            double[] weightedW      = new double[clusters.Count];
            double[] weightedT      = new double[clusters.Count];

            for (int i = 0; i < clusters.Count; i++)
            {
                var thisClusterHistories = clusterHistories.Where(x => x.ClusterPrefix == clusters[i]);
                for (int day = 0; day < D; day++)
                {
                    var dayHistory = thisClusterHistories.FirstOrDefault(x => x.Day == day);

                    if (dayHistory == null)
                    {
                        continue;
                    }

                    wSourceCluster[i] += ProfileMaintainer.Days[day].Weight;
                    weightedF[i]      += ProfileMaintainer.Days[day].Weight * dayHistory.F;
                    weightedT[i]      += ProfileMaintainer.Days[day].Weight * dayHistory.T;
                    weightedW[i]      += ProfileMaintainer.Days[day].Weight * dayHistory.W;
                }
                weightedF[i] = 1 / wSourceCluster[i] * weightedF[i];
                weightedT[i] = 1 / wSourceCluster[i] * weightedT[i];
                weightedW[i] = 1 / wSourceCluster[i] * weightedW[i];
            }
            int p = (int)Math.Truncate(0.95 * wSourceCluster.Sum());

            weightedF.ToList().Sort();

            Origin.Frequency = weightedF[p];
            Origin.Weight    = weightedW[p];
            Origin.LifeTime  = weightedT[p];
        }
        public static void Persist(Stone_DBEntities db)
        {
            foreach (var clusterHistory in db.ClusterHistories.Where(x => x.Day <= ApplicationSettings.Instance.HistoryDaysCount))
            {
                clusterHistory.Day = clusterHistory.Day + 1;
            }

            foreach (StoneCluster cluster in AxesBuilder.Clustres)
            {
                var newClusterHistory = new ClusterHistory()
                {
                    ClusterPrefix = cluster.Prefix,
                    Day           = 0,
                    W             = cluster.Weight,
                    T             = cluster.LifeTime,
                    F             = cluster.Frequency
                };
                db.ClusterHistories.AddObject(newClusterHistory);
            }
        }
Exemplo n.º 10
0
 public void Persist(Stone_DBEntities db)
 {
     PersistRatios(db);
     PersistClusters(db);
     PersistRates(db);
 }
Exemplo n.º 11
0
 public void Refresh(Stone_DBEntities db)
 {
     RefreshRatioHistory(db);
     RefreshRateHistory(db);
 }