m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/pl/edu
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/pl/edu')
-rw-r--r--src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlStrategies.java55
1 files changed, 55 insertions, 0 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
new file mode 100644
index 0000000..bf163d1
--- /dev/null
+++ b/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlStrategies.java
@@ -0,0 +1,55 @@
+package pl.edu.mimuw.cloudatlas.agent.modules;
+
+import org.apache.commons.math3.distribution.EnumeratedDistribution;
+import org.apache.commons.math3.util.Pair;
+import pl.edu.mimuw.cloudatlas.model.PathName;
+
+import java.util.ArrayList;
+
+/**
+ round robin with the same frequency for all levels,
+ round robin with the frequency exponentially decreasing with level,
+ random with the same selection probability for all levels,
+ random with the selection probability decreasing exponentially with level.
+ */
+
+public class GossipGirlStrategies {
+
+ public enum ZoneSelectionStrategy {
+ ROUND_ROBIN_SAME_FREQ,
+ ROUND_ROBIN_EXP_FREQ,
+ RANDOM_UNFIORM,
+ RANDOM_DECR_EXP
+ }
+
+ public PathName selectStrategy(PathName fullPath, ZoneSelectionStrategy selectionStrategy) {
+ PathName selectedPath;
+ ArrayList<PathName>
+ int fullPathLength = fullPath.getComponents().size();
+
+ switch(selectionStrategy) {
+ case (ZoneSelectionStrategy.ROUND_ROBIN_SAME_FREQ):
+
+ break;
+ case (ZoneSelectionStrategy.ROUND_ROBIN_EXP_FREQ):
+
+ break;
+ case (ZoneSelectionStrategy.RANDOM_UNFIORM):
+ ArrayList<Pair<PathName, Double>> zoneProbabilities = new ArrayList<>(fullPathLength);
+ EnumeratedDistribution dist = new EnumeratedDistribution();
+ for (int i = 1; i < fullPathLength; i++) {
+ zoneProbabilities.add(fullPath.);
+ }
+ break;
+ case (ZoneSelectionStrategy.RANDOM_DECR_EXP):
+ break;
+ default:
+ throw new UnsupportedOperationException("Such strategy doesn't exist");
+ }
+
+ return selectedPath;
+ }
+
+
+
+}