private static void DbScanSyntheticTest() { var filePath = $"{Environment.CurrentDirectory}/Data/Synthesis/DataSteamGenerator/data.synthetic.json"; var dataStream = ContinuousDataReader.ReadSyntheticEuclidean(filePath); Func <EuclideanPoint, EuclideanPoint, float> simFunc = (x, y) => (float)Math.Sqrt(Math.Pow(x.X - y.X, 2) + Math.Pow(x.Y - y.Y, 2)); Func <CoreMicroCluster <EuclideanPoint>, CoreMicroCluster <EuclideanPoint>, int, float> cmcSimFunc = (u, v, t) => (float)Math.Sqrt(Math.Pow(u.Center(t).X - v.Center(t).X, 2) + Math.Pow(u.Center(t).Y - v.Center(t).Y, 2)); var denStream = new DenStream <EuclideanPoint>(simFunc, cmcSimFunc); //denStream.SetDataStream(dataStream); var terminate = denStream.MaintainClusterMap(); Thread.Sleep(2000); var clusters = denStream.Cluster(); var clusterPoints = new List <dynamic>(); foreach (var(i, cluster) in clusters.Enumerate()) { foreach (var point in cluster) { clusterPoints.Add(new { x = point.X, y = point.Y, c = i }); } } Console.WriteLine($"Waiting..."); Thread.Sleep(2000); Console.WriteLine($"Terminating MaintainClusterMap"); terminate(); }
private static void DenStreamAsyncTest() { var filePath = $"{Environment.CurrentDirectory}/Data/Synthesis/DataSteamGenerator/data.synthetic.json"; var dataStream = ContinuousDataReader.ReadSyntheticEuclidean(filePath); Func <EuclideanPoint, EuclideanPoint, float> simFunc = (x, y) => (float)Math.Sqrt(Math.Pow(x.X - y.X, 2) + Math.Pow(x.Y - y.Y, 2)); Func <CoreMicroCluster <EuclideanPoint>, CoreMicroCluster <EuclideanPoint>, int, float> cmcSimFunc = (u, v, t) => (float)Math.Sqrt(Math.Pow(u.Center(t).X - v.Center(t).X, 2) + Math.Pow(u.Center(t).Y - v.Center(t).Y, 2)); var denStream = new DenStream <EuclideanPoint>(simFunc, cmcSimFunc); denStream.AddToDataStream(dataStream); var terminate = denStream.MaintainClusterMap(); foreach (var i in 1000.Range()) { try { Thread.Sleep(5); var clusters = denStream.Cluster(); Console.WriteLine($"{clusters.Length} clusters."); } catch (EnvueArgumentException e) { Console.WriteLine($"{i} threw exception."); } } Console.WriteLine($"Terminating MaintainClusterMap"); terminate(); }