Example #1
0
 /// <summary>
 /// Primary Constructor
 /// </summary>
 /// <param name="cluster">An EventCollection representing a cluster</param>
 /// <param name="clusterid">The ID of the cluster</param>
 public ClusterAnalysis(EventCollection cluster, int clusterid)
 {
     Cluster      = cluster;
     ClusterID    = clusterid;
     DropAnalysis = new DropAnalysis(Cluster);
     FailAnalysis = new FailAnalysis(Cluster);
 }
 /// <summary>
 /// Primary Constructor
 /// </summary>
 /// <param name="cluster">An EventCollection representing a cluster</param>
 /// <param name="clusterid">The ID of the cluster</param>
 public ClusterAnalysis(EventCollection cluster, int clusterid)
 {
     Cluster = cluster;
       ClusterID = clusterid;
       DropAnalysis = new DropAnalysis(Cluster);
       FailAnalysis = new FailAnalysis(Cluster);
 }
        /// <summary>
        /// This method will produce a JSON object that contains all the data from
        /// the current instance. Only focusing upon fail events, this method will
        /// firstly group the events by the start MixBand only, and then by the
        /// start and end MixBand values.
        /// </summary>
        /// <returns>A well formed JSON string</returns>
        public String CreateFailMixBandJSON()
        {
            // Create a new JSONResults Data Structure
            JSONResults json = new JSONResults(WeekNumber);

            // Loop over all clusters in this week
            foreach (KeyValuePair <int, ClusterAnalysis> pair in ClustersAnalysis)
            {
                // Get the Drop Analysis object
                FailAnalysis analysis = pair.Value.FailAnalysis;
                // Used to stores the split up events
                List <String>             keys   = analysis.GroupByStartMixBand().Keys.ToList();
                AnalysisResultsCollection groups = new AnalysisResultsCollection(keys);
                // Get the Analysis result
                AnalysisResults results = analysis.GroupByStartEndMixBand();
                // Loop over each result
                foreach (KeyValuePair <String, EventCollection> p in results)
                {
                    // Calculate the Key
                    String key = p.Value[0].StartMixBand;
                    // Add into the array
                    groups[key].Add(p.Key, p.Value);
                }
                // Add the Mix-Band goup to the JSONResults Data Structure
                json.Add(pair.Key, groups);
            }
            // return the JSON data structure for this week
            return(json.ToString());
        }
        public void Initialise()
        {
            // Create a new KML Reader
              KMLReader reader = new KMLReader(ROOT_DIR + "data\\L_wk32_drops.kml");

              // Read in all call logs
              EventCollection collection = reader.GetCallLogs();

              // Cluster the call logs
              DBSCAN scan = new DBSCAN(collection);
              scan.Analyse();

              // Initialise the cluster
              Cluster = new EventCollection(scan.Clusters.OrderBy(col => col.Count).Last());

              // Initialise the Cluster analysis
              Analysis = new FailAnalysis(Cluster);
        }