From 283fb863279172a0240cdae69eff023e149e997a Mon Sep 17 00:00:00 2001 From: Francois Fleuret Date: Sat, 20 Jul 2013 11:51:11 +0200 Subject: [PATCH] Remove the mtp_stress_test command, integrated what it did in mtp_example. --- Makefile | 11 ++---- README.txt | 7 ++-- mtp_example.cc | 54 +++++++++++++++++++++++++++-- mtp_stress_test.cc | 86 ---------------------------------------------- 4 files changed, 55 insertions(+), 103 deletions(-) delete mode 100644 mtp_stress_test.cc diff --git a/Makefile b/Makefile index c502771..bb334d1 100644 --- a/Makefile +++ b/Makefile @@ -41,7 +41,7 @@ endif CXXFLAGS = -Wconversion -Wall $(OPTIMIZE_FLAG) $(PROFILE_FLAG) $(VERBOSE_FLAG) -all: mtp mtp_example mtp_stress_test +all: mtp mtp_example mtp: \ path.o \ @@ -57,17 +57,10 @@ mtp_example: \ mtp_example.o $(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) -mtp_stress_test: \ - path.o \ - mtp_graph.o \ - mtp_tracker.o \ - mtp_stress_test.o - $(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) - Makefile.depend: *.h *.cc Makefile $(CC) $(CXXFLAGS) -M *.cc > Makefile.depend clean: - \rm -f mtp mtp_example mtp_stress_test *.o Makefile.depend + \rm -f mtp mtp_example *.o Makefile.depend -include Makefile.depend diff --git a/README.txt b/README.txt index aad4ca2..ca2e062 100644 --- a/README.txt +++ b/README.txt @@ -28,11 +28,8 @@ This software package includes three commands: - mtp_example creates a tracking toy example, and runs the tracking algorithm on it. It gives an example of how to use MTPTracker on a configuration produced dynamically, and produces a test input file - for the mtp command. - - - mtp_stress_test creates a larger problem with a lot of noise and - multiple trajectories, to check the behavior of the code under - slightly more complex situations. + for the mtp command. If you pass it the "stress" argument, it + generates a larger and noisier problem. * INSTALLATION diff --git a/mtp_example.cc b/mtp_example.cc index 9e8db82..21d6443 100644 --- a/mtp_example.cc +++ b/mtp_example.cc @@ -25,6 +25,7 @@ #include #include #include +#include using namespace std; @@ -41,13 +42,11 @@ scalar_t noisy_score(scalar_t true_score, scalar_t erroneous_score, } } -int main(int argc, char **argv) { +void create_light_test(MTPTracker *tracker) { int nb_locations = 7; int nb_time_steps = 8; int motion_amplitude = 1; - MTPTracker *tracker = new MTPTracker(); - tracker->allocate(nb_time_steps, nb_locations); // We define the spatial structure by stating what are the possible @@ -133,6 +132,55 @@ int main(int argc, char **argv) { ofstream out_tracker("tracker.dat"); tracker->write(&out_tracker); } +} + +void create_heavy_test(MTPTracker *tracker) { + int nb_locations = 100; + int nb_time_steps = 1000; + + tracker->allocate(nb_time_steps, nb_locations); + + for(int l = 0; l < nb_locations; l++) { + for(int m = 0; m < nb_locations; m++) { + tracker->allowed_motions[l][m] = (drand48() < 0.1); + } + } + + for(int t = 0; t < nb_time_steps; t++) { + for(int l = 0; l < nb_locations; l++) { + tracker->entrances[t][l] = drand48() < 0.01; + tracker->exits[t][l] = drand48() < 0.01; + } + } + + tracker->build_graph(); + + for(int t = 0; t < nb_time_steps; t++) { + for(int l = 0; l < nb_locations; l++) { + tracker->detection_scores[t][l] = scalar_t(drand48()) - 0.95f; + } + } +} + +int main(int argc, char **argv) { + int stress_test; + + if(argc == 1) { + stress_test = 0; + } else if(argc == 2 && strcmp(argv[1], "stress") == 0) { + stress_test = 1; + } else { + cerr << "mtp_examples [stress]" << endl; + exit(EXIT_FAILURE); + } + + MTPTracker *tracker = new MTPTracker(); + + if(stress_test) { + create_heavy_test(tracker); + } else { + create_light_test(tracker); + } // Performs the tracking per se diff --git a/mtp_stress_test.cc b/mtp_stress_test.cc deleted file mode 100644 index 68af561..0000000 --- a/mtp_stress_test.cc +++ /dev/null @@ -1,86 +0,0 @@ - -/* - * mtp is the ``Multi Tracked Paths'', an implementation of the - * k-shortest paths algorithm for multi-target tracking. - * - * Copyright (c) 2012 Idiap Research Institute, http://www.idiap.ch/ - * Written by Francois Fleuret - * - * This file is part of mtp. - * - * mtp is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3 as - * published by the Free Software Foundation. - * - * mtp is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public - * License for more details. - * - * You should have received a copy of the GNU General Public License - * along with selector. If not, see . - * - */ - -#include -#include -#include - -using namespace std; - -#include "mtp_tracker.h" - -////////////////////////////////////////////////////////////////////// - -int main(int argc, char **argv) { - int nb_locations = 100; - int nb_time_steps = 1000; - - MTPTracker *tracker = new MTPTracker(); - - tracker->allocate(nb_time_steps, nb_locations); - - for(int l = 0; l < nb_locations; l++) { - for(int m = 0; m < nb_locations; m++) { - tracker->allowed_motions[l][m] = (drand48() < 0.1); - } - } - - for(int t = 0; t < nb_time_steps; t++) { - for(int l = 0; l < nb_locations; l++) { - tracker->entrances[t][l] = drand48() < 0.01; - tracker->exits[t][l] = drand48() < 0.01; - } - } - - tracker->build_graph(); - - for(int t = 0; t < nb_time_steps; t++) { - for(int l = 0; l < nb_locations; l++) { - tracker->detection_scores[t][l] = scalar_t(drand48()) - 0.95f; - } - } - - // Performs the tracking per se - - tracker->track(); - - // Prints the detected trajectories - - for(int t = 0; t < tracker->nb_trajectories(); t++) { - cout << "Trajectory " - << t - << " starting at " << tracker->trajectory_entrance_time(t) - << ", duration " << tracker->trajectory_duration(t) - << ", score " << tracker->trajectory_score(t) - << ", through locations"; - for(int u = 0; u < tracker->trajectory_duration(t); u++) { - cout << " " << tracker->trajectory_location(t, u); - } - cout << endl; - } - - delete tracker; - - exit(EXIT_SUCCESS); -} -- 2.39.5