예제 #1
0
        public static void Refresh()
        {
            var db = DB.NewContext();

            ProfileMaintainer.ComputeDayWeights();
            DCC.Refresh(db);
            AxesBuilder.UpdateOrigin(db);
            ProfileMaintainer.Refresh(db);
        }
예제 #2
0
        public static void Persist()
        {
            var db = DB.NewContext();

            DCC.Persist(db);

            AxesBuilder.Persist(db);
            try
            {
                db.SaveChanges();
            }
            catch (Exception)
            {
                foreach (var h in db.ClusterHistories)
                {
                    if (double.IsNaN(h.F))
                    {
                        System.Windows.Forms.MessageBox.Show("F");
                    }
                    else if (double.IsNaN(h.W))
                    {
                        System.Windows.Forms.MessageBox.Show("W");
                    }
                    else if (double.IsNaN(h.T))
                    {
                        System.Windows.Forms.MessageBox.Show("T");
                    }
                    else if (double.IsInfinity(h.F))
                    {
                        System.Windows.Forms.MessageBox.Show("F");
                    }
                    else if (double.IsInfinity(h.W))
                    {
                        System.Windows.Forms.MessageBox.Show("W");
                    }
                    else if (double.IsInfinity(h.T))
                    {
                        System.Windows.Forms.MessageBox.Show("T");
                    }
                }
                foreach (var h in db.GroupRateHistories)
                {
                    if (double.IsNaN(h.Rate))
                    {
                        System.Windows.Forms.MessageBox.Show("F");
                    }
                    else if (double.IsInfinity(h.Rate))
                    {
                        System.Windows.Forms.MessageBox.Show("W");
                    }
                }
                throw;
            }
        }
예제 #3
0
        public static void AddTuple(DataSetTuple dataSetTuple)
        {
            if (!IsActive)
            {
                StoneBaseChanel.ForwardToServer(dataSetTuple);
                return;
            }

            int groupNumber = AxesBuilder.GroupFunction(dataSetTuple.StoneFeatures);

            if (groupNumber == 0)
            {
                GroupChanels[0].Add(dataSetTuple);
            }
            else
            {
                var clusters = ProfileMaintainer.AcquaintanceList.Where(x => x.Prefix == dataSetTuple.ClusterPrefix);
                if (clusters.Count() > 0)
                {
                    Boolean added   = false;
                    var     cluster = clusters.First();
                    foreach (var group in DCC.Groups)
                    {
                        var probability = cluster.ProbabilityInGroup(group);
                        var chanel      = GroupChanels[group.Number];
                        added = chanel.ProbabilisticAdd(dataSetTuple, probability * chanel.Capacity);
                        if (added)
                        {
                            break;
                        }
                    }
                    if (!added)
                    {
                        SuspiciousChanel.Add(dataSetTuple);
                    }
                }
                else
                {
                    SuspiciousChanel.Add(dataSetTuple);
                }
            }
        }
예제 #4
0
        public static void Receive(DataAggregatorTuple daTuple)
        {
            int newGroupIndex = AxesBuilder.GroupFunction(daTuple.NewFeatures);
            int oldGroupIndex = AxesBuilder.GroupFunction(daTuple.OldFeatures);

            if (newGroupIndex != oldGroupIndex)
            {
                if (daTuple.NewFeatures.HasValue)
                {
                    if (newGroupIndex != 0)
                    {
                        Groups[newGroupIndex].AddCluster(daTuple.SourceCluster);
                    }
                }
                if (daTuple.OldFeatures.HasValue && Groups[oldGroupIndex].Clusters.Count > 0)
                {
                    if (oldGroupIndex != 0)
                    {
                        Groups[oldGroupIndex].RemoveCluster(daTuple.SourceCluster);
                    }
                }
            }

            int sumRatio = Groups.Sum(x => x.Clusters.Count);

            foreach (var group in Groups)
            {
                group.Rc = (double)group.Clusters.Count / sumRatio;
            }


            for (int i = 0; i < 8; i++)
            {
                if (Math.Abs(Groups[i].Rc - Groups[i].Re) > ApplicationSettings.Instance.AlarmTolerance)
                {
                    Alarm(i, Groups[i].Rc, Groups[i].Re, ApplicationSettings.Instance.AlarmTolerance);
                }
            }

            AxesBuilder.Add(daTuple.SourceCluster);
        }