1 Makhoul's algorithm... several versions for source code...
2 ==========================================================
4 powwow:/home/makhoul# find . -name Fusion.cc -exec md5sum {} +
5 powwow:/home/makhoul# find . -name Fusion.cc -ls
8 238d74aac45bec21460e151295598764 ./Desktop/A.Makhoul/DiffusOMNET/Fusion.cc
10 5541828 8 -rw-r--r-- 1 makhoul and 6631 mai 14 2007 ./Desktop/A.Makhoul/DiffusOMNET/Fusion.cc
12 | void BRITENode::updateLoad(){
14 | double deltaSum = 0.;
15 | double deltaMin = this->load;
16 | for (int i = 0; i < gateSize("out"); i++) {
17 | double delta1 = this->load - neighborsLoad[i];
18 | if (delta1 > epsilonDelta) {
21 | if (deltaMin > delta1)
26 | double alpha = deltaMin / (deltaMin + deltaSum);
27 | for (int i = 0; i < gateSize("out"); i++) {
28 | double transfer = alpha * delta[i];
29 | totalSend[i] += transfer;
30 | this->load -= transfer;
37 8f5c3e7c5358626bc06726d888d912af ./Desktop/A.Makhoul/Abdallah-Makhoul/Recherche/Diffus-OMNET/Fusion.cc
38 8f5c3e7c5358626bc06726d888d912af ./Desktop/AbdallahMakhoul/Recherche/Diffus-OMNET/Fusion.cc
40 5540991 8 -rw-r--r-- 1 makhoul and 8001 juin 12 2007 ./Desktop/A.Makhoul/Abdallah-Makhoul/Recherche/Diffus-OMNET/Fusion.cc
41 6497742 8 -rw-r--r-- 1 makhoul and 8001 juin 12 2007 ./Desktop/AbdallahMakhoul/Recherche/Diffus-OMNET/Fusion.cc
43 | void BRITENode::updateLoad(){
45 | double deltaSum = 0.;
46 | double deltaMin = this->load;
47 | for (int i = 0; i < gateSize("out"); i++) {
48 | double delta1 = this->load - neighborsLoad[i];
49 | if (delta1 > epsilonDelta) {
52 | if (deltaMin > delta1)
57 | double alpha = deltaMin / (deltaMin + deltaSum);
58 | for (int i = 0; i < gateSize("out"); i++) {
59 | double transfer = alpha * delta[i];
60 | totalSend[i] += transfer;
61 | this->load -= transfer;
68 d0b4ef1a4553ff1c9c408390818cf925 ./FusionOmnet/Fusion.cc
70 5516053 12 -rw-r--r-- 1 makhoul and 9732 juil. 13 2007 ./FusionOmnet/Fusion.cc
72 | void BRITENode::updateLoad(){
74 | const double alpha = 1.0 / (gateSize("out") + 1);
75 | const double epsilon = 1.0e-4;
78 | for (int i = 0; i < gateSize("out"); i++) {
79 | double d = this->load - neighborsLoad[i];
81 | Delta[nDelta].delta = d;
82 | Delta[nDelta].index = i;
87 | std::sort(Delta, Delta + nDelta, DeltaCompDec());
89 | double neighborLoadMax = 0.0; // maximum load of neighbors to which
90 | // something has been sent
91 | for (int i = 0; i < nDelta; i++) {
92 | int index = Delta[i].index;
93 | double delta = this->load - neighborsLoad[index];
94 | if (delta <= epsilon)
98 | delta = Delta[i].delta; // does not work well...
101 | double transfer = alpha * delta;
102 | double transferMax =
103 | std::min(this->load - neighborLoadMax,
104 | (this->load - neighborsLoad[index]) / 2.0);
106 | if (transfer > transferMax) // ping-pong violated?
107 | transfer = transferMax;
109 | totalSend[index] += transfer;
110 | this->load -= transfer;
112 | double newNeighborLoad = neighborsLoad[index] + transfer;
113 | if (newNeighborLoad > neighborLoadMax)
114 | neighborLoadMax = newNeighborLoad;
117 | // double transfer = alpha * Delta[i].delta;
118 | // if((this->load - totalSent) >= neighborsLoad[Delta[i].index] + transfer)
121 | // totalSend[i] += transfer;
122 | // this->load -= transfer;
123 | // totalSent+=transfer;
127 | // double deltaMax = 1.0e-3; // we consider only positive deltas
128 | // int iMax = -1; // invalid value
129 | // for (int i = 0; i < gateSize("out"); i++) {
130 | // Delta[i].delta = this->load - neighborsLoad[i];
131 | // if (Delta[i].delta > deltaMax) {
132 | // deltaMax = Delta[i].delta;
133 | // iMax = Delta[i].index;
137 | // if (iMax != -1) {
138 | // double transfer = alpha * Delta[iMax].delta;
139 | // totalSend[iMax] += transfer;
140 | // this->load -= transfer;
146 69f9baf76eb24e0e6cfa539d21c9b6f6 ./Bureau/Fusion.cc
147 69f9baf76eb24e0e6cfa539d21c9b6f6 ./Bureau/Simulations-Fusion-Omnet/Fusion.cc
148 69f9baf76eb24e0e6cfa539d21c9b6f6 ./Desktop/A.Makhoul/Abdallah-Makhoul/Recherche/Simulations-Fusion-Omnet/Fusion.cc
149 69f9baf76eb24e0e6cfa539d21c9b6f6 ./Desktop/AbdallahMakhoul/Recherche/Simulations-Fusion-Omnet/Fusion.cc
150 69f9baf76eb24e0e6cfa539d21c9b6f6 ./Simulations-Fusion-Omnet/Fusion.cc
152 5516032 12 -rw-r--r-- 1 makhoul and 11160 nov. 7 2008 ./Bureau/Fusion.cc
153 5524854 12 -rw-r--r-- 1 makhoul and 11160 nov. 7 2008 ./Bureau/Simulations-Fusion-Omnet/Fusion.cc
154 5541114 12 -rw-r--r-- 1 makhoul and 11160 nov. 28 2007 ./Desktop/A.Makhoul/Abdallah-Makhoul/Recherche/Simulations-Fusion-Omnet/Fusion.cc
155 6497957 12 -rw-r--r-- 1 makhoul and 11160 nov. 28 2007 ./Desktop/AbdallahMakhoul/Recherche/Simulations-Fusion-Omnet/Fusion.cc
156 5516082 12 -rw-r--r-- 1 makhoul and 11160 nov. 7 2008 ./Simulations-Fusion-Omnet/Fusion.cc
158 | void BRITENode::updateLoad(){
160 | const double alpha = 1.0 / (gateSize("out") + 1);
161 | const double epsilon = par("erreur");
164 | for (int i = 0; i < gateSize("out"); i++) {
165 | double d = this->load - neighborsLoad[i];
167 | Delta[nDelta].delta = d;
168 | Delta[nDelta].index = i;
173 | std::sort(Delta, Delta + nDelta, DeltaCompDec());
175 | double neighborLoadMax = 0.0; // maximum load of neighbors to which
176 | // something has been sent
177 | for (int i = 0; i < nDelta; i++) {
178 | int index = Delta[i].index;
179 | double delta = this->load - neighborsLoad[index];
180 | if (delta <= epsilon)
184 | delta = Delta[i].delta; // does not work well...
187 | double transfer = alpha * delta;
188 | double transferMax =
189 | std::min(this->load - neighborLoadMax,
190 | (this->load - neighborsLoad[index]) / 2.0);
192 | if (transfer > transferMax) // ping-pong violated?
193 | transfer = transferMax;
195 | totalSend[index] += transfer;
196 | this->load -= transfer;
198 | double newNeighborLoad = neighborsLoad[index] + transfer;
199 | if (newNeighborLoad > neighborLoadMax)
200 | neighborLoadMax = newNeighborLoad;
203 | // double transfer = alpha * Delta[i].delta;
204 | // if((this->load - totalSent) >= neighborsLoad[Delta[i].index] + transfer)
207 | // totalSend[i] += transfer;
208 | // this->load -= transfer;
209 | // totalSent+=transfer;
213 | // double deltaMax = 1.0e-3; // we consider only positive deltas
214 | // int iMax = -1; // invalid value
215 | // for (int i = 0; i < gateSize("out"); i++) {
216 | // Delta[i].delta = this->load - neighborsLoad[i];
217 | // if (Delta[i].delta > deltaMax) {
218 | // deltaMax = Delta[i].delta;
219 | // iMax = Delta[i].index;
223 | // if (iMax != -1) {
224 | // double transfer = alpha * Delta[iMax].delta;
225 | // totalSend[iMax] += transfer;
226 | // this->load -= transfer;