Permalink
Browse files

Classpath refactor

  • Loading branch information...
1 parent 70c6d4e commit b9b5f63c0ba9a776e9e9db2b9c04167bb1689551 @javajawa committed Mar 20, 2012
Showing with 77 additions and 396 deletions.
  1. +0 −100 src/networkssim/NetworksSim.java
  2. +0 −85 src/networkssim/ResultAggregator.java
  3. +0 −138 src/networkssim/ResultAggregator2Free.java
  4. +0 −6 src/networkssim/entropy/Process.java
  5. +0 −10 src/networkssim/functions/Function.java
  6. +1 −1 src/{networkssim → uk/co/harcourtprogramming/stochastics}/entropy/DiscreteDistribution.java
  7. +1 −1 src/{networkssim → uk/co/harcourtprogramming/stochastics}/entropy/DiscreteProcess.java
  8. +2 −2 src/{networkssim → uk/co/harcourtprogramming/stochastics}/entropy/Distribution.java
  9. +6 −0 src/uk/co/harcourtprogramming/stochastics/entropy/Process.java
  10. +1 −1 src/{networkssim → uk/co/harcourtprogramming/stochastics}/entropy/Randomised.java
  11. +8 −8 src/{networkssim → uk/co/harcourtprogramming/stochastics}/entropy/implementations/Bernoulli.java
  12. +3 −3 src/{networkssim → uk/co/harcourtprogramming/stochastics}/entropy/implementations/Gaussian.java
  13. +3 −3 src/{networkssim → uk/co/harcourtprogramming/stochastics}/entropy/implementations/Poisson.java
  14. +2 −2 ...networkssim → uk/co/harcourtprogramming/stochastics}/entropy/implementations/PusedoBernoulli.java
  15. +10 −0 src/uk/co/harcourtprogramming/stochastics/functions/Function.java
  16. +1 −1 src/{networkssim → uk/co/harcourtprogramming/stochastics}/sets/Domain.java
  17. +1 −1 src/{networkssim → uk/co/harcourtprogramming/stochastics}/sets/DoubleRange.java
  18. +1 −1 src/{networkssim → uk/co/harcourtprogramming/stochastics}/sets/IntRange.java
  19. +1 −1 src/{networkssim → uk/co/harcourtprogramming/stochastics}/sets/Range.java
  20. +6 −6 src/{networkssim → uk/co/harcourtprogramming/stochastics}/simulations/SlottedAloha.java
  21. +1 −1 src/{networkssim → uk/co/harcourtprogramming/stochastics}/statistics/QueueStatistic.java
  22. +3 −3 src/{networkssim → uk/co/harcourtprogramming/stochastics}/statistics/RealsSample.java
  23. +4 −4 src/{networkssim → uk/co/harcourtprogramming/stochastics}/statistics/Sample.java
  24. +1 −1 src/{networkssim → uk/co/harcourtprogramming/stochastics}/statistics/Statistic.java
  25. +2 −2 src/{networkssim → uk/co/harcourtprogramming/stochastics}/statistics/TimedQueueSample.java
  26. +1 −1 src/{networkssim → uk/co/harcourtprogramming/stochastics}/utilities/Combinatorics.java
  27. +3 −3 test/{networkssim → uk/co/harcourtprogramming/stochastics}/entropy/BernoulliDistributionTest.java
  28. +3 −2 test/{networkssim → uk/co/harcourtprogramming/stochastics}/entropy/GaussianDistributionTest.java
  29. +3 −3 test/{networkssim → uk/co/harcourtprogramming/stochastics}/entropy/PoissonDistributionTest.java
  30. +3 −3 test/{networkssim → uk/co/harcourtprogramming/stochastics}/entropy/PoissonTest.java
  31. +2 −1 test/{networkssim → uk/co/harcourtprogramming/stochastics}/statistics/SampleTest.java
  32. +2 −1 test/{networkssim → uk/co/harcourtprogramming/stochastics}/statistics/SampleValuesTest.java
  33. +2 −1 test/{networkssim → uk/co/harcourtprogramming/stochastics}/utilities/CombinatoricsTest.java
@@ -1,100 +0,0 @@
-package networkssim;
-
-import java.io.IOException;
-import java.io.PrintStream;
-import networkssim.entropy.Distribution;
-import networkssim.entropy.implementations.Poisson;
-import networkssim.sets.Domain;
-import networkssim.simulations.SlottedAloha;
-import networkssim.statistics.QueueStatistic;
-import networkssim.sets.DoubleRange;
-import networkssim.sets.IntRange;
-
-public class NetworksSim
-{
- /**
- * @param args the command line arguments
- */
- @SuppressWarnings({"UseOfSystemOutOrSystemErr", "CallToThreadRun"})
- public static void main(String[] args) throws IOException
- {
- PrintStream p = new PrintStream("Z:/tmp/networks4/new-fine.tsv");
-
- for (Integer i : new IntRange(0, 500))
- {
- for (Double lambda : new DoubleRange(0.01, 0.40, 0.0025))
- {
- SlottedAloha sim = new SlottedAloha(new Poisson(lambda), optimalDist(lambda), 10000);
-
- sim.run();
- QueueStatistic blockingStatistics = sim.getBlockingStatistics();
-
- p.format("%5$6.4f\t%1$7d\t%2$7d\t%3$8.3f\n",
- blockingStatistics.arrivals(),
- blockingStatistics.completions(),
- blockingStatistics.sampleMean(),
- blockingStatistics.sampleVariance(),
- lambda
- );
- System.gc();
- }
- p.flush();
- System.out.print('.');
- }
- p.close();
- }
-
- private static Distribution<Integer> constDist(final double v)
- {
- return new Distribution<Integer>()
- {
- @Override
- public Double valueOf(Integer value)
- {
- return v;
- }
-
- @Override
- public Domain<Integer> domain()
- {
- return new IntRange(0, Integer.MAX_VALUE);
- }
-
- @Override
- public Domain<Double> range()
- {
- return new DoubleRange(0.0D, 1.0D, Double.MIN_NORMAL);
- }
-
- };
- }
-
- private static Distribution<Integer> optimalDist(final double v)
- {
- return new Distribution<Integer>()
- {
- @Override
- public Double valueOf(Integer value)
- {
- return (1 - v) / value;
- }
-
- @Override
- public Domain<Integer> domain()
- {
- return new IntRange(0, Integer.MAX_VALUE);
- }
-
- @Override
- public Domain<Double> range()
- {
- return new DoubleRange(0.0D, 1.0D, Double.MIN_NORMAL);
- }
-
- };
- }
-
- private NetworksSim()
- {
- }
-}
@@ -1,85 +0,0 @@
-package networkssim;
-
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import networkssim.statistics.RealsSample;
-import networkssim.statistics.Sample;
-
-public class ResultAggregator
-{
- static final Map<Integer, Sample> arrivals = new TreeMap<Integer, Sample>();
- static final Map<Integer, Sample> completions = new TreeMap<Integer, Sample>();
- static final Map<Integer, RealsSample> queue = new TreeMap<Integer, RealsSample>();
-
- static final Pattern p = Pattern.compile("([0-9.]+)", Pattern.CASE_INSENSITIVE);
-
- @SuppressWarnings("UseOfSystemOutOrSystemErr")
- public static void main(String[] args) throws IOException
- {
- final BufferedReader f = new BufferedReader(new FileReader("Z:/tmp/networks4/new-fine.tsv"));
-
- while (f.ready())
- process(f.readLine());
-
- f.close();
-
- final BufferedWriter w = new BufferedWriter(new FileWriter("Z:/tmp/networks4/new-fine.tsv"));
-
- for (Integer i : queue.keySet())
- {
- w.append(String.format("%5.4f\t%10.4f\t%10.4f\t%10.4f\t%10.4f\t%10.4f\t%10.4f\n",
- (double)i/10000,
- arrivals.get(i).sampleMean(),
- Math.sqrt(arrivals.get(i).sampleVariance()) * 1.96,
- completions.get(i).sampleMean(),
- Math.sqrt(completions.get(i).sampleVariance()) * 1.96,
- queue.get(i).sampleMean(),
- Math.sqrt(queue.get(i).sampleVariance()) * 1.96
- ));
- }
-
- w.close();
- }
-
- private static void process(String readLine)
- {
- Matcher m = p.matcher(readLine);
-
- m.find();
- int i = ((Double)(Double.valueOf(m.group()) * 10000)).intValue();
-
- m.find();
- mapSample(arrivals, i, Integer.parseInt(m.group()));
- m.find();
- mapSample(completions, i, Integer.parseInt(m.group()));
- m.find();
- mapSample(queue, i, Double.parseDouble(m.group()));
- }
-
- static <T> void mapSample(Map<T, Sample> m, T t, int s)
- {
- if (!m.containsKey(t))
- m.put(t, new Sample());
-
- m.get(t).observed(s);
- }
-
- static <T> void mapSample(Map<T, RealsSample> m, T t, double s)
- {
- if (!m.containsKey(t))
- m.put(t, new RealsSample());
-
- m.get(t).observed(s);
- }
-
- private ResultAggregator()
- {
- }
-}
@@ -1,138 +0,0 @@
-package networkssim;
-
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.TreeMap;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import networkssim.statistics.RealsSample;
-import networkssim.statistics.Sample;
-import networkssim.statistics.Statistic;
-
-public class ResultAggregator2Free
-{
- static final TreeMap<Integer, Map<Integer, Statistic<Integer>>> arrivals = new TreeMap<Integer, Map<Integer, Statistic<Integer>>>();
- static final TreeMap<Integer, Map<Integer, Statistic<Integer>>> completions = new TreeMap<Integer, Map<Integer, Statistic<Integer>>>();
- static final TreeMap<Integer, Map<Integer, Statistic<Double>>> queue = new TreeMap<Integer, Map<Integer, Statistic<Double>>>();
-
- static final Pattern p = Pattern.compile("([0-9.]+)", Pattern.CASE_INSENSITIVE);
-
- @SuppressWarnings("UseOfSystemOutOrSystemErr")
- public static void main(String[] args) throws IOException
- {
- final BufferedReader f = new BufferedReader(new FileReader("Z:/tmp/networks4/betas.tsv"));
- long i = 0;
-
- while (f.ready())
- try
- {
- ++i;
- process(f.readLine());
- }
- catch (Throwable ex)
- {
- throw new Error("Error on line " + i, ex);
- }
-
-
- f.close();
-
- final BufferedWriter w = new BufferedWriter(new FileWriter("Z:/tmp/networks4/betas-aggregate.tsv"));
-
- output(w, queue);
- output(w, completions);
- output(w, arrivals);
-
- w.close();
- System.out.println(i + " lines processed");
- }
-
- private static void process(String readLine)
- {
- if (readLine.trim().length() == 0) return;
- Matcher m = p.matcher(readLine);
-
- m.find();
- int i = ((Double)(Double.valueOf(m.group()) * 100)).intValue();
- m.find();
- int j = ((Double)(Double.valueOf(m.group()) * 100)).intValue();
- m.find();
- mapSample(arrivals, i, j, Integer.parseInt(m.group()));
- m.find();
- mapSample(completions, i, j, Integer.parseInt(m.group()));
- m.find();
- mapSample(queue, i, j, Double.parseDouble(m.group()));
- }
-
- static <T,U> void mapSample(Map<T, Map<U, Statistic<Integer>>> m, T t, U u, int s)
- {
- if (!m.containsKey(t))
- m.put(t, new TreeMap<U, Statistic<Integer>>());
- if (!m.get(t).containsKey(u))
- m.get(t).put(u, (Statistic<Integer>)new Sample());
-
- m.get(t).get(u).observed(s);
- }
-
- static <T,U> void mapSample(Map<T, Map<U, Statistic<Double>>> m, T t, U u, double s)
- {
- if (!m.containsKey(t))
- m.put(t, new TreeMap<U, Statistic<Double>>());
- if (!m.get(t).containsKey(u))
- m.get(t).put(u, new RealsSample());
-
- m.get(t).get(u).observed(s);
- }
-
- private static <T extends Number> void output(BufferedWriter w, Map<Integer, Map<Integer, Statistic<T> > > m) throws IOException
- {
- Set<Integer> keySet = new HashSet<Integer>(Arrays.asList(1,2,4,8)); //m.values().iterator().next().keySet();
- for (Integer j : keySet)
- w.append(String.format("\t%10.4f",(double)j/100));
- w.append('\n');
-
- for (Entry<Integer, Map<Integer, Statistic<T>>> n : m.entrySet())
- {
- w.append(String.format("%5.4f", (double)n.getKey()/100));
- for (Integer i : keySet)
- if (!n.getValue().containsKey(i))
- {
- w.append('\t');
- }
- else
- {
- Statistic<T> s = n.getValue().get(i);
- w.append(String.format("\t%10.4f", s.sampleMean()));
- }
- w.newLine();
- }
- w.newLine();
- for (Entry<Integer, Map<Integer, Statistic<T>>> n : m.entrySet())
- {
- w.append(String.format("%5.4f", (double)n.getKey()/100));
- for (Integer i : keySet)
- if (!n.getValue().containsKey(i))
- {
- w.append('\t');
- }
- else
- {
- Statistic<T> s = n.getValue().get(i);
- w.append(String.format("\t%10.4f", Math.sqrt(s.sampleVariance()) * 1.96));
- }
- w.newLine();
- }
- w.newLine();
- }
- private ResultAggregator2Free()
- {
- }
-}
@@ -1,6 +0,0 @@
-package networkssim.entropy;
-
-public interface Process
-{
- Number next();
-}
@@ -1,10 +0,0 @@
-package networkssim.functions;
-
-import networkssim.sets.Domain;
-
-public interface Function<X,Y>
-{
- Y valueOf(X value);
- Domain<X> domain();
- Domain<Y> range();
-}
@@ -1,4 +1,4 @@
-package networkssim.entropy;
+package uk.co.harcourtprogramming.stochastics.entropy;
@SuppressWarnings("MarkerInterface")
public interface DiscreteDistribution<T extends Comparable<T> > extends Distribution<T>
@@ -1,4 +1,4 @@
-package networkssim.entropy;
+package uk.co.harcourtprogramming.stochastics.entropy;
public interface DiscreteProcess extends Process
{
@@ -1,6 +1,6 @@
-package networkssim.entropy;
+package uk.co.harcourtprogramming.stochastics.entropy;
-import networkssim.functions.Function;
+import uk.co.harcourtprogramming.stochastics.functions.Function;
@SuppressWarnings("MarkerInterface")
public interface Distribution<T extends Comparable<T> > extends Function<T, Double>
@@ -0,0 +1,6 @@
+package uk.co.harcourtprogramming.stochastics.entropy;
+
+public interface Process
+{
+ Number next();
+}
@@ -1,4 +1,4 @@
-package networkssim.entropy;
+package uk.co.harcourtprogramming.stochastics.entropy;
import java.util.Random;
public abstract class Randomised
Oops, something went wrong.

0 comments on commit b9b5f63

Please sign in to comment.