def run_timings_vs_num_landmarks(): np.random.seed(0) options = simulator_options.copy() options['num_landmarks'] = 1000 calibration = structures.Calibration.random() trials = [] true_trajectory, measurements, spline_template, true_frame_timestamps = simulation.simulate_trajectory( calibration, **options) all_features = measurements.features for n in np.linspace(10, 400, 25): measurements.features = filter(lambda f: f.track_id < n, all_features) try: spline_socp.estimate_trajectory( calibration, measurements, spline_template, estimator='mixed', feature_tolerance=options['feature_noise']*3) trials.append((n, socp.timings['last_solve'])) except spline_socp.InsufficientObservationsError: print 'Simulator failed to generate trajectory. Retrying...' np.savetxt('results/timings_vs_num_landmarks.txt', trials)
def run_accuracy_vs_feature_noise(): np.random.seed(1) calibration = structures.Calibration.random() options = simulator_options.copy() options['feature_noise'] = 0. options['accel_reading_noise'] = 1e-2 true_trajectory, measurements, spline_template = simulation.simulate_trajectory(calibration, **options) results = [] for feature_noise in np.linspace(0, 10, 25): print 'Trying feature noise = %f' % feature_noise noisy_measurements = copy.deepcopy(measurements) for f in noisy_measurements.features: f.position += np.random.randn(2) * feature_noise try: pos_err, vel_err, bias_err, g_err = evaluate( calibration, noisy_measurements, spline_template, 'mixed', feature_noise*3+1e-3, true_trajectory) results.append((feature_noise, pos_err)) except spline_socp.FeasibilityError: pass np.savetxt('results/accuracy_vs_feature_noise.txt', results)
def run_timings_vs_num_knots(): np.random.seed(0) calibration = structures.Calibration.random() trials = [] true_trajectory, measurements, spline_template, true_frame_timestamps = simulation.simulate_trajectory( calibration, **simulator_options) for n in np.arange(2, 21): spline_template.knots = np.linspace(0, simulator_options['duration'], n) try: spline_socp.estimate_trajectory( calibration, measurements, spline_template, estimator='mixed', feature_tolerance=simulator_options['feature_noise']*3) trials.append((n, socp.timings['last_solve'])) except spline_socp.InsufficientObservationsError: print 'Simulator failed to generate trajectory. Retrying...' np.savetxt('results/timings_vs_num_knots.txt', trials)
def simulate_and_evaluate(num_trials, calibration, estimators=None, **options): if estimators is None: estimators = ['mixed'] trials = [] while len(trials) < num_trials: try: true_trajectory, measurements, spline_template = simulation.simulate_trajectory( calibration, **options) row = [] for estimator in estimators: row.extend(evaluate( calibration, measurements, spline_template, estimator, simulator_options['feature_noise']*3, true_trajectory)) trials.append(row) except spline_socp.FeasibilityError: print 'Simulator failed to generate trajectory. Retrying...' except spline_socp.InsufficientObservationsError: print 'Simulator failed to generate trajectory. Retrying...' return np.asarray(trials)