public ITrajectory eval(ITrajectoryBundle tb) { ITrajectory central = tb.CentralTrajectory; ITrajectory dev = new Trajectory(tb.Name + SUFFIX, tb.TemporalGranularityThreshold, 0.0, 0.0); foreach (double t in central.Times) { double max = Double.NegativeInfinity; double centralval = central.eval(t); foreach (ITrajectory traj in tb.Trajectories) { if (traj == central) { continue; } if (traj.Times.Count == 0) { continue; } double y = traj.eval(t); double diff = Math.Abs(y - centralval); if (diff > max) { max = diff; } } dev.add(t, max); } return(dev); }
public void add(ISimulationResults res) { foreach (ITrajectory t in res.getTrajectories()) { ITrajectoryBundle tb = null; if (!_tbundles.ContainsKey(t.Name)) { tb = new TrajectoryBundle(t.Name); _tbundles.Add(t.Name, tb); } else { tb = _tbundles[t.Name]; } tb.addTrajectory(t); } foreach (IAgentEvaluation ae in res.getAgentEvaluations()) { IAgentEvaluationBundle aeb = null; if (!_aebundles.ContainsKey(ae.Name)) { aeb = new AgentEvaluationBundle(ae.Name); _aebundles.Add(ae.Name, aeb); } else { aeb = _aebundles[ae.Name]; } aeb.addAgentEvaluation(ae); } }
private void ComputeYrange(ITrajectoryBundle tb, out double min, out double max) { min = Double.MaxValue; max = Double.MinValue; foreach (ITrajectory traj in tb.Trajectories) { double step = (traj.MaximumTime - traj.MinimumTime) / STEPS; for (double x = traj.MinimumTime; x <= traj.MaximumTime; x += step) /// NULL TRAJECTORY FIX { double y = traj.eval(x); if (y < min) { min = y; } if (y > max) { max = y; } if (step == 0.0) { break; /// NULL TRAJECTORY FIX } } } }
private void Present(ITrajectoryBundle tb) { int i = 1; foreach (ITrajectory traj in tb.Trajectories) { this.BeginPresentation(_datadir, traj.Name + "-" + i + ".tra"); Present(traj, i, tb.Trajectories.Count); this.EndPresentation(); i++; } ITrajectory meanTraj = tb.MeanTrajectory; ITrajectory stdTraj = tb.StdTrajectory; ITrajectory centerTraj = tb.CentralTrajectory; ITrajectory centerDev = tb.CentralDevTrajectory; this.BeginPresentation(_datadir, meanTraj.Name + ".tra"); PresentMean(meanTraj, stdTraj); this.EndPresentation(); this.BeginPresentation(_datadir, centerTraj.Name + TrajectoryBundleCollapser_CentralDTW.SUFFIX + ".tra"); PresentCenter(centerTraj, centerDev); this.EndPresentation(); this.BeginPresentation(_gpdir, tb.Name + ".traj.gp"); CreateGnuplotScript(tb, meanTraj, centerTraj); this.EndPresentation(); }
public ITrajectory eval(ITrajectoryBundle tb) { TrajectoryDistanceMeasure_DTW dist = new TrajectoryDistanceMeasure_DTW(); ITrajectory winner = null; double winningD = Double.PositiveInfinity; foreach (ITrajectory t in tb.Trajectories) { if (winner == null) { winner = t; } if (t.Times.Count == 0) { continue; } double totalD = 0.0; foreach (ITrajectory t2 in tb.Trajectories) { if (t == t2) { continue; } if (t2.Times.Count == 0) { continue; } double minDur = Math.Min(t.MaximumTime, t2.MaximumTime); double inc = dist.eval(t, t2, minDur); totalD += Math.Abs(inc); // Console.WriteLine("d("+t.GetHashCode()+" -- "+t2.GetHashCode()+") = "+inc); } if (totalD < winningD) { winningD = totalD; winner = t; } // Console.WriteLine("*** total d("+t.GetHashCode()+") = "+totalD); } /* * ITrajectory CentralTrajectory = new Trajectory(tb.Name+SUFFIX, tb.TemporalGranularityThreshold, 0.0); * foreach (double t in winner.Times) { * CentralTrajectory.add(t, winner.eval (t)); * } */ return(winner); }
private void ComputeXrange(ITrajectoryBundle tb, out double min, out double max) { min = Double.MaxValue; max = Double.MinValue; foreach (ITrajectory traj in tb.Trajectories) { if (traj.MinimumTime < min) { min = traj.MinimumTime; } if (traj.MaximumTime > max) { max = traj.MaximumTime; } } }
public ITrajectory eval(ITrajectoryBundle tb) { SortedList <double, double> alltimes = tb.Times; ITrajectory mean = new Trajectory(tb.Name + SUFFIX, tb.TemporalGranularityThreshold, 0.0, 0.0); foreach (double t in alltimes.Keys) { double val = 0.0; double ct = 0.0; foreach (ITrajectory traj in tb.Trajectories) { val += traj.eval(t); ct += 1.0; } mean.add(t, val / ct); } return(mean); }
public ITrajectory eval(ITrajectoryBundle tb) { ITrajectory mean = tb.MeanTrajectory; SortedList <double, double> alltimes = tb.Times; ITrajectory std = new Trajectory(tb.Name + SUFFIX, tb.TemporalGranularityThreshold, 0.0, 0.0); foreach (double t in alltimes.Keys) { double val = 0.0; double ct = 0.0; foreach (ITrajectory traj in tb.Trajectories) { double y = traj.eval(t); double ybar = mean.eval(t); val += (y - ybar) * (y - ybar); ct += 1.0; } std.add(t, Math.Sqrt(val / ct)); } return(std); }
public void add(ISimulationResultsBundle resb) { foreach (ITrajectoryBundle tb in resb.getTrajectoryBundles()) { foreach (ITrajectory t in tb.Trajectories) { ITrajectoryBundle newtb = null; if (!_tbundles.ContainsKey(t.Name)) { newtb = new TrajectoryBundle(t.Name); _tbundles.Add(t.Name, newtb); } else { newtb = _tbundles[t.Name]; } newtb.addTrajectory(t); } } foreach (IAgentEvaluationBundle aeb in resb.getAgentEvaluationBundles()) { foreach (IAgentEvaluation ae in aeb.Evaluations) { IAgentEvaluationBundle newaeb = null; if (!_aebundles.ContainsKey(ae.Name)) { newaeb = new AgentEvaluationBundle(ae.Name); _aebundles.Add(ae.Name, newaeb); } else { newaeb = _aebundles[ae.Name]; } aeb.addAgentEvaluation(ae); } } }
private void CreateGnuplotScript(ITrajectoryBundle tb, ITrajectory meanTraj, ITrajectory centerTraj) { this.AppendToPresentation("set terminal postscript eps enhanced"); this.AppendToPresentation("set output \"" + tb.Name + ".eps\""); Latex.AddImage("" + tb.Name + ".eps", "" + tb.Name + " trajectory in " + _experimentName); double min, max; ComputeYrange(tb, out min, out max); double low = min == Double.MaxValue ? -1.0 : min - (max - min); double high = max == Double.MinValue ? 1.0 : max + (max - min); double mint, maxt; ComputeXrange(tb, out mint, out maxt); double lowt = mint == Double.MaxValue ? 0.0 : mint; double hight = maxt == Double.MinValue ? 1.0 : maxt; this.AppendToPresentation("set xrange [ " + lowt + " : " + hight + " ]"); this.AppendToPresentation("set yrange [ " + low + " : " + high + " ]"); this.AppendToPresentation("set title \"" + _experimentName + " " + tb.Name + " Trajectory\""); this.AppendToPresentation("set ylabel \"" + tb.Name + "\""); this.AppendToPresentation("set xlabel \"Time (seconds)\""); string s = "plot "; int i = 1; foreach (ITrajectory traj in tb.Trajectories) { s += "\"../" + _exp.TRAJ_DIR_STRING + "/" + traj.Name + "-" + i + ".tra\" using 1:2 with lines notitle lt 2 lc rgb \"black\""; s += ", "; i++; } s += "\"../" + _exp.TRAJ_DIR_STRING + "/" + meanTraj.Name + ".tra\" using 1:2:3 with yerrorbars t \"Mean\" lc rgb \"blue\","; s += "\"../" + _exp.TRAJ_DIR_STRING + "/" + centerTraj.Name + TrajectoryBundleCollapser_CentralDTW.SUFFIX + ".tra\" using 1:2:3 with yerrorbars t \"Center\" lc rgb \"red\""; this.AppendToPresentation(s); }
public ITrajectory eval(ITrajectoryBundle tb) { SortedList <double, double> alltimes = tb.Times; ITrajectory avesep = new Trajectory(tb.Name + SUFFIX, tb.TemporalGranularityThreshold, 0.0, 0.0); foreach (double t in alltimes.Keys) { double val = 0.0; double ct = 0.0; foreach (ITrajectory traj1 in tb.Trajectories) { if (traj1.Times.Count == 0) { continue; } foreach (ITrajectory traj2 in tb.Trajectories) { if (traj1 == traj2) { continue; } if (traj2.Times.Count == 0) { continue; } val += Math.Abs(traj1.eval(t) - traj2.eval(t)); ct += 1.0; } } avesep.add(t, val / ct); } return(avesep); }