diff options
| author | Magdalena Grodzińska <mag.grodzinska@gmail.com> | 2020-01-10 20:44:44 +0100 | 
|---|---|---|
| committer | Magdalena Grodzińska <mag.grodzinska@gmail.com> | 2020-01-10 20:44:44 +0100 | 
| commit | b0108af8033748220bb10b427cba6cbb1b418ebd (patch) | |
| tree | d865fdc0660d2e046b79c952ca25ad0ac7b96458 /src/main | |
| parent | 69fa53941cfa42f3b0f511f6abe549919241123b (diff) | |
Add gossip girl strategies skeleton
Diffstat (limited to 'src/main')
| -rw-r--r-- | src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/GossipGirlStrategies.java | 55 | 
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; +    } + + + +} |