Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Don't call lmm_solve and correctly use latency in update_actions_state
[simgrid.git] / src / surf / network_constant.c
index 860f149..59fb081 100644 (file)
@@ -6,10 +6,12 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "surf_private.h"
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "surf_private.h"
+#include "network_common.h"
 #include "xbt/dict.h"
 #include "xbt/str.h"
 #include "xbt/log.h"
 
 #include "xbt/dict.h"
 #include "xbt/str.h"
 #include "xbt/log.h"
 
+#define CONSTANT_VALUE 1.0
 typedef struct network_card_Constant {
   char *name;
   int id;
 typedef struct network_card_Constant {
   char *name;
   int id;
@@ -47,8 +49,6 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_network);
 static lmm_system_t network_maxmin_system = NULL;
 static void (*network_solve) (lmm_system_t) = NULL;
 
 static lmm_system_t network_maxmin_system = NULL;
 static void (*network_solve) (lmm_system_t) = NULL;
 
-static xbt_dict_t network_card_set = NULL;
-
 static int card_number = 0;
 static int host_number = 0;
 static link_Constant_t **routing_table = NULL;
 static int card_number = 0;
 static int host_number = 0;
 static link_Constant_t **routing_table = NULL;
@@ -405,17 +405,10 @@ static void action_change_state(surf_action_t action,
 
 static double share_resources(double now)
 {
 
 static double share_resources(double now)
 {
-  s_surf_action_network_Constant_t s_action;
   surf_action_network_Constant_t action = NULL;
   xbt_swag_t running_actions =
       surf_network_model->common_public->states.running_action_set;
   surf_action_network_Constant_t action = NULL;
   xbt_swag_t running_actions =
       surf_network_model->common_public->states.running_action_set;
-  double min;
-
-  min = generic_maxmin_share_resources(running_actions,
-                                      xbt_swag_offset(s_action,
-                                                      variable),
-                                      network_maxmin_system,
-                                      network_solve);
+  double min = -1.0;
 
   xbt_swag_foreach(action, running_actions) {
     if (action->latency > 0) {
 
   xbt_swag_foreach(action, running_actions) {
     if (action->latency > 0) {
@@ -431,61 +424,32 @@ static double share_resources(double now)
 
 static void update_actions_state(double now, double delta)
 {
 
 static void update_actions_state(double now, double delta)
 {
-  double deltap = 0.0;
   surf_action_network_Constant_t action = NULL;
   surf_action_network_Constant_t next_action = NULL;
   xbt_swag_t running_actions =
       surf_network_model->common_public->states.running_action_set;
   surf_action_network_Constant_t action = NULL;
   surf_action_network_Constant_t next_action = NULL;
   xbt_swag_t running_actions =
       surf_network_model->common_public->states.running_action_set;
-  /*
-     xbt_swag_t failed_actions =
-     surf_network_model->common_public->states.failed_action_set;
-   */
 
   xbt_swag_foreach_safe(action, next_action, running_actions) {
 
   xbt_swag_foreach_safe(action, next_action, running_actions) {
-    deltap = delta;
     if (action->latency > 0) {
     if (action->latency > 0) {
-      if (action->latency > deltap) {
-       double_update(&(action->latency), deltap);
-       deltap = 0.0;
+      if (action->latency > delta) {
+       double_update(&(action->latency), delta);
       } else {
       } else {
-       double_update(&(deltap), action->latency);
        action->latency = 0.0;
       }
        action->latency = 0.0;
       }
-      if ((action->latency == 0.0) && !(action->suspended))
-       lmm_update_variable_weight(network_maxmin_system, action->variable,
-                                  action->lat_current);
     }
     double_update(&(action->generic_action.remains),
     }
     double_update(&(action->generic_action.remains),
-                 lmm_variable_getvalue(action->variable) * deltap);
+                 action->generic_action.cost * delta/ CONSTANT_VALUE);
     if (action->generic_action.max_duration != NO_MAX_DURATION)
       double_update(&(action->generic_action.max_duration), delta);
 
     if (action->generic_action.max_duration != NO_MAX_DURATION)
       double_update(&(action->generic_action.max_duration), delta);
 
-    /*   if(action->generic_action.remains<.00001) action->generic_action.remains=0; */
-
-    if ((action->generic_action.remains <= 0) &&
-       (lmm_get_variable_weight(action->variable) > 0)) {
+    if (action->generic_action.remains <= 0) {
       action->generic_action.finish = surf_get_clock();
       action_change_state((surf_action_t) action, SURF_ACTION_DONE);
     } else if ((action->generic_action.max_duration != NO_MAX_DURATION) &&
               (action->generic_action.max_duration <= 0)) {
       action->generic_action.finish = surf_get_clock();
       action_change_state((surf_action_t) action, SURF_ACTION_DONE);
       action->generic_action.finish = surf_get_clock();
       action_change_state((surf_action_t) action, SURF_ACTION_DONE);
     } else if ((action->generic_action.max_duration != NO_MAX_DURATION) &&
               (action->generic_action.max_duration <= 0)) {
       action->generic_action.finish = surf_get_clock();
       action_change_state((surf_action_t) action, SURF_ACTION_DONE);
-    } else {                   /* Need to check that none of the model has failed */
-      lmm_constraint_t cnst = NULL;
-      int i = 0;
-      link_Constant_t nw_link = NULL;
-
-      while ((cnst =
-             lmm_get_cnst_from_var(network_maxmin_system,
-                                   action->variable, i++))) {
-       nw_link = lmm_constraint_id(cnst);
-       if (nw_link->state_current == SURF_LINK_OFF) {
-         action->generic_action.finish = surf_get_clock();
-         action_change_state((surf_action_t) action, SURF_ACTION_FAILED);
-         break;
-       }
-      }
-    }
+    } 
   }
 
   return;
   }
 
   return;
@@ -570,7 +534,7 @@ static surf_action_t communicate(void *src, void *dst, double size,
   xbt_swag_insert(action, action->generic_action.state_set);
   action->rate = rate;
 
   xbt_swag_insert(action, action->generic_action.state_set);
   action->rate = rate;
 
-  action->latency = 1.0;
+  action->latency = CONSTANT_VALUE;
   action->lat_current = action->latency;
 
   XBT_OUT;
   action->lat_current = action->latency;
 
   XBT_OUT;