use of desmoj.core.dist.DiscreteDistPoisson in project scylla by bptlab.
the class SimulationUtils method getDistribution.
public static NumericalDist<?> getDistribution(Distribution dist, SimulationModel model, String name, Integer nodeId, boolean showInReport, boolean showInTrace) throws InstantiationException {
if (dist instanceof BinomialDistribution) {
BinomialDistribution binDist = (BinomialDistribution) dist;
double probability = binDist.getProbability();
int amount = binDist.getAmount();
return new DiscreteDistBinomial(model, name, probability, amount, showInReport, showInTrace);
} else if (dist instanceof ConstantDistribution) {
ConstantDistribution conDist = (ConstantDistribution) dist;
double constantValue = conDist.getConstantValue();
return new DiscreteDistConstant<Number>(model, name, constantValue, showInReport, showInTrace);
} else if (dist instanceof EmpiricalDistribution) {
EmpiricalDistribution empDist = (EmpiricalDistribution) dist;
Map<Double, Double> entries = empDist.getEntries();
DiscreteDistEmpirical<Double> cde = new DiscreteDistEmpirical<Double>(model, name, showInReport, showInTrace);
for (Double value : entries.keySet()) {
Double frequency = entries.get(value);
cde.addEntry(value, frequency);
}
return cde;
} else if (dist instanceof EmpiricalStringDistribution) {
EmpiricalStringDistribution empDist = (EmpiricalStringDistribution) dist;
Map<Double, Double> entries = empDist.getEntries();
DiscreteDistEmpirical<Double> cde = new DiscreteDistEmpirical<Double>(model, name, showInReport, showInTrace);
for (Double value : entries.keySet()) {
Double frequency = entries.get(value);
cde.addEntry(value, frequency);
}
return cde;
} else if (dist instanceof ErlangDistribution) {
ErlangDistribution erlDist = (ErlangDistribution) dist;
double mean = erlDist.getMean();
long order = erlDist.getOrder();
return new ContDistErlang(model, name, order, mean, showInReport, showInTrace);
} else if (dist instanceof ExponentialDistribution) {
ExponentialDistribution expDist = (ExponentialDistribution) dist;
double mean = expDist.getMean();
return new ContDistExponential(model, name, mean, showInReport, showInTrace);
} else if (dist instanceof TriangularDistribution) {
TriangularDistribution triDist = (TriangularDistribution) dist;
double lower = triDist.getLower();
double upper = triDist.getUpper();
double peak = triDist.getPeak();
return new ContDistTriangular(model, name, lower, upper, peak, showInReport, showInTrace);
} else if (dist instanceof NormalDistribution) {
NormalDistribution norDist = (NormalDistribution) dist;
double mean = norDist.getMean();
double standardDeviation = norDist.getStandardDeviation();
return new ContDistNormal(model, name, mean, standardDeviation, showInReport, showInTrace);
} else if (dist instanceof PoissonDistribution) {
PoissonDistribution poiDist = (PoissonDistribution) dist;
double mean = poiDist.getMean();
return new DiscreteDistPoisson(model, name, mean, showInReport, showInTrace);
} else if (dist instanceof UniformDistribution) {
UniformDistribution uniDist = (UniformDistribution) dist;
double lower = uniDist.getLower();
double upper = uniDist.getUpper();
return new ContDistUniform(model, name, lower, upper, showInReport, showInTrace);
} else {
throw new InstantiationException("Distribution of node " + nodeId + " not supported.");
}
}
Aggregations