Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Let's trust the mathematics here: sqrt + fabs + fabs IS positive or nul :)
[simgrid.git] / src / surf / surf_routing_vivaldi.c
index bffcb4f..fe92bb4 100644 (file)
@@ -26,6 +26,7 @@ static double euclidean_dist_comp(int index, xbt_dynar_t src, xbt_dynar_t dst)
 {
        double src_coord, dst_coord;
 
 {
        double src_coord, dst_coord;
 
+       // FIXME converting from string to float each time we need a coordinate is ... suboptimal
        src_coord = atof(xbt_dynar_get_as(src, index, char *));
        dst_coord = atof(xbt_dynar_get_as(dst, index, char *));
 
        src_coord = atof(xbt_dynar_get_as(src, index, char *));
        dst_coord = atof(xbt_dynar_get_as(dst, index, char *));
 
@@ -48,13 +49,11 @@ static double base_vivaldi_get_latency (const char *src, const char *dst)
   euclidean_dist = sqrt (euclidean_dist_comp(0,src_ctn,dst_ctn)+euclidean_dist_comp(1,src_ctn,dst_ctn))
                                 + fabs(atof(xbt_dynar_get_as(src_ctn, 2, char *)))+fabs(atof(xbt_dynar_get_as(dst_ctn, 2, char *)));
 
   euclidean_dist = sqrt (euclidean_dist_comp(0,src_ctn,dst_ctn)+euclidean_dist_comp(1,src_ctn,dst_ctn))
                                 + fabs(atof(xbt_dynar_get_as(src_ctn, 2, char *)))+fabs(atof(xbt_dynar_get_as(dst_ctn, 2, char *)));
 
-  xbt_assert(euclidean_dist>=0, "Euclidean Dist is less than 0\"%s\" and \"%.2f\"", src, euclidean_dist);
-
   //From .ms to .s
   return euclidean_dist / 1000;
 }
 
   //From .ms to .s
   return euclidean_dist / 1000;
 }
 
-static double vivaldi_get_link_latency (AS_t rc,const char *src, const char *dst, route_t e_route)
+static double vivaldi_get_latency (AS_t rc,const char *src, const char *dst, route_t e_route)
 {
   if(routing_get_network_element_type(src) == SURF_NETWORK_ELEMENT_AS) {
          int need_to_clean = e_route?0:1;
 {
   if(routing_get_network_element_type(src) == SURF_NETWORK_ELEMENT_AS) {
          int need_to_clean = e_route?0:1;
@@ -73,6 +72,6 @@ AS_t model_vivaldi_create(void)
 {
          AS_t new_component = model_rulebased_create();
          new_component->get_route = vivaldi_get_route;
 {
          AS_t new_component = model_rulebased_create();
          new_component->get_route = vivaldi_get_route;
-         new_component->get_latency = vivaldi_get_link_latency;
+         new_component->get_latency = vivaldi_get_latency;
          return new_component;
 }
          return new_component;
 }