m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMagdalena Grodzińska <mag.grodzinska@gmail.com>2020-01-11 10:56:26 +0100
committerMagdalena Grodzińska <mag.grodzinska@gmail.com>2020-01-11 10:56:26 +0100
commit36da6a754624f93e555bcaba8b3d0cdc28c17a0b (patch)
tree9f6665ffa612ce8ea7cf587fa375707ba1b57632 /src
parentea35ef1c86401257d82daf978d5870285f7c163e (diff)
Make exp increases in good direction
Diffstat (limited to 'src')
-rw-r--r--src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlStrategies.java13
-rw-r--r--src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlStrategyTest.java1
2 files changed, 7 insertions, 7 deletions
diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlStrategies.java b/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlStrategies.java
index 4cd534e..79efe39 100644
--- a/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlStrategies.java
+++ b/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlStrategies.java
@@ -34,7 +34,6 @@ public class GossipGirlStrategies {
ArrayList<Pair<String, Double>> zoneProbabilities;
zoneProbabilities = new ArrayList<>(fullPathLength);
- // TODO check if we decrease in good direction
for (int i = 0; i < fullPathLength; i++) {
Pair<String, Double> probPair = new Pair<String, Double>(fullPathComponents.get(i), Math.exp((double) i+1));
zoneProbabilities.add(probPair);
@@ -48,7 +47,6 @@ public class GossipGirlStrategies {
zoneProbabilities = new ArrayList<>(fullPathLength);
Double uniformProb = 1.0/fullPathLength;
- // TODO good direction
for (int i = 0; i < fullPathLength; i++) {
Pair<String, Double> probPair = new Pair<String, Double>(fullPathComponents.get(i), uniformProb);
zoneProbabilities.add(probPair);
@@ -72,10 +70,9 @@ public class GossipGirlStrategies {
}
private String updateRoundRobinExpFreqs() {
- // TODO good direction
- for (int i = roundRobinExpFreqs.size() - 1; i > 0; i--) {
+ for (int i = 0; i < roundRobinExpFreqs.size() - 1; i++) {
Pair<String, Integer> p = roundRobinExpFreqs.get(i);
- Pair<String, Integer> nextP = roundRobinExpFreqs.get(i-1);
+ Pair<String, Integer> nextP = roundRobinExpFreqs.get(i+1);
if (2 * p.getSecond() < nextP.getSecond()) {
roundRobinExpFreqs.set(i, new Pair<String, Integer>(p.getFirst(), p.getSecond() + 1));
@@ -83,8 +80,10 @@ public class GossipGirlStrategies {
}
}
- Pair<String, Integer> rootPath = roundRobinExpFreqs.get(0);
- roundRobinExpFreqs.set(0, new Pair<String, Integer>(rootPath.getFirst(), rootPath.getSecond() + 1));
+ Pair<String, Integer> rootPath = roundRobinExpFreqs.get(roundRobinExpFreqs.size() - 1);
+ roundRobinExpFreqs.set(
+ roundRobinExpFreqs.size() - 1,
+ new Pair<String, Integer>(rootPath.getFirst(), rootPath.getSecond() + 1));
return rootPath.getFirst();
}
diff --git a/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlStrategyTest.java b/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlStrategyTest.java
index 681483d..8fba76e 100644
--- a/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlStrategyTest.java
+++ b/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlStrategyTest.java
@@ -26,6 +26,7 @@ public class GossipGirlStrategyTest {
gossipGirlStrategies.selectStrategy(GossipGirlStrategies.ZoneSelectionStrategy.ROUND_ROBIN_EXP_FREQ);
freqs.put(selectedPath, freqs.get(selectedPath) + 1);
System.out.println(selectedPath);
+ System.out.println(freqs);
}
}
}