From: Francois Fleuret Date: Mon, 20 Aug 2012 23:55:55 +0000 (-0700) Subject: Update. X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=commitdiff_plain;h=fdab6e3f90209ce026160717cc783784a11f125a;p=mtp.git Update. --- diff --git a/miniksp.cc b/miniksp.cc index c6e8354..360289f 100644 --- a/miniksp.cc +++ b/miniksp.cc @@ -56,6 +56,7 @@ void find_shortest(int nb_vertices, for(int e = 0; e < nb_edges; e++) { pred[e] = -1; + ASSERT(se[e] >= 0); } int nb_changes; @@ -83,13 +84,21 @@ void find_best_paths(int nb_vertices, raise_es(nb_edges, es); + scalar_t s; do { - find_shortest(nb_vertices, nb_edges, es, ea, eb, source, sink, dist, pred); + find_shortest(nb_vertices, nb_edges, es, ea, eb, source, sink, pred, dist); add_dpsi_es(nb_edges, es, ea, eb, dist); - for(int v = 0; v < nb_edges; v++) { - + s = 0.0; + for(int e = 0; e < nb_edges; e++) { + if(pred[eb[e]] == ea[e]) { + s += es[e]; + int k = eb[e]; + eb[e] = ea[e]; + ea[e] = k; + es[e] = - es[e]; + } } - } while(); + } while(s < 0); delete[] dist; delete[] pred; @@ -97,9 +106,17 @@ void find_best_paths(int nb_vertices, int main(int argc, char **argv) { int nb_time_steps = 4; - int nb_locations = 10; - int nb_neighbors = 3; + int nb_locations = 5; // Add the source and sink int nb_vertices = nb_time_steps * nb_locations + 2; - int nb_edges = nb_locations + (nb_time_steps - 1) * nb_locations + int nb_edges = nb_locations + (nb_time_steps - 1) * nb_locations * nb_locations + nb_locations; + int source = 0; + int sink = nb_locations - 1; + scalar_t *es = new scalar_t[nb_edges]; + int *ea = new int[nb_edges]; + int *eb = new int[nb_edges]; + + delete[] es; + delete[] ea; + delete[] eb; }