Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
rename next_occuring_event() into nextOccuringEvent()
[simgrid.git] / src / surf / surf_interface.cpp
index 31cf110..66dad37 100644 (file)
@@ -393,18 +393,18 @@ Model::~Model(){
   delete doneActionSet_;
 }
 
-double Model::next_occuring_event(double now)
+double Model::nextOccuringEvent(double now)
 {
   //FIXME: set the good function once and for all
   if (updateMechanism_ == UM_LAZY)
-    return next_occuring_event_lazy(now);
+    return nextOccuringEventLazy(now);
   else if (updateMechanism_ == UM_FULL)
-    return next_occuring_event_full(now);
+    return nextOccuringEventFull(now);
   else
     xbt_die("Invalid cpu update mechanism!");
 }
 
-double Model::next_occuring_event_lazy(double now)
+double Model::nextOccuringEventLazy(double now)
 {
   XBT_DEBUG("Before share resources, the size of modified actions set is %zd", modifiedSet_->size());
   lmm_solve(maxminSystem_);
@@ -471,57 +471,24 @@ double Model::next_occuring_event_lazy(double now)
   }
 }
 
-double Model::next_occuring_event_full(double /*now*/) {
-  THROW_UNIMPLEMENTED;
-  return 0.0;
-}
+double Model::nextOccuringEventFull(double /*now*/) {
+  maxminSystem_->solve_fun(maxminSystem_);
 
-double Model::shareResourcesMaxMin(ActionList *running_actions,
-                          lmm_system_t sys,
-                          void (*solve) (lmm_system_t))
-{
-  Action *action = nullptr;
   double min = -1;
-  double value = -1;
-
-  solve(sys);
-
-  ActionList::iterator it(running_actions->begin()), itend(running_actions->end());
-  for(; it != itend ; ++it) {
-    action = &*it;
-    value = lmm_variable_getvalue(action->getVariable());
-    if ((value > 0) || (action->getMaxDuration() >= 0))
-      break;
-  }
-
-  if (!action)
-    return -1.0;
-
-  if (value > 0) {
-    if (action->getRemains() > 0)
-      min = action->getRemainsNoUpdate() / value;
-    else
-      min = 0.0;
-    if ((action->getMaxDuration() >= 0) && (action->getMaxDuration() < min))
-      min = action->getMaxDuration();
-  } else
-    min = action->getMaxDuration();
-
-
-  for (++it; it != itend; ++it) {
-  action = &*it;
-    value = lmm_variable_getvalue(action->getVariable());
+  for (auto it(getRunningActionSet()->begin()), itend(getRunningActionSet()->end()); it != itend ; ++it) {
+    Action *action = &*it;
+    double value = lmm_variable_getvalue(action->getVariable());
     if (value > 0) {
       if (action->getRemains() > 0)
         value = action->getRemainsNoUpdate() / value;
       else
         value = 0.0;
-      if (value < min) {
+      if (min < 0 || value < min) {
         min = value;
         XBT_DEBUG("Updating min (value) with %p: %f", action, min);
       }
     }
-    if ((action->getMaxDuration() >= 0) && (action->getMaxDuration() < min)) {
+    if ((action->getMaxDuration() >= 0) && (min<0 || action->getMaxDuration() < min)) {
       min = action->getMaxDuration();
       XBT_DEBUG("Updating min (duration) with %p: %f", action, min);
     }
@@ -534,11 +501,11 @@ double Model::shareResourcesMaxMin(ActionList *running_actions,
 void Model::updateActionsState(double now, double delta)
 {
   if (updateMechanism_ == UM_FULL)
-  updateActionsStateFull(now, delta);
+    updateActionsStateFull(now, delta);
   else if (updateMechanism_ == UM_LAZY)
-  updateActionsStateLazy(now, delta);
+    updateActionsStateLazy(now, delta);
   else
-  xbt_die("Invalid cpu update mechanism!");
+    xbt_die("Invalid cpu update mechanism!");
 }
 
 void Model::updateActionsStateLazy(double /*now*/, double /*delta*/)