From: Francois Fleuret Date: Sun, 26 Aug 2012 07:22:55 +0000 (+0200) Subject: Renamed the Tracker class to MTPTracker. X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=commitdiff_plain;h=f248d9481cd0338053cb38a18eb3898042c126d3;p=mtp.git Renamed the Tracker class to MTPTracker. --- diff --git a/Makefile b/Makefile index e8cad3a..e390a7d 100644 --- a/Makefile +++ b/Makefile @@ -51,14 +51,16 @@ random-graph: \ $(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) mtp: \ - path.o mtp_graph.o \ - tracker.o \ + path.o \ + mtp_graph.o \ + mtp_tracker.o \ mtp.o $(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) mtp_example: \ - path.o mtp_graph.o \ - tracker.o \ + path.o \ + mtp_graph.o \ + mtp_tracker.o \ mtp_example.o $(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) diff --git a/README.txt b/README.txt index eb8a26f..708fea6 100644 --- a/README.txt +++ b/README.txt @@ -31,7 +31,7 @@ with the dot command from graphviz: * IMPLEMENTATION -The two main classes are MTPGraph and Tracker. +The two main classes are MTPGraph and MTPTracker. The MTPGraph class stores a directed acyclic graph (DAG), with a length for each edge -- which can be negative -- and can compute the @@ -43,7 +43,7 @@ no path at all. Note that the procedure is similar to that of KSP, in the sense that the family it computes eventually is globally optimal, even if the computation is iterative. -The Tracker class allows +The MTPTracker class allows (1) to define a spatial topology composed of @@ -64,7 +64,7 @@ consistent with the topology, which maximizes the overall detection score (i.e. the sum of the detection scores of the nodes visited by the trajectories) -The Tracker class uses the MTPGraph. From the definition of the +The MTPTracker class uses the MTPGraph. From the definition of the spatial topology, it builds a graph with one source, one sink, and two nodes per location and time. This structure ensures the trajectories computed by the tracker to be node-disjoint by forcing the paths @@ -74,10 +74,10 @@ The edges from the source or to the sink, or between these pairs, are of length zero, and the edge between the two nodes of such a pair has a length equal to the opposite of the detection score. -The file mtp.cc gives a very simple usage example of the Tracker +The file mtp.cc gives a very simple usage example of the MTPTracker class. -The tracker data file one can read with Tracker::read has the +The tracker data file one can read with MTPTracker::read has the following format (with L the number of locations and T the number of time steps): diff --git a/mtp.cc b/mtp.cc index 75cbe96..c6d31b3 100644 --- a/mtp.cc +++ b/mtp.cc @@ -27,7 +27,7 @@ using namespace std; -#include "tracker.h" +#include "mtp_tracker.h" int main(int argc, char **argv) { @@ -40,7 +40,7 @@ int main(int argc, char **argv) { if(in_tracker->good()) { - Tracker *tracker = new Tracker(); + MTPTracker *tracker = new MTPTracker(); tracker->read(in_tracker); cout << "Read " << argv[1] << endl; diff --git a/mtp_example.cc b/mtp_example.cc index 0db6054..84ef153 100644 --- a/mtp_example.cc +++ b/mtp_example.cc @@ -27,7 +27,7 @@ using namespace std; -#include "tracker.h" +#include "mtp_tracker.h" ////////////////////////////////////////////////////////////////////// @@ -45,7 +45,7 @@ int main(int argc, char **argv) { int nb_time_steps = 8; int motion_amplitude = 1; - Tracker *tracker = new Tracker(); + MTPTracker *tracker = new MTPTracker(); tracker->allocate(nb_time_steps, nb_locations); diff --git a/tracker.cc b/mtp_tracker.cc similarity index 91% rename from tracker.cc rename to mtp_tracker.cc index d19093b..af97ca5 100644 --- a/tracker.cc +++ b/mtp_tracker.cc @@ -22,13 +22,13 @@ * */ -#include "tracker.h" +#include "mtp_tracker.h" #include using namespace std; -void Tracker::free() { +void MTPTracker::free() { delete[] _edge_lengths; delete _graph; deallocate_array(detection_scores); @@ -37,7 +37,7 @@ void Tracker::free() { delete[] entrances; } -void Tracker::allocate(int nb_time_steps, int nb_locations) { +void MTPTracker::allocate(int nb_time_steps, int nb_locations) { free(); _nb_locations = nb_locations; @@ -67,7 +67,7 @@ void Tracker::allocate(int nb_time_steps, int nb_locations) { _graph = 0; } -void Tracker::write(ostream *os) { +void MTPTracker::write(ostream *os) { (*os) << _nb_locations << " " << _nb_time_steps <> nb_locations >> nb_time_steps; @@ -131,7 +131,7 @@ void Tracker::read(istream *is) { } } -void Tracker::write_trajectories(ostream *os) { +void MTPTracker::write_trajectories(ostream *os) { for(int t = 0; t < nb_trajectories(); t++) { (*os) << t << " " << trajectory_entrance_time(t) @@ -144,7 +144,7 @@ void Tracker::write_trajectories(ostream *os) { } } -Tracker::Tracker() { +MTPTracker::MTPTracker() { _nb_locations = 0; _nb_time_steps = 0; @@ -158,7 +158,7 @@ Tracker::Tracker() { _graph = 0; } -Tracker::~Tracker() { +MTPTracker::~MTPTracker() { delete[] _edge_lengths; delete _graph; deallocate_array(detection_scores); @@ -167,15 +167,15 @@ Tracker::~Tracker() { delete[] entrances; } -int Tracker::early_pair_node(int t, int l) { +int MTPTracker::early_pair_node(int t, int l) { return 1 + (2 * (t + 0) + 0) * _nb_locations + l; } -int Tracker::late_pair_node(int t, int l) { +int MTPTracker::late_pair_node(int t, int l) { return 1 + (2 * (t + 0) + 1) * _nb_locations + l; } -void Tracker::build_graph() { +void MTPTracker::build_graph() { // Delete the existing graph if there was one delete[] _edge_lengths; delete _graph; @@ -288,7 +288,7 @@ void Tracker::build_graph() { delete[] node_to; } -void Tracker::print_graph_dot(ostream *os) { +void MTPTracker::print_graph_dot(ostream *os) { int e = 0; for(int t = 0; t < _nb_time_steps; t++) { for(int l = 0; l < _nb_locations; l++) { @@ -298,7 +298,7 @@ void Tracker::print_graph_dot(ostream *os) { _graph->print_dot(os); } -void Tracker::track() { +void MTPTracker::track() { ASSERT(_graph); int e = 0; @@ -323,22 +323,22 @@ void Tracker::track() { #endif } -int Tracker::nb_trajectories() { +int MTPTracker::nb_trajectories() { return _graph->nb_paths; } -scalar_t Tracker::trajectory_score(int k) { +scalar_t MTPTracker::trajectory_score(int k) { return -_graph->paths[k]->length; } -int Tracker::trajectory_entrance_time(int k) { +int MTPTracker::trajectory_entrance_time(int k) { return (_graph->paths[k]->nodes[1] - 1) / (2 * _nb_locations); } -int Tracker::trajectory_duration(int k) { +int MTPTracker::trajectory_duration(int k) { return (_graph->paths[k]->nb_nodes - 2) / 2; } -int Tracker::trajectory_location(int k, int time_from_entry) { +int MTPTracker::trajectory_location(int k, int time_from_entry) { return (_graph->paths[k]->nodes[2 * time_from_entry + 1] - 1) % _nb_locations; } diff --git a/tracker.h b/mtp_tracker.h similarity index 95% rename from tracker.h rename to mtp_tracker.h index c21df97..08de498 100644 --- a/tracker.h +++ b/mtp_tracker.h @@ -22,8 +22,8 @@ * */ -#ifndef TRACKER_H -#define TRACKER_H +#ifndef MTP_TRACKER_H +#define MTP_TRACKER_H #include @@ -32,7 +32,7 @@ using namespace std; #include "misc.h" #include "mtp_graph.h" -class Tracker { +class MTPTracker { int _nb_locations, _nb_time_steps; scalar_t **_detection_score; int **_allowed_motion; @@ -53,8 +53,8 @@ public: // The detection scores at each node scalar_t **detection_scores; - Tracker(); - ~Tracker(); + MTPTracker(); + ~MTPTracker(); void allocate(int nb_time_steps, int nb_locations); void free();