Search in sources :

Example 1 with ContDistErlang

use of desmoj.core.dist.ContDistErlang in project scylla by bptlab.

the class ProcessSimulationComponents method getSetUpDistributionSample.

public double getSetUpDistributionSample(Integer nodeId) {
    NumericalDist<?> setUpDistribution = setUpDistributions.get(nodeId);
    if (setUpDistribution == null) {
        DebugLogger.log("No distribution found for node " + nodeId + ". " + "\nUse zero time interval.");
        // distribution = new DiscreteDistConstant<Double>(model, nodeId.toString(), 0d, showInReport, showInTrace);
        return 0d;
    }
    if (setUpDistribution instanceof ContDistErlang) {
        // skip trace notes to avoid confusion
        // when order is e.g. 10, it provides 11x "samples ... from ..." notes
        // only the last one is relevant for the user, so skip first 10
        ContDistErlang dist = (ContDistErlang) setUpDistribution;
        dist.skipTraceNote((int) dist.getOrder());
    }
    double value = setUpDistribution.sample().doubleValue();
    if (value < 0) {
        // negative values are not allowed, DESMOJ can't handle negative event times
        value = 0;
    }
    return value;
}
Also used : ContDistErlang(desmoj.core.dist.ContDistErlang)

Example 2 with ContDistErlang

use of desmoj.core.dist.ContDistErlang in project scylla by bptlab.

the class ProcessSimulationComponents method getDistributionSample.

public double getDistributionSample(Integer nodeId) {
    NumericalDist<?> distribution = distributions.get(nodeId);
    NumericalDist<?> setUpDistribution = setUpDistributions.get(nodeId);
    if (distribution == null) {
        DebugLogger.log("No distribution found for node " + nodeId + ". " + "\nUse zero time interval.");
        // distribution = new DiscreteDistConstant<Double>(model, nodeId.toString(), 0d, showInReport, showInTrace);
        return 0d;
    }
    if (distribution instanceof ContDistErlang) {
        // skip trace notes to avoid confusion
        // when order is e.g. 10, it provides 11x "samples ... from ..." notes
        // only the last one is relevant for the user, so skip first 10
        ContDistErlang dist = (ContDistErlang) distribution;
        dist.skipTraceNote((int) dist.getOrder());
    }
    double value = distribution.sample().doubleValue();
    if (value < 0) {
        // negative values are not allowed, DESMOJ can't handle negative event times
        value = 0;
    }
    return value;
}
Also used : ContDistErlang(desmoj.core.dist.ContDistErlang)

Example 3 with ContDistErlang

use of desmoj.core.dist.ContDistErlang 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.");
    }
}
Also used : PoissonDistribution(de.hpi.bpt.scylla.model.configuration.distribution.PoissonDistribution) DiscreteDistBinomial(desmoj.core.dist.DiscreteDistBinomial) EmpiricalDistribution(de.hpi.bpt.scylla.model.configuration.distribution.EmpiricalDistribution) ContDistErlang(desmoj.core.dist.ContDistErlang) ContDistTriangular(desmoj.core.dist.ContDistTriangular) DiscreteDistPoisson(desmoj.core.dist.DiscreteDistPoisson) ContDistNormal(desmoj.core.dist.ContDistNormal) ContDistUniform(desmoj.core.dist.ContDistUniform) ConstantDistribution(de.hpi.bpt.scylla.model.configuration.distribution.ConstantDistribution) DiscreteDistEmpirical(desmoj.core.dist.DiscreteDistEmpirical) ErlangDistribution(de.hpi.bpt.scylla.model.configuration.distribution.ErlangDistribution) ExponentialDistribution(de.hpi.bpt.scylla.model.configuration.distribution.ExponentialDistribution) UniformDistribution(de.hpi.bpt.scylla.model.configuration.distribution.UniformDistribution) EmpiricalStringDistribution(de.hpi.bpt.scylla.model.configuration.distribution.EmpiricalStringDistribution) ContDistExponential(desmoj.core.dist.ContDistExponential) NormalDistribution(de.hpi.bpt.scylla.model.configuration.distribution.NormalDistribution) BinomialDistribution(de.hpi.bpt.scylla.model.configuration.distribution.BinomialDistribution) TriangularDistribution(de.hpi.bpt.scylla.model.configuration.distribution.TriangularDistribution) Map(java.util.Map)

Aggregations

ContDistErlang (desmoj.core.dist.ContDistErlang)3 BinomialDistribution (de.hpi.bpt.scylla.model.configuration.distribution.BinomialDistribution)1 ConstantDistribution (de.hpi.bpt.scylla.model.configuration.distribution.ConstantDistribution)1 EmpiricalDistribution (de.hpi.bpt.scylla.model.configuration.distribution.EmpiricalDistribution)1 EmpiricalStringDistribution (de.hpi.bpt.scylla.model.configuration.distribution.EmpiricalStringDistribution)1 ErlangDistribution (de.hpi.bpt.scylla.model.configuration.distribution.ErlangDistribution)1 ExponentialDistribution (de.hpi.bpt.scylla.model.configuration.distribution.ExponentialDistribution)1 NormalDistribution (de.hpi.bpt.scylla.model.configuration.distribution.NormalDistribution)1 PoissonDistribution (de.hpi.bpt.scylla.model.configuration.distribution.PoissonDistribution)1 TriangularDistribution (de.hpi.bpt.scylla.model.configuration.distribution.TriangularDistribution)1 UniformDistribution (de.hpi.bpt.scylla.model.configuration.distribution.UniformDistribution)1 ContDistExponential (desmoj.core.dist.ContDistExponential)1 ContDistNormal (desmoj.core.dist.ContDistNormal)1 ContDistTriangular (desmoj.core.dist.ContDistTriangular)1 ContDistUniform (desmoj.core.dist.ContDistUniform)1 DiscreteDistBinomial (desmoj.core.dist.DiscreteDistBinomial)1 DiscreteDistEmpirical (desmoj.core.dist.DiscreteDistEmpirical)1 DiscreteDistPoisson (desmoj.core.dist.DiscreteDistPoisson)1 Map (java.util.Map)1