예제 #1
0
파일: maxmin.cpp 프로젝트: frs69wq/simgrid
static XBT_INLINE void lmm_variable_disable(lmm_system_t sys, lmm_variable_t var)
{
  int i;
  int n;

  lmm_element_t elem = NULL;

  XBT_IN("(sys=%p, var=%p)", sys, var);
  sys->modified = 1;

  n = 0;
  for (i = 0; i < var->cnsts_number; i++) {
    elem = &var->cnsts[i];
    xbt_swag_remove(elem, &(elem->constraint->element_set));
    xbt_swag_remove(elem, &(elem->constraint->active_element_set));
    if (!xbt_swag_size(&(elem->constraint->element_set)))
      make_constraint_inactive(sys, elem->constraint);
    else {
      if (n < i)
        var->cnsts[n].constraint = elem->constraint;
      n++;
    }
  }
  if (n) {
    var->cnsts_number = n;
    lmm_update_modified_set(sys, var->cnsts[0].constraint);
  }

  var->cnsts_number = 0;
  XBT_OUT();
}
예제 #2
0
파일: maxmin.cpp 프로젝트: frs69wq/simgrid
static XBT_INLINE void lmm_cnst_free(lmm_system_t sys,
                                     lmm_constraint_t cnst)
{
/*   xbt_assert(xbt_swag_size(&(cnst->element_set)), */
/*         "This list should be empty!"); */
  make_constraint_inactive(sys, cnst);
  free(cnst);
}
예제 #3
0
파일: maxmin.cpp 프로젝트: frs69wq/simgrid
void lmm_shrink(lmm_system_t sys, lmm_constraint_t cnst,
                lmm_variable_t var)
{
  lmm_element_t elem = NULL;
  int found = 0;

  int i;
  for (i = 0; i < var->cnsts_number; i++) {
    elem = &(var->cnsts[i]);
    if (elem->constraint == cnst) {
      found = 1;
      break;
    }
  }

  if (!found) {
    XBT_DEBUG("cnst %p is not found in var %p", cnst, var);
    return;
  }

  sys->modified = 1;

  XBT_DEBUG("remove elem(value %f, cnst %p, var %p) in var %p",
      elem->value, elem->constraint, elem->variable, var);



  /* We are going to change the constraint object and the variable object.
   * Propagate this change to other objects. Calling here (not after
   * modification) is correct? */
  lmm_update_modified_set(sys, cnst);
  lmm_update_modified_set(sys, var->cnsts[0].constraint); // will look up element_set of this constraint, and then each var in the element_set, and each var->cnsts[i].



  /* now var->cnsts[i] is not necessary any more */

  xbt_swag_remove(elem, &(elem->constraint->element_set));
  xbt_swag_remove(elem, &(elem->constraint->active_element_set));
  elem->constraint = NULL;
  elem->variable = NULL;
  elem->value = 0;



  /* We do not want to have an empty element entry before the last entry. So,
   * plug up the hole with the last one. */
  if (i < var->cnsts_number - 1)
    renew_elem_entry(&var->cnsts[i], &var->cnsts[var->cnsts_number - 1]);

  var->cnsts_number -= 1;


  if (xbt_swag_size(&(cnst->element_set)) == 0)
    make_constraint_inactive(sys, cnst);
}
예제 #4
0
void lmm_shrink(lmm_system_t sys, lmm_constraint_t cnst, lmm_variable_t var)
{
  lmm_element_t elem = NULL;
  int found = 0;

  int i;
  for (i = 0; i < var->cnsts_number; i++) {
    elem = &(var->cnsts[i]);
    if (elem->constraint == cnst) {
      found = 1;
      break;
    }
  }

  if (!found) {
    XBT_DEBUG("cnst %p is not found in var %p", cnst, var);
    return;
  }

  sys->modified = 1;

  XBT_DEBUG("remove elem(value %f, cnst %p, var %p) in var %p", elem->value, elem->constraint, elem->variable, var);

  /* We are going to change the constraint object and the variable object.
   * Propagate this change to other objects. Calling here before removing variable from not active elements
   * (inactive elements are not visited)
   */
  lmm_update_modified_set(sys, cnst);
  //Useful in case var was already removed from the constraint
  lmm_update_modified_set(sys, var->cnsts[0].constraint); // will look up enabled_element_set of this constraint, and
                                                     //then each var in the enabled_element_set, and each var->cnsts[i].

  if(xbt_swag_remove(elem, &(elem->constraint->enabled_element_set)))
    lmm_decrease_concurrency(elem);

  xbt_swag_remove(elem, &(elem->constraint->active_element_set));
  elem->constraint = NULL;
  elem->variable = NULL;
  elem->value = 0;

  var->cnsts_number -= 1;

  //No variable in this constraint -> make it inactive
  if (xbt_swag_size(&(cnst->enabled_element_set))+xbt_swag_size(&(cnst->disabled_element_set)) == 0)
    make_constraint_inactive(sys, cnst);
  else {
    //Check maxconcurrency to see if we can enable new variables
    lmm_on_disabled_var(sys,elem->constraint);       
  }

  lmm_check_concurrency(sys);
}
예제 #5
0
static inline void lmm_variable_remove(lmm_system_t sys, lmm_variable_t var)
{
  int i;
  int nelements;

  lmm_element_t elem = NULL;

  XBT_IN("(sys=%p, var=%p)", sys, var);
  sys->modified = 1;

  //TODOLATER Can do better than that by leaving only the variable in only one enabled_element_set, call
  //lmm_update_modified_set, and then remove it..
  if(var->cnsts_number)
    lmm_update_modified_set(sys, var->cnsts[0].constraint);

  for (i = 0; i < var->cnsts_number; i++) {
    elem = &var->cnsts[i];
    if(var->weight>0)
    lmm_decrease_concurrency(elem);
    xbt_swag_remove(elem, &(elem->constraint->enabled_element_set));
    xbt_swag_remove(elem, &(elem->constraint->disabled_element_set));
    xbt_swag_remove(elem, &(elem->constraint->active_element_set));
    nelements=xbt_swag_size(&(elem->constraint->enabled_element_set)) +
              xbt_swag_size(&(elem->constraint->disabled_element_set));
    if (!nelements)
      make_constraint_inactive(sys, elem->constraint);
    else
      lmm_on_disabled_var(sys,elem->constraint);
  }

  //Check if we can enable new variables going through the constraints where var was.
  //Do it after removing all elements, so he first disabled variables get priority over those with smaller requirement
  for (i = 0; i < var->cnsts_number; i++) {
    elem = &var->cnsts[i];
    if(xbt_swag_size(&(elem->constraint->disabled_element_set)))
      lmm_on_disabled_var(sys,elem->constraint);
  }

  var->cnsts_number = 0;

  lmm_check_concurrency(sys);

  XBT_OUT();
}
예제 #6
0
static inline void lmm_cnst_free(lmm_system_t sys, lmm_constraint_t cnst)
{
  make_constraint_inactive(sys, cnst);
  free(cnst);
}