m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.gradle2
-rw-r--r--src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlStrategies.java55
2 files changed, 57 insertions, 0 deletions
diff --git a/build.gradle b/build.gradle
index de9a9df..e2174a7 100644
--- a/build.gradle
+++ b/build.gradle
@@ -55,6 +55,8 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-test:2.2.1.RELEASE'
+ implementation 'org.apache.commons:commons-math3:3.6.1'
+
// Use JUnit test framework
testImplementation 'junit:junit:4.12'
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;
+ }
+
+
+
+}