Esempio n. 1
0
        private JsonReport(StrykerOptions options, IReadOnlyInputComponent mutationReport)
        {
            _options = options;

            Thresholds.Add("high", _options.Thresholds.High);
            Thresholds.Add("low", _options.Thresholds.Low);

            Merge(Files, GenerateReportComponents(mutationReport));
        }
Esempio n. 2
0
        private JsonReport(IStrykerOptions options, IReadOnlyProjectComponent mutationReport)
        {
            _options = options;

            Thresholds.Add("high", _options.Thresholds.High);
            Thresholds.Add("low", _options.Thresholds.Low);

            ProjectRoot = mutationReport.FullPath;

            Merge(Files, GenerateReportComponents(mutationReport));
        }
        public override Boolean Load(Int64 forId)
        {
            Boolean success = false;

            StringBuilder selectStatement = new StringBuilder();

            System.Data.DataTable dataTable;


            if (application.EnvironmentDatabase == null)
            {
                return(false);
            }

            selectStatement.Append("SELECT * FROM dbo.CareLevelActivity WHERE CareLevelActivityId = " + forId.ToString());

            dataTable = application.EnvironmentDatabase.SelectDataTable(selectStatement.ToString(), 0);

            if (dataTable.Rows.Count == 1)
            {
                MapDataFields(dataTable.Rows[0]);

                success = true;
            }

            else
            {
                success = false;
            }


            if (success)
            {
                // LOAD CHILD OBJECTS

                String selectActivities = "SELECT * FROM dbo.CareLevelActivityThreshold WHERE CareLevelActivityId = " + forId.ToString();

                dataTable = application.EnvironmentDatabase.SelectDataTable(selectActivities.ToString(), 0);

                foreach (System.Data.DataRow currentRow in dataTable.Rows)
                {
                    Activity.ActivityThreshold threshold = new Activity.ActivityThreshold(application);

                    threshold.MapDataFields(currentRow);

                    Thresholds.Add(threshold);
                }
            }

            return(success);
        }
Esempio n. 4
0
        private void Iterate()
        {
            float d, curD;
            KeyValuePair <int, Cluster> closestCl = new KeyValuePair <int, Cluster>();

            //find closest cluster for each histogram unit and apply info
            foreach (KeyValuePair <ushort, HistogramUnit> node in Histogram)
            {
                d = float.MaxValue;
                foreach (KeyValuePair <int, Cluster> c in currentCluster)
                {
                    curD = Math.Abs(c.Value.Centroid - (float)node.Key);
                    if (curD < d)
                    {
                        d         = curD;
                        closestCl = c;
                    }
                }

                closestCl.Value.Counter += node.Value.Counter;
                closestCl.Value.Sum     += node.Value.Sum;

                if (closestCl.Value.Min > node.Key)
                {
                    closestCl.Value.Min = node.Key;
                }
                if (closestCl.Value.Max < node.Key)
                {
                    closestCl.Value.Max = node.Key;
                }
            }
            //calculate the new centroids
            foreach (KeyValuePair <int, Cluster> c in currentCluster)
            {
                c.Value.Centroid = c.Value.Sum / c.Value.Counter;
            }
            //Calculate new thresholds
            clusterArr.Clear();
            for (int i = 0; i < currentCluster.Count; i++)
            {
                Cluster tempClust = null;
                foreach (KeyValuePair <int, Cluster> cluster in currentCluster)
                {
                    if (clusterArr.IndexOf(cluster.Value) == -1)
                    {
                        if (tempClust == null)
                        {
                            tempClust = cluster.Value;
                        }
                        else if (tempClust.Min > cluster.Value.Min)
                        {
                            tempClust = cluster.Value;
                        }
                    }
                }
                if (tempClust != null)
                {
                    clusterArr.Add(tempClust);
                }
            }

            Thresholds.Clear();

            for (int i = 0, j = 1; j < clusterArr.Count; i++, j++)
            {
                Thresholds.Add((int)(clusterArr[i].Max + ((clusterArr[j].Min - clusterArr[i].Max) / 2)));
            }

            Thresholds.Add(int.MaxValue);

            clusterArr.Clear();

            //Clear;
            foreach (KeyValuePair <int, Cluster> c in currentCluster)
            {
                c.Value.Min     = float.MaxValue;
                c.Value.Max     = float.MinValue;
                c.Value.Counter = 1;
                c.Value.Sum     = (long)c.Value.Centroid;
            }

            CheckConvergence();
        }
Esempio n. 5
0
 public void SetThreshold(double low, double high, Action <bool> handler)
 {
     Thresholds.Add(new MyTuple <double, double, Action <bool> >(low, high, handler));
 }