X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/1d32796efe1be63d7a67b8718527fa03a32c4baa..4a2a591f2a153d202731c3d2e2a6739a3775ee0a:/src/surf/maxmin.c diff --git a/src/surf/maxmin.c b/src/surf/maxmin.c index e9f635de1c..feef80bb82 100644 --- a/src/surf/maxmin.c +++ b/src/surf/maxmin.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2004-2011. The SimGrid Team. +/* Copyright (c) 2004-2013. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -21,7 +21,7 @@ typedef struct s_dyn_light { int size; } s_dyn_light_t, *dyn_light_t; -double sg_maxmin_precision = 0.00001; +XBT_EXPORT_NO_IMPORT(double) sg_maxmin_precision = 0.00001; static void *lmm_variable_mallocator_new_f(void); static void lmm_variable_mallocator_free_f(void *var); @@ -32,6 +32,10 @@ static void lmm_remove_all_modified_set(lmm_system_t sys); static int Global_debug_id = 1; static int Global_const_debug_id = 1; +static void lmm_var_free(lmm_system_t sys, lmm_variable_t var); +static XBT_INLINE void lmm_cnst_free(lmm_system_t sys, + lmm_constraint_t cnst); + lmm_system_t lmm_system_new(int selective_update) { lmm_system_t l = NULL; @@ -385,7 +389,7 @@ static XBT_INLINE void saturated_constraint_set_update(double usage, } else if (*min_usage == usage) { if(saturated_constraint_set->pos == saturated_constraint_set->size) { // realloc the size saturated_constraint_set->size *= 2; - saturated_constraint_set->data = realloc(saturated_constraint_set->data, (saturated_constraint_set->size) * sizeof(int)); + saturated_constraint_set->data = xbt_realloc(saturated_constraint_set->data, (saturated_constraint_set->size) * sizeof(int)); } saturated_constraint_set->data[saturated_constraint_set->pos] = cnst_light_num; saturated_constraint_set->pos++; @@ -659,7 +663,6 @@ void lmm_solve(lmm_system_t sys) make_elem_inactive(elem); elem_list = &(cnst->element_set); xbt_swag_foreach(elem, elem_list) { -// make_elem_active(elem); if (elem->variable->weight <= 0 || elem->variable->value > 0) break; if (elem->value > 0) @@ -886,3 +889,30 @@ static void lmm_remove_all_modified_set(lmm_system_t sys) } xbt_swag_reset(&sys->modified_constraint_set); } + +/** + * Returns total resource load + * + * \param cnst the lmm_constraint_t associated to the resource + * + */ +double lmm_constraint_get_usage(lmm_constraint_t cnst) { + double usage = 0.0; + xbt_swag_t elem_list = &(cnst->element_set); + lmm_element_t elem = NULL; + + xbt_swag_foreach(elem, elem_list) { + /* 0-weighted elements (ie, sleep actions) are at the end of the swag and we don't want to consider them */ + if (elem->variable->weight <= 0) + break; + if ((elem->value > 0)) { + if (cnst->shared) + usage += elem->value * elem->variable->value; + else if (usage < elem->value * elem->variable->value) + usage = elem->value * elem->variable->value; + } + } + return usage; +} + +