Removed compute_dp_ranks, added compute_dp_ordering instead.
[mtp.git] / mtp_stress_test.cc
1
2 /*
3  *  mtp is the ``Multi Tracked Paths'', an implementation of the
4  *  k-shortest paths algorithm for multi-target tracking.
5  *
6  *  Copyright (c) 2012 Idiap Research Institute, http://www.idiap.ch/
7  *  Written by Francois Fleuret <francois.fleuret@idiap.ch>
8  *
9  *  This file is part of mtp.
10  *
11  *  mtp is free software: you can redistribute it and/or modify it
12  *  under the terms of the GNU General Public License version 3 as
13  *  published by the Free Software Foundation.
14  *
15  *  mtp is distributed in the hope that it will be useful, but WITHOUT
16  *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17  *  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
18  *  License for more details.
19  *
20  *  You should have received a copy of the GNU General Public License
21  *  along with selector.  If not, see <http://www.gnu.org/licenses/>.
22  *
23  */
24
25 #include <iostream>
26 #include <fstream>
27 #include <stdlib.h>
28
29 using namespace std;
30
31 #include "mtp_tracker.h"
32
33 //////////////////////////////////////////////////////////////////////
34
35 int main(int argc, char **argv) {
36   int nb_locations = 100;
37   int nb_time_steps = 1000;
38
39   MTPTracker *tracker = new MTPTracker();
40
41   tracker->allocate(nb_time_steps, nb_locations);
42
43   for(int l = 0; l < nb_locations; l++) {
44     for(int m = 0; m < nb_locations; m++) {
45       tracker->allowed_motions[l][m] = (drand48() < 0.1);
46     }
47   }
48
49   for(int t = 0; t < nb_time_steps; t++) {
50     for(int l = 0; l < nb_locations; l++) {
51       tracker->entrances[t][l] = drand48() < 0.01;
52       tracker->exits[t][l] = drand48() < 0.01;
53     }
54   }
55
56   tracker->build_graph();
57
58   for(int t = 0; t < nb_time_steps; t++) {
59     for(int l = 0; l < nb_locations; l++) {
60       tracker->detection_scores[t][l] = scalar_t(drand48()) - 0.95f;
61     }
62   }
63
64   // Performs the tracking per se
65
66   tracker->track();
67
68   // Prints the detected trajectories
69
70   for(int t = 0; t < tracker->nb_trajectories(); t++) {
71     cout << "Trajectory "
72          << t
73          << " starting at " << tracker->trajectory_entrance_time(t)
74          << ", duration " << tracker->trajectory_duration(t)
75          << ", score " << tracker->trajectory_score(t)
76          << ", through nodes ";
77     for(int u = 0; u < tracker->trajectory_duration(t); u++) {
78       cout << " " << tracker->trajectory_location(t, u);
79     }
80     cout << endl;
81   }
82
83   delete tracker;
84
85   exit(EXIT_SUCCESS);
86 }