4import java.util.Scanner;
5import umontreal.ssj.charts.HistogramChart;
6import umontreal.ssj.charts.EmpiricalChart;
7import umontreal.ssj.probdist.ContinuousDistribution;
8import umontreal.ssj.probdist.DistributionFactory;
9import umontreal.ssj.rng.*;
10import umontreal.ssj.mcqmctools.*;
11import umontreal.ssj.stat.TallyStore;
25 double[] V =
new double[dim];
28 double[] paths =
new double[6];
32 public San13Dist(String fileName)
throws IOException {
33 readDistributions(fileName);
36 public void readDistributions(String fileName)
throws IOException {
38 BufferedReader input =
new BufferedReader(
new FileReader(fileName));
39 Scanner scan =
new Scanner(input);
40 for (
int k = 0; k < 13; k++) {
46 public int getDimension() {
50 public double deterministicLengths() {
51 for (
int k = 0; k < 13; k++) {
52 V[k] = dist[k].getMean();
56 return computePathsAndT();
60 for (
int k = 0; k < 13; k++) {
69 public double computePathsAndT() {
71 paths[0] = V[1] + V[5] + V[10];
72 paths[1] = V[0] + V[2] + V[5] + V[10];
73 paths[2] = V[0] + V[4] + V[10];
74 paths[3] = V[0] + V[3] + V[7] + V[9] + V[10];
75 paths[4] = V[0] + V[3] + V[7] + V[8] + V[12];
76 paths[5] = V[0] + V[3] + V[6] + V[11] + V[12];
78 for (
int p = 1; p < 6; p++)
79 if (paths[p] > maxPath)
90 String s =
"SAN network with 9 nodes and 13 links, from Elmaghraby (1977)\n"
91 +
"Estimate distribution of length T of longest path \n";
99 public static void main(String[] args)
throws IOException {
110 statTaggregated = statT.
aggregate(groupSize);
111 double[] aggreg = statTaggregated.
getArray();
114 double[] bounds2 = { 0, 200, 0, 1.0 };
122 HistogramChart hist =
new HistogramChart(
"Distribution of $T$",
"Values of $T$",
"Frequency", statT.
getArray(),
124 double[] bounds = { 0, 200, 0, 12000 };
125 hist.setManualRange(bounds);
126 (hist.getSeriesCollection()).setBins(0, 40, 0, 200);
128 String histLatex = hist.toLatex(12.0, 8.0);
129 file =
new FileWriter(
"src/main/docs/examples/tutorial/san13chart.tex");
130 file.write(histLatex);
135 int index = (int) Math.round(p * n);
136 double xip = statT.
getArray()[index];
137 System.out.printf(
"%5.3g -th quantile: %9.6g \n", p, xip);
This class simulates a specific stochastic activity network with 9 nodes and 13 links,...
double getPerformance()
Recovers and returns the realization of the performance measure, of type double.
String toString()
Returns a description of the model and its parameters.
String getTag()
Returns a short model name (tag) to be used in reports.
void simulate(RandomStream stream)
Simulates the model for one run.
Provides tools to create and manage empirical plots, which are used to plot empirical distributions.
JFrame view(int width, int height)
Displays chart on the screen using Swing.
void setManualRange(double[] range)
Sets the and ranges of the chart using the format: range = [xmin, xmax, ymin, ymax].
Classes implementing continuous distributions should inherit from this base class.
This class implements a string API for the package probdist.
static ContinuousDistribution getContinuousDistribution(String str)
Uses the Java Reflection API to construct a.
Extends RandomStreamBase using a composite linear feedback shift register (LFSR) (or Tausworthe) RNG ...
This class is a variant of Tally for which the individual observations are stored in a list implement...
void quickSort()
Sorts the elements of this probe using the quicksort from Colt.
TallyStore aggregate(int gsize)
Returns a new TallyStore instance that contains aggregate observations from this TallyStore.
double[] getArray()
Returns the observations stored in this probe.
int numberObs()
Returns the number of observations given to this probe since its last initialization.
This interface defines the basic structures to handle multiple streams of uniform (pseudo)random numb...
double nextDouble()
Returns a (pseudo)random number from the uniform distribution over the interval , using this stream,...