From b0108af8033748220bb10b427cba6cbb1b418ebd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magdalena=20Grodzi=C5=84ska?= Date: Fri, 10 Jan 2020 20:44:44 +0100 Subject: Add gossip girl strategies skeleton --- .../agent/modules/GossipGirlStrategies.java | 55 ++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlStrategies.java (limited to 'src/main/java') 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 + 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> 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; + } + + + +} -- cgit v1.2.3