From: Francois Fleuret Date: Sat, 25 Aug 2012 05:29:28 +0000 (+0200) Subject: The main command now loads a tracker file, and mtp_example produces it. X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=commitdiff_plain;h=b55dae20c1b56dac452dda6ab2831ea6388c079b;p=mtp.git The main command now loads a tracker file, and mtp_example produces it. --- diff --git a/Makefile b/Makefile index 4b71e4b..523a3e4 100644 --- a/Makefile +++ b/Makefile @@ -39,7 +39,7 @@ endif CXXFLAGS = -Wall $(OPTIMIZE_FLAG) $(PROFILE_FLAG) $(VERBOSE_FLAG) -all: mtp random-graph +all: mtp mtp_example TAGS: *.cc *.h etags --members -l c++ *.cc *.h @@ -54,6 +54,12 @@ mtp: \ mtp.o $(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) +mtp_example: \ + path.o mtp_graph.o \ + tracker.o \ + mtp_example.o + $(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) + Makefile.depend: *.h *.cc Makefile $(CC) $(CXXFLAGS) -M *.cc > Makefile.depend diff --git a/mtp_example.cc b/mtp_example.cc index 13cd4f1..cb3f44e 100644 --- a/mtp_example.cc +++ b/mtp_example.cc @@ -113,43 +113,24 @@ int main(int argc, char **argv) { // Does the tracking per se - { - ofstream out_tracker("/tmp/tracker.dat"); - tracker->write(&out_tracker); - - ifstream in_tracker("/tmp/tracker.dat"); - Tracker tracker2; - tracker2.read(&in_tracker); - tracker2.build_graph(); - tracker2.track(); - ofstream out_traj("/tmp/result.trj"); - tracker2.write_trajectories(&out_traj); - } + ofstream out_tracker("tracker.dat"); + tracker->write(&out_tracker); tracker->track(); // Prints the detected trajectories for(int t = 0; t < tracker->nb_trajectories(); t++) { - cout << "TRAJECTORY " + cout << "Trajectory " << t - << " [starting " << tracker->trajectory_entrance_time(t) - << ", score " << tracker->trajectory_score(t) << "]"; + << " starting at " << tracker->trajectory_entrance_time(t) + << ", score " << tracker->trajectory_score(t) << ", through nodes "; for(int u = 0; u < tracker->trajectory_duration(t); u++) { cout << " " << tracker->trajectory_location(t, u); } cout << endl; } - // Save the underlying graph in the dot format, with occupied edges - // marked in bold. - - { - ofstream dot("graph.dot"); - tracker->print_graph_dot(&dot); - cout << "Wrote graph.dot." << endl; - } - delete tracker; exit(EXIT_SUCCESS); diff --git a/random-graph.cc b/random-graph.cc deleted file mode 100644 index 6560ea4..0000000 --- a/random-graph.cc +++ /dev/null @@ -1,70 +0,0 @@ - -/////////////////////////////////////////////////////////////////////////// -// This program is free software: you can redistribute it and/or modify // -// it under the terms of the version 3 of the GNU General Public License // -// as published by the Free Software Foundation. // -// // -// This program 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 this program. If not, see . // -// // -// Written by and Copyright (C) Francois Fleuret // -// Contact for comments & bug reports // -/////////////////////////////////////////////////////////////////////////// - -#include -#include -#include -#include -#include - -using namespace std; - -int main(int argc, char **argv) { - int nb_locations = 20; - int nb_time_steps = 20; - - int nb_vertices = nb_time_steps * nb_locations + 2; - int nb_edges = 2 * nb_locations + (nb_time_steps - 1) * (nb_locations * nb_locations); - int source = 0; - int sink = nb_vertices - 1; - - cout << nb_vertices << " " << nb_edges << endl; - cout << source << " " << sink << endl; - cout << endl; - - for(int l = 0; l < nb_locations; l++) { - cout << source - << " " - << l + 1 - << " " - << drand48() * 2 - 1 - << endl; - } - - for(int t = 0; t < nb_time_steps - 1; t++) { - for(int l = 0; l < nb_locations; l++) { - for(int m = 0; m < nb_locations; m++) { - cout << 1 + (t * nb_locations + l) - << " " - << 1 + ((t+1) * nb_locations + m) - << " " - << drand48() * 2 - 1 - << endl; - } - } - } - - for(int l = 0; l < nb_locations; l++) { - cout << 1 + ((nb_time_steps-1) * nb_locations + l) - << " " - << sink - << " " - << drand48() * 2 - 1 - << endl; - } -}