-void NetworkIBModel::updateIBfactors(NetworkActionPtr action, IBNode *from, IBNode * to, int remove) {
- if (from == to)//disregard local comms (should use loopback)
- return;
-
- bool* updated=(bool*)xbt_malloc0(xbt_dict_size(active_nodes)*sizeof(bool));
- ActiveComm* comm=NULL;
- if(remove){
- if(to->ActiveCommsDown[from]==1)
- to->ActiveCommsDown.erase(from);
- else
- to->ActiveCommsDown[from]-=1;
-
- to->nbActiveCommsDown--;
- for (std::vector<ActiveComm*>::iterator it= from->ActiveCommsUp.begin();
- it != from->ActiveCommsUp.end(); ++it) {
- if((*it)->action==action){
- comm=(*it);
- from->ActiveCommsUp.erase(it);
- break;
+ for (std::vector<ActiveComm*>::iterator it= root->ActiveCommsUp.begin(); it != root->ActiveCommsUp.end(); ++it) {
+
+ //compute inbound penalty
+ double my_penalty_in = 1.0;
+ int nb_comms = (*it)->destination->nbActiveCommsDown;//total number of incoming comms
+ if(nb_comms!=1)
+ my_penalty_in = ((*it)->destination->ActiveCommsDown)[root] //number of comm sent to dest by root node
+ * Be
+ * (*it)->destination->ActiveCommsDown.size();//number of different nodes sending to dest
+
+ double penalty = std::max(my_penalty_in,max_penalty_out);
+
+ double rate_before_update = (*it)->action->getBound();
+ //save initial rate of the action
+ if((*it)->init_rate==-1)
+ (*it)->init_rate= rate_before_update;
+
+ penalized_bw= ! num_comm_out ? (*it)->init_rate : (*it)->init_rate /penalty;
+
+ if (!double_equals(penalized_bw, rate_before_update, sg_surf_precision)){
+ XBT_DEBUG("%d->%d action %p penalty updated : bw now %f, before %f , initial rate %f", root->id,(*it)->destination->id,(*it)->action,penalized_bw, (*it)->action->getBound(), (*it)->init_rate );
+ lmm_update_variable_bound(maxminSystem_, (*it)->action->getVariable(), penalized_bw);
+ }else{
+ XBT_DEBUG("%d->%d action %p penalty not updated : bw %f, initial rate %f", root->id,(*it)->destination->id,(*it)->action,penalized_bw, (*it)->init_rate );
+ }
+
+ }
+ XBT_DEBUG("Finished computing IB penalties");
+ }
+
+ void NetworkIBModel::updateIBfactors_rec(IBNode *root, bool* updatedlist) {
+ if(updatedlist[root->id]==0){
+ XBT_DEBUG("IB - Updating rec %d", root->id);
+ computeIBfactors(root);
+ updatedlist[root->id]=1;
+ for (std::vector<ActiveComm*>::iterator it= root->ActiveCommsUp.begin(); it != root->ActiveCommsUp.end(); ++it) {
+ if(updatedlist[(*it)->destination->id]!=1)
+ updateIBfactors_rec((*it)->destination, updatedlist);
+ }
+ for (std::map<IBNode*, int>::iterator it= root->ActiveCommsDown.begin(); it != root->ActiveCommsDown.end(); ++it) {
+ if(updatedlist[it->first->id]!=1)
+ updateIBfactors_rec(it->first, updatedlist);
+ }