Permalink
Browse files

Reverted the bad commit c258432

  • Loading branch information...
1 parent 521c151 commit 01dec404fb948258f3deb9d7d5c45cd120652c5d @Tristramg Tristramg committed May 18, 2010
Showing with 92 additions and 347 deletions.
  1. +2 −5 ch/Makefile
  2. +4 −30 ch/bench.cc
  3. +0 −1 ch/graph.h
  4. +7 −8 ch/main.cc
  5. +1 −60 ch/query.cc
  6. +0 −1 ch/query.h
  7. +5 −3 lib/CMakeLists.txt
  8. +9 −0 lib/README.CONFIG.txt
  9. +9 −17 lib/benchmark.py
  10. +33 −175 lib/graph_wrapper.cpp
  11. +1 −8 lib/graph_wrapper.h
  12. +15 −23 lib/layer.py
  13. +0 −1 lib/martins.cpp
  14. +1 −1 lib/martins.h
  15. +4 −14 lib/martins_impl.h
  16. +1 −0 lib/tsaggouris.cpp
View
@@ -1,5 +1,5 @@
-ch: main.o bench.o test.o dijkstra.o contraction.o query.o tsaggouris.o
- g++ -o ch main.o bench.o test.o dijkstra.o contraction.o query.o tsaggouris.o -lpqxx -Wall -lboost_serialization
+ch: main.o bench.o test.o dijkstra.o contraction.o query.o
+ g++ -o ch main.o bench.o test.o dijkstra.o contraction.o query.o -lpqxx -Wall -lboost_serialization
main.o: main.cc
g++ -O3 -Wall -o main.o -c main.cc
@@ -16,8 +16,5 @@ dijkstra.o: dijkstra.cc
contraction.o: contraction.cc
g++ -O3 -Wall -o contraction.o -c contraction.cc
-tsaggouris.o: tsaggouris.cc
- g++ -O3 -Wall -o tsaggouris.o -c tsaggouris.cc
-
query.o: query.cc
g++ -O3 -Wall -o query.o -c query.cc
View
@@ -1,6 +1,6 @@
#include "dijkstra.h"
#include "query.h"
-#include "tsaggouris.h"
+
#include <boost/graph/dijkstra_shortest_paths.hpp>
struct found_goal{};
@@ -58,14 +58,14 @@ void bench(Graph & g, Graph & gc)
boost::progress_timer t;
for(int i=0; i < runs; i++)
{
- query_mono(starts[i], dests[i], gc.graph);
+ //query_mono(starts[i], dests[i], gc.graph);
}
}
}
void martins_bench(Graph & g, Graph & gc)
{
- int runs = 100;
+ int runs = 10;
std::vector<int> starts(runs);
std::vector<int> dests(runs);
for(int i=0; i < runs; i++)
@@ -77,7 +77,7 @@ void martins_bench(Graph & g, Graph & gc)
boost::progress_timer t;
for(int i=0; i < runs; i++)
{
- martins(starts[i], dests[i], g);
+ //martins(starts[i], dests[i], g);
}
}
@@ -90,29 +90,3 @@ void martins_bench(Graph & g, Graph & gc)
}
}
-
-void tsaggouris_bench(Graph & g)
-{
- int runs = 10;
- std::vector<int> starts(runs);
- for(int i=0; i < runs; i++)
- {
- starts[i] = rand() % boost::num_vertices(g.graph);
- }
- {
- boost::progress_timer t;
- for(int i=0; i < runs; i++)
- {
- martins_all(starts[i], g);
- }
- }
-
- {
- boost::progress_timer t;
- for(int i=0; i < runs; i++)
- {
- ssmosp(g, starts[i]);
- }
- }
-
-}
View
@@ -79,7 +79,6 @@ struct Graph
typedef boost::adjacency_list<boost::listS, boost::vecS, boost::bidirectionalS, Node, Edge > Type;
typedef boost::graph_traits<Type>::edge_descriptor edge_t;
typedef boost::graph_traits<Type>::vertex_descriptor node_t;
- typedef boost::graph_traits<Type>::edge_iterator edge_iterator;
struct inc_order
{
View
@@ -8,7 +8,6 @@
void bench(Graph & g, Graph & gc);
void martins_bench(Graph & g, Graph & gc);
-void tsaggouris_bench(Graph & g);
void test(Graph & g, Graph & gc);
float secu(int cat, int length)
{
@@ -26,7 +25,7 @@ float secu(int cat, int length)
int main(int, char** argv)
{
- /* Graph g;
+/* Graph g;
std::map<int, int> map;
pqxx::connection Conn("dbname=mumoro");
@@ -56,12 +55,12 @@ int main(int, char** argv)
g.add_edge(map[source], map[destination], edge_prop);
// g.add_edge(map[destination], map[source], edge_prop);
++show_progress;
- }
- g.save("paris_original");
+ }*/
+/* g.save("paris_original");
Graph gc(g);
gc.contract();
- gc.save("paris_ch");*/
-
+ gc.save("paris_ch");
+ */
// 51937 nodes
// 619894 edges
@@ -75,7 +74,7 @@ int main(int, char** argv)
// 619894 edges
Graph g("paris_original");
- //Graph gc("paris_ch");
+ Graph gc("paris_ch");
/* gc.split();
gc.save("paris_ch");*/
// Graph gc(g);
@@ -86,7 +85,7 @@ int main(int, char** argv)
//test(g,gc);
// bench(g, gc);
- tsaggouris_bench(g);
+ martins_bench(g, gc);
}
View
@@ -157,65 +157,6 @@ bool martins(Graph::node_t start_node, Graph::node_t dest_node, const Graph & g)
return false;
}
-// Algo de martins sur le graphe normal, vers tous les nœuds
-bool martins_all(Graph::node_t start_node, const Graph & g)
-{
- my_queue::Type Q;
- std::vector< std::deque<Label> > P(num_vertices(g.graph));
-
- Label start;
- start.node = start_node;
- for(int i=0; i < Graph::objectives; i++)
- start.cost[i] = 0;
-
- Q.insert(start);
- const my_queue::by_cost cost_q_it = Q.get<0>();
- const my_queue::by_nodes node_q = Q.get<1>();
-
- int visited = 0;
- while( !Q.empty() )
- {
- Label l = *(cost_q_it.begin());
- visited++;
- P[l.node].push_back(l);
- // std::cout << "Label! node=" << l.node << " [" << l.cost[0] << "," << l.cost[1] << "]" << std::endl;
- Q.erase(cost_q_it.begin());
- BOOST_FOREACH(Graph::edge_t e, out_edges(l.node, g.graph))
- {
- Label l2;
- l2.node = boost::target(e, g.graph);
- for(int i=0; i < Graph::objectives; i++)
- l2.cost[i] = l.cost[i] + g[e].cost[i];
-
- if(!is_dominated_by_any(node_q.equal_range(l2.node), l2) && !is_dominated_by_any(P[l2.node],l2) )
- {
- my_queue::nodes_it it, end;
- tie(it, end) = node_q.equal_range(l2.node);
- while(it != end)
- {
- if(Graph::dominates(l2.cost, it->cost) || l2.cost == it->cost)
- it = Q.get<1>().erase(it);
- else
- {
- it++;
- }
- }
- Q.insert(l2);
- }
- }
- }
-
- size_t total = 0;
- for(int n = 0; n<boost::num_vertices(g.graph); n++)
- {
- total += P[n].size();
- }
-
- std::cout << "Number of elements found " << total << std::endl;
- return false;
-}
-
-
// Algo de martins dans un graphe CH
// On maintient une liste de couts réalisables trouvés
// À la création d'un nouveau label, on vérifie qu'il n'est pas dominé par aucun label des couts réalisables
@@ -256,7 +197,7 @@ bool ch_martins(Graph::node_t start_node, Graph::node_t dest_node, const Graph &
Q1.insert(start);
Q2.insert(dest);
- while(!Q1.empty() || !Q2.empty())
+ while(!Q1.empty() && !Q2.empty())
{
if(!Q1.empty())
{
View
@@ -29,7 +29,6 @@ struct Path
std::list<Path> query(Graph::node_t source, Graph::node_t target, const Graph::Type & graph);
bool martins(Graph::node_t start_node, Graph::node_t dest_node, const Graph & g);
-bool martins_all(Graph::node_t start_node, const Graph & g);
bool ch_martins(Graph::node_t start_node, Graph::node_t dest_node, const Graph & g);
bool martins_witness(Graph::node_t start_node, Graph::node_t dest_node, Graph::cost_t cost, const Graph::Type & g);
#endif
View
@@ -2,17 +2,19 @@ CMAKE_MINimum_required(VERSION 2.6)
SET( CMAKE_BUILD_TYPE DEBUG )
+FIND_LIBRARY(PQXX pqxx /opt/local/lib)
+
find_package(Boost COMPONENTS graph REQUIRED)
FIND_PACKAGE(PythonLibs REQUIRED)
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})
include_directories(${Boost_INCLUDE_DIRS})
-ADD_DEFINITIONS( -O3 -Wall -fPIC -Wno-deprecated)
+ADD_DEFINITIONS( -O3 -Wall -Wno-deprecated)
-ADD_LIBRARY(mum_lib martins.cpp graph_wrapper.cpp)
-TARGET_LINK_LIBRARIES(mum_lib)
+ADD_LIBRARY(mum_lib martins.cpp tsaggouris.cpp graph_wrapper.cpp)
+TARGET_LINK_LIBRARIES(mum_lib ${PQXX})
#ADD_EXECUTABLE(mum_test main.cpp )
#TARGET_LINK_LIBRARIES(mum_test mum_lib)
@@ -0,0 +1,9 @@
+Delete first line, replace values and save file as config.cfg
+[DBSettings]
+DBName: mumoroRE
+DBUser: root
+DBPassword: test
+DBHost: localhost
+DBTableNodes: nodes
+DBTableEdges: edges
+
View
@@ -3,9 +3,9 @@
import time
import random
-foot = layer.Layer('foot', mumoro.Foot, {'nodes': 'sf_nodes_ch4', 'edges': 'sf_edges_ch4'})
-bike = layer.Layer('bike', mumoro.Bike, {'nodes': 'sf_nodes_ch4', 'edges': 'sf_edges_ch4'})
-pt = layer.GTFSLayer('muni', 'pt2')
+foot = layer.Layer('foot', mumoro.Foot, {'nodes': 'sf_nodes', 'edges': 'sf_edges'})
+bike = layer.Layer('bike', mumoro.Bike, {'nodes': 'sf_nodes', 'edges': 'sf_edges'})
+pt = layer.GTFSLayer('muni', 'pt')
g = layer.MultimodalGraph([foot, pt, bike])
e = mumoro.Edge()
@@ -17,22 +17,17 @@
g.connect_nearest_nodes(pt, foot, e, e2)
g.connect_nearest_nodes(bike, foot, e)
-#g.connect_nearest_nodes(bike, pt, e)
random.seed(time.clock())
found = 0
comp = []
-runs = 2
-
-found = 0
+runs = 10
for x in range(runs):
s = random.randint(0, bike.count - 1) + bike.offset
t = random.randint(0, foot.count - 1)
comp.append((s,t))
-
-
found = 0
start = time.clock()
for (s,t) in comp:
@@ -45,11 +40,7 @@
p = mumoro.relaxed_martins(s, t, g.graph, 30000, mumoro.mode_change, 120)
efound += len(p)
eend = time.clock()
-fstart = time.clock()
-for (s,t) in comp:
- p = mumoro.relaxed_martins(s, -1, g.graph, 30000, mumoro.mode_change, 120)
-fend = time.clock()
-print "\"t + ms\" {0} {1} {2} {3} ".format(float(found)/runs, float(end - start) * 1000 / runs, float(efound)/runs, float(eend - estart) * 1000 / runs)
+print "t + ms & {0} & {1} & {2} & {3}".format(float(found)/runs, float(end - start) * 1000 / runs, float(efound)/runs, float(eend - estart) * 1000 / runs)
found = 0
@@ -64,7 +55,7 @@
p = mumoro.relaxed_martins(s, t, g.graph, 30000, mumoro.mode_change, 120, mumoro.line_change, 60)
efound += len(p)
eend = time.clock()
-print "\"t + ms + ls\" {0} {1} {2} {3}".format(float(found)/runs, float(end - start) * 1000 / runs, float(efound)/runs, float(eend - estart) * 1000 / runs)
+print "t + ms + ls & {0} & {1} & {2} & {3}".format(float(found)/runs, float(end - start) * 1000 / runs, float(efound)/runs, float(eend - estart) * 1000 / runs)
found = 0
@@ -79,7 +70,7 @@
p = mumoro.relaxed_martins(s, t, g.graph, 30000, mumoro.elevation, 10)
efound += len(p)
eend = time.clock()
-print "\"t + a\" {0} {1} {2} {3}".format(float(found)/runs, float(end - start) * 1000 / runs, float(efound)/runs, float(eend - estart) * 1000 / runs)
+print "t + a & {0} & {1} & {2} & {3}".format(float(found)/runs, float(end - start) * 1000 / runs, float(efound)/runs, float(eend - estart) * 1000 / runs)
found = 0
@@ -94,6 +85,7 @@
p = mumoro.relaxed_martins(s, t, g.graph, 30000, mumoro.elevation, 10, mumoro.line_change, 60, mumoro.mode_change, 120)
efound += len(p)
eend = time.clock()
-print "\"t + a + ms + ls\" {0} {1} {2} {3}".format(float(found)/runs, float(end - start) * 1000 / runs, float(efound)/runs, float(eend - estart) * 1000 / runs)
+print "t + a + ms + ls& {0} & {1} & {2} & {3}".format(float(found)/runs, float(end - start) * 1000 / runs, float(efound)/runs, float(eend - estart) * 1000 / runs)
+
Oops, something went wrong.

0 comments on commit 01dec40

Please sign in to comment.