// read filenames and indexes from manifest static void outputMatrix(string manifest, string dirin, string fileout) { var stopwatch = new System.Diagnostics.Stopwatch(); stopwatch.Start(); var manifestfile = File.OpenText(manifest); var trajinfo = JsonConvert.DeserializeObject <List <string> >(manifestfile.ReadToEnd()); var trajs = new List <Trajectory>(); foreach (var filename in trajinfo) { trajs.AddRange(LoadFromFile(Path.Combine(dirin, filename))); } var AABBs = new List <AABB>(); int N = trajs.Count; var output = new float[N, N]; // initialize AABBs for (int i = 0; i < N; i++) { AABBs.Add(new AABB(trajs[i])); } stopwatch.Stop(); Console.WriteLine("Prep time: {0}", stopwatch.Elapsed); stopwatch.Reset(); stopwatch.Start(); for (int y = 0; y < N; y++) // go row by row { for (int x = 0; x < N; x++) { if (x == y) { output[x, y] = 0; } else if (x < y) // if on the lower side of the diagonal, just copy value { output[x, y] = output[y, x]; } else { output[x, y] = EDwP.doEDwP(trajs[x], trajs[y], true); //output[x, y] = EDwP.doBoundedEDwP(trajs[x], AABBs[x], trajs[y], AABBs[y], true); } } } stopwatch.Stop(); File.WriteAllText(fileout, JsonConvert.SerializeObject(output)); Console.WriteLine("Runtime: {0}", stopwatch.Elapsed); Console.WriteLine("Done."); }
static void testRandomTraj(int n1, int n2) { var t0 = GetRandomTraj(1); var t1 = GetRandomTraj(n1); var t2 = GetRandomTraj(n2); var stopwatch = new System.Diagnostics.Stopwatch(); EDwP.doEDwP(t0, t0, true); stopwatch.Start(); var score = EDwP.doEDwP(t1, t2, true); stopwatch.Stop(); Console.Write("EDwP score: "); Console.WriteLine(score); Console.Write("Elapsed time: "); Console.WriteLine(stopwatch.Elapsed); }
static void Standardtest() { var trajs = LoadFromFile("trajectories.json"); foreach (var traj in trajs) { Console.WriteLine(traj); } var values = new List <float>(); float[] testvals = { 5.65f, 4.64f, 7.77f, 89.65f }; values.Add(EDwP.doEDwP(trajs[0], trajs[1], true)); values.Add(EDwP.doEDwP(trajs[1], trajs[2], true)); values.Add(EDwP.doEDwP(trajs[0], trajs[2], true)); values.Add(EDwP.doEDwP(trajs[3], trajs[4])); for (int i = 0; i < 4; i++) { Console.Write("EDwP: "); Console.Write(values[i]); Console.Write(", should be "); Console.WriteLine(testvals[i]); } }