- listLessLoadedNeighbors.clear();
- for(i=0;i<size;++i) {
- S[i]=0.0;
- if( pneigh[i]->get_load()< lessLoad )
- listLessLoadedNeighbors.push_back(i);
- }
- int nbLessLoadedNeighbors=listLessLoadedNeighbors.size();
- for( i=0; i<listLessLoadedNeighbors.size(); ++i) {
- double delta = (myLoad-pneigh[listLessLoadedNeighbors[i]]->get_load())/(nbLessLoadedNeighbors+1);
- if(myLoad-delta > pneigh[listLessLoadedNeighbors[i]]->get_load()) {
- S[i]=delta;
- myLoad-=delta;
- }
- }
- for(i=0; i<size; ++i) {
- send(pneigh[i], S[i]);
- XBT_DEBUG("sent to %s", pneigh[i]->get_name());
- }
- delete[] S;
+ listLessLoadedNeighbors.clear();
+ for (i = 0; i < size; ++i) {
+ S[i] = 0.0;
+ if (pneigh[i]->get_load() < lessLoad)
+ listLessLoadedNeighbors.push_back(i);
+ }
+ int nbLessLoadedNeighbors = listLessLoadedNeighbors.size();
+ for (i = 0; i < listLessLoadedNeighbors.size(); ++i) {
+ double delta =
+ (myLoad - pneigh[listLessLoadedNeighbors[i]]->get_load()) /
+ (nbLessLoadedNeighbors + 1);
+ if (myLoad - delta > pneigh[listLessLoadedNeighbors[i]]->get_load()) {
+ S[i] = delta;
+ myLoad -= delta;
+ }
+ }
+ for (i = 0; i < size; ++i) {
+ send(pneigh[i], S[i]);
+ XBT_DEBUG("sent to %s", pneigh[i]->get_name());
+ }
+ delete[] S;