+double Model::shareResourcesLazy(double now)
+{
+ ActionLmmPtr action = NULL;
+ double min = -1;
+ double value;
+
+ XBT_DEBUG
+ ("Before share resources, the size of modified actions set is %d",
+ xbt_swag_size(p_modifiedSet));
+
+ lmm_solve(p_maxminSystem);
+
+ XBT_DEBUG
+ ("After share resources, The size of modified actions set is %d",
+ xbt_swag_size(p_modifiedSet));
+
+ while((action = (ActionLmmPtr) xbt_swag_extract(p_modifiedSet))) {
+ int max_dur_flag = 0;
+
+ if (action->p_stateSet != p_runningActionSet)
+ continue;
+
+ /* bogus priority, skip it */
+ if (action->m_priority <= 0)
+ continue;
+
+ action->updateRemainingLazy(now);
+
+ min = -1;
+ value = lmm_variable_getvalue(action->p_variable);
+ if (value > 0) {
+ if (action->m_remains > 0) {
+ value = action->m_remains / value;
+ min = now + value;
+ } else {
+ value = 0.0;
+ min = now;
+ }
+ }
+
+ if ((action->m_maxDuration != NO_MAX_DURATION)
+ && (min == -1
+ || action->m_start +
+ action->m_maxDuration < min)) {
+ min = action->m_start +
+ action->m_maxDuration;
+ max_dur_flag = 1;
+ }
+
+ XBT_DEBUG("Action(%p) Start %lf Finish %lf Max_duration %lf", action,
+ action->m_start, now + value,
+ action->m_maxDuration);
+
+ if (min != -1) {
+ action->heapRemove(p_actionHeap);
+ action->heapInsert(p_actionHeap, min, max_dur_flag ? MAX_DURATION : NORMAL);
+ XBT_DEBUG("Insert at heap action(%p) min %lf now %lf", action, min,
+ now);
+ } else DIE_IMPOSSIBLE;
+ }
+
+ //hereafter must have already the min value for this resource model
+ if (xbt_heap_size(p_actionHeap) > 0)
+ min = xbt_heap_maxkey(p_actionHeap) - now;
+ else
+ min = -1;
+
+ XBT_DEBUG("The minimum with the HEAP %lf", min);
+
+ return min;
+}
+
+double Model::shareResourcesFull(xbt_swag_t running_actions,
+ size_t offset,
+ lmm_system_t sys,
+ void (*solve) (lmm_system_t))
+{
+ void *_action = NULL;
+ ActionPtr action = NULL;
+ double min = -1;
+ double value = -1;
+#define VARIABLE(action) (*((lmm_variable_t*)(((char *) (action)) + (offset))))
+
+ solve(sys);
+
+ xbt_swag_foreach(_action, running_actions) {
+ action = (ActionPtr)_action;
+ value = lmm_variable_getvalue(VARIABLE(action));
+ if ((value > 0) || (action->m_maxDuration >= 0))
+ break;
+ }
+
+ if (!action)
+ return -1.0;
+
+ if (value > 0) {
+ if (action->m_remains > 0)
+ min = action->m_remains / value;
+ else
+ min = 0.0;
+ if ((action->m_maxDuration >= 0) && (action->m_maxDuration < min))
+ min = action->m_maxDuration;
+ } else
+ min = action->m_maxDuration;
+
+
+ for (action = (ActionPtr) xbt_swag_getNext(action, running_actions->offset);
+ action;
+ action = (ActionPtr) xbt_swag_getNext(action, running_actions->offset)) {
+ value = lmm_variable_getvalue(VARIABLE(action));
+ if (value > 0) {
+ if (action->m_remains > 0)
+ value = action->m_remains / value;
+ else
+ value = 0.0;
+ if (value < min) {
+ min = value;
+ XBT_DEBUG("Updating min (value) with %p: %f", action, min);
+ }
+ }
+ if ((action->m_maxDuration >= 0) && (action->m_maxDuration < min)) {
+ min = action->m_maxDuration;
+ XBT_DEBUG("Updating min (duration) with %p: %f", action, min);
+ }
+ }
+ XBT_DEBUG("min value : %f", min);
+
+#undef VARIABLE
+ return min;
+}
+
+void Model::gapRemove(ActionLmmPtr action) {}
+
+
+void Model::updateActionsStateLazy(double now, double delta)
+{
+
+}
+
+void Model::updateActionsStateFull(double now, double delta)
+{
+
+}
+
+