Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Added the weight model improvements to lagrange models.
[simgrid.git] / src / surf / network.c
index 7acfc6f..fd42c0c 100644 (file)
@@ -18,6 +18,10 @@ static void (*network_solve) (lmm_system_t) = NULL;
 xbt_dict_t link_set = NULL;
 xbt_dict_t network_card_set = NULL;
 
+double latency_factor = 1.0; /* default value */
+double bandwidth_factor = 1.0; /* default value */
+double weight_S_parameter = 0.0; /* default value */
+
 int card_number = 0;
 int host_number = 0;
 link_CM02_t **routing_table = NULL;
@@ -70,7 +74,7 @@ static link_CM02_t link_new(char *name,
 
   nw_link->constraint =
       lmm_constraint_new(network_maxmin_system, nw_link,
-                        nw_link->bw_current);
+                        bandwidth_factor*nw_link->bw_current);
 
   if (policy == SURF_LINK_FATPIPE)
     lmm_constraint_shared(nw_link->constraint);
@@ -400,7 +404,7 @@ static void update_actions_state(double now, double delta)
       }
       if ((action->latency == 0.0) && !(action->suspended))
        lmm_update_variable_weight(network_maxmin_system, action->variable,
-                                  action->lat_current);
+                                  action->weight);
     }
     double_update(&(action->generic_action.remains),
                  lmm_variable_getvalue(action->variable) * deltap);
@@ -431,9 +435,24 @@ static void update_resource_state(void *id,
   /*     value, event_type); */
 
   if (event_type == nw_link->bw_event) {
+    double delta = weight_S_parameter/value - weight_S_parameter/nw_link->bw_current;
+    lmm_variable_t var = NULL;
+    lmm_element_t elem = NULL;
+    surf_action_network_CM02_t action = NULL;
+
     nw_link->bw_current = value;
     lmm_update_constraint_bound(network_maxmin_system, nw_link->constraint,
-                               nw_link->bw_current);
+                               bandwidth_factor*nw_link->bw_current);
+    if(weight_S_parameter>0) {
+      while ((var= lmm_get_var_from_cnst
+             (network_maxmin_system, nw_link->constraint, &elem))) {
+       action = lmm_variable_id(var);
+       action->weight += delta;
+       if (!(action->suspended))
+         lmm_update_variable_weight(network_maxmin_system, action->variable,
+                                    action->weight);
+      }
+    }
   } else if (event_type == nw_link->lat_event) {
     double delta = value - nw_link->lat_current;
     lmm_variable_t var = NULL;
@@ -445,6 +464,7 @@ static void update_resource_state(void *id,
           (network_maxmin_system, nw_link->constraint, &elem))) {
       action = lmm_variable_id(var);
       action->lat_current += delta;
+      action->weight += delta;
       if (action->rate < 0)
        lmm_update_variable_bound(network_maxmin_system, action->variable,
                                  SG_TCP_CTE_GAMMA / (2.0 *
@@ -458,7 +478,7 @@ static void update_resource_state(void *id,
                                                          lat_current)));
       if (!(action->suspended))
        lmm_update_variable_weight(network_maxmin_system, action->variable,
-                                  action->lat_current);
+                                  action->weight);
 
     }
   } else if (event_type == nw_link->state_event) {
@@ -536,11 +556,15 @@ static surf_action_t communicate(void *src, void *dst, double size,
   action->rate = rate;
 
   action->latency = 0.0;
-  for (i = 0; i < route_size; i++)
+  action->weight = 0.0;
+  for (i = 0; i < route_size; i++) {
     action->latency += route[i]->lat_current;
+    action->weight += route[i]->lat_current + weight_S_parameter/route[i]->bw_current;
+  }
   /* LARGE PLATFORMS HACK:
      Add src->link and dst->link latencies */
   action->lat_current = action->latency;
+  action->latency *= latency_factor;
 
   /* LARGE PLATFORMS HACK:
      lmm_variable_new(..., total_route_size)*/
@@ -639,7 +663,7 @@ static void action_resume(surf_action_t action)
                               ((surf_action_network_CM02_t) action)->
                               variable,
                               ((surf_action_network_CM02_t) action)->
-                              lat_current);
+                              weight);
     ((surf_action_network_CM02_t) action)->suspended = 0;
   }
 }
@@ -763,11 +787,12 @@ static void surf_network_model_init_internal(void)
     network_maxmin_system = lmm_system_new();
 }
 
-/***************************************************************************/
-/* New TCP sharing model based on thesis experimantation and discussions.  */
-/***************************************************************************/
+/************************************************************************/
+/* New model based on optimizations discussed during this thesis        */
+/************************************************************************/
 void surf_network_model_init_LegrandVelho(const char *filename)
 {
+
   if (surf_network_model)
     return;
   surf_network_model_init_internal();
@@ -775,10 +800,13 @@ void surf_network_model_init_LegrandVelho(const char *filename)
   xbt_dynar_push(model_list, &surf_network_model);
   network_solve = lmm_solve;
 
+  latency_factor = 10.4;
+  bandwidth_factor = 0.92;
+  weight_S_parameter = 8775;
+
   update_model_description(surf_network_model_description,
                           "LegrandVelho",
                           (surf_model_t) surf_network_model);
-  INFO0("LegrandVelho Model was chosen!!");
 }
 
 /***************************************************************************/
@@ -819,6 +847,10 @@ void surf_network_model_init_Reno(const char *filename)
                                    func_reno_fpi);
   network_solve = lagrange_solve;
 
+  latency_factor = 10.4;
+  bandwidth_factor = 0.92;
+  weight_S_parameter = 8775;
+
   update_model_description(surf_network_model_description,
                           "Reno",
                           (surf_model_t) surf_network_model);
@@ -837,6 +869,10 @@ void surf_network_model_init_Reno2(const char *filename)
                                    func_reno2_fpi);
   network_solve = lagrange_solve;
 
+  latency_factor = 10.4;
+  bandwidth_factor = 0.92;
+  weight_S_parameter = 8775;
+
   update_model_description(surf_network_model_description,
                           "Reno2",
                           (surf_model_t) surf_network_model);
@@ -854,6 +890,10 @@ void surf_network_model_init_Vegas(const char *filename)
                                    func_vegas_fpi);
   network_solve = lagrange_solve;
 
+  latency_factor = 10.4;
+  bandwidth_factor = 0.92;
+  weight_S_parameter = 8775;
+
   update_model_description(surf_network_model_description,
                           "Vegas",
                           (surf_model_t) surf_network_model);