Search in sources :

Example 1 with TimeDistributionWrapper

use of de.hpi.bpt.scylla.model.configuration.distribution.TimeDistributionWrapper in project scylla by bptlab.

the class SimulationConfigurationParser method getTimeDistributionWrapper.

public static TimeDistributionWrapper getTimeDistributionWrapper(Element element, Namespace simNamespace) throws ScyllaValidationException {
    // <--- fieldType should not atter, but my not be "string"
    Distribution distribution = getDistribution(element, simNamespace, "");
    TimeUnit timeUnit = TimeUnit.valueOf(element.getAttributeValue("timeUnit"));
    TimeDistributionWrapper distWrapper = new TimeDistributionWrapper(timeUnit);
    distWrapper.setDistribution(distribution);
    return distWrapper;
}
Also used : EmpiricalDistribution(de.hpi.bpt.scylla.model.configuration.distribution.EmpiricalDistribution) NormalDistribution(de.hpi.bpt.scylla.model.configuration.distribution.NormalDistribution) ExponentialDistribution(de.hpi.bpt.scylla.model.configuration.distribution.ExponentialDistribution) TriangularDistribution(de.hpi.bpt.scylla.model.configuration.distribution.TriangularDistribution) UniformDistribution(de.hpi.bpt.scylla.model.configuration.distribution.UniformDistribution) ErlangDistribution(de.hpi.bpt.scylla.model.configuration.distribution.ErlangDistribution) ConstantDistribution(de.hpi.bpt.scylla.model.configuration.distribution.ConstantDistribution) Distribution(de.hpi.bpt.scylla.model.configuration.distribution.Distribution) BinomialDistribution(de.hpi.bpt.scylla.model.configuration.distribution.BinomialDistribution) EmpiricalStringDistribution(de.hpi.bpt.scylla.model.configuration.distribution.EmpiricalStringDistribution) PoissonDistribution(de.hpi.bpt.scylla.model.configuration.distribution.PoissonDistribution) TimeUnit(java.util.concurrent.TimeUnit) TimeDistributionWrapper(de.hpi.bpt.scylla.model.configuration.distribution.TimeDistributionWrapper)

Example 2 with TimeDistributionWrapper

use of de.hpi.bpt.scylla.model.configuration.distribution.TimeDistributionWrapper in project scylla by bptlab.

the class EventArrivalRateSCParserPlugin method parse.

/**
 * Parses all occurences of event arrival rates to be stored as extension attribute.
 */
@Override
public Map<String, Object> parse(SimulationConfiguration simulationInput, Element sim) throws ScyllaValidationException {
    Map<Integer, TimeDistributionWrapper> arrivalRates = new HashMap<Integer, TimeDistributionWrapper>();
    Namespace simNamespace = sim.getNamespace();
    ProcessModel processModel = simulationInput.getProcessModel();
    for (Element el : sim.getChildren()) {
        String elementName = el.getName();
        if (elementName.equals(EventArrivalRatePluginUtils.ELEMENT_NAME)) {
            String identifier = el.getAttributeValue("id");
            if (identifier == null) {
                DebugLogger.log("Warning: Simulation configuration definition catch event element '" + elementName + "' does not have an identifier, skip.");
                continue;
            }
            Integer nodeId = processModel.getIdentifiersToNodeIds().get(identifier);
            if (nodeId == null) {
                DebugLogger.log("Warning: There is no matching catch event in the process model for " + "simulation configuration definition '" + identifier + ", skip.");
                continue;
            }
            Element elem = el.getChild("arrivalRate", simNamespace);
            if (elem != null) {
                TimeDistributionWrapper distribution = SimulationConfigurationParser.getTimeDistributionWrapper(elem, simNamespace);
                arrivalRates.put(nodeId, distribution);
            }
        }
    }
    Map<String, Object> extensionAttributes = new HashMap<String, Object>();
    extensionAttributes.put(EventArrivalRatePluginUtils.ARRIVALRATES_KEY, arrivalRates);
    return extensionAttributes;
}
Also used : ProcessModel(de.hpi.bpt.scylla.model.process.ProcessModel) HashMap(java.util.HashMap) Element(org.jdom2.Element) TimeDistributionWrapper(de.hpi.bpt.scylla.model.configuration.distribution.TimeDistributionWrapper) Namespace(org.jdom2.Namespace)

Example 3 with TimeDistributionWrapper

use of de.hpi.bpt.scylla.model.configuration.distribution.TimeDistributionWrapper in project scylla by bptlab.

the class ProcessSimulationComponents method convertToDesmojDistributions.

private void convertToDesmojDistributions(Map<Integer, TimeDistributionWrapper> arrivalRatesAndDurations, boolean setUp) throws InstantiationException {
    Long randomSeed = simulationConfiguration.getRandomSeed();
    for (Integer nodeId : arrivalRatesAndDurations.keySet()) {
        TimeDistributionWrapper distWrapper = arrivalRatesAndDurations.get(nodeId);
        TimeUnit distTimeUnit = distWrapper.getTimeUnit();
        Distribution dist = distWrapper.getDistribution();
        String name = processModel.getModelScopeId() + "_" + nodeId.toString();
        NumericalDist<?> desmojDist = SimulationUtils.getDistribution(dist, model, name, nodeId, showInReport, showInTrace);
        desmojDist.setSeed(randomSeed);
        // all
        if (!setUp) {
            distributions.put(nodeId, desmojDist);
            distributionTimeUnits.put(nodeId, distTimeUnit);
        } else {
            setUpDistributions.put(nodeId, desmojDist);
            setUpDistributionTimeUnits.put(nodeId, distTimeUnit);
        }
    }
}
Also used : Distribution(de.hpi.bpt.scylla.model.configuration.distribution.Distribution) TimeUnit(java.util.concurrent.TimeUnit) TimeDistributionWrapper(de.hpi.bpt.scylla.model.configuration.distribution.TimeDistributionWrapper)

Example 4 with TimeDistributionWrapper

use of de.hpi.bpt.scylla.model.configuration.distribution.TimeDistributionWrapper in project scylla by bptlab.

the class EventArrivalRateDistributionConversionPlugin method convertToDesmoJDistributions.

/**
 * Converts scylla distributions from extension to desmoJ distributions to be stored als distribution extension.
 * @see {@link de.hpi.bpt.scylla.simulation.utils.SimulationUtils#getDistribution(Distribution, SimulationModel, String, Integer, boolean, boolean)}
 */
@Override
public Map<Integer, Object> convertToDesmoJDistributions(ProcessSimulationComponents pSimComponents) {
    Map<Integer, Object> arrivalRateDistributions = new HashMap<Integer, Object>();
    SimulationConfiguration simulationConfiguration = pSimComponents.getSimulationConfiguration();
    Long randomSeed = simulationConfiguration.getRandomSeed();
    /**
     *Get saved extension from sc parser
     */
    @SuppressWarnings("unchecked") HashMap<Integer, TimeDistributionWrapper> arrivalRates = (HashMap<Integer, TimeDistributionWrapper>) simulationConfiguration.getExtensionValue(getName(), EventArrivalRatePluginUtils.ARRIVALRATES_KEY);
    ProcessModel processModel = pSimComponents.getProcessModel();
    SimulationModel model = pSimComponents.getModel();
    boolean showInReport = model.reportIsOn();
    boolean showInTrace = model.traceIsOn();
    for (Entry<Integer, TimeDistributionWrapper> entry : arrivalRates.entrySet()) {
        Integer nodeId = entry.getKey();
        TimeDistributionWrapper arrivalRate = entry.getValue();
        TimeUnit timeUnit = arrivalRate.getTimeUnit();
        Distribution distribution = arrivalRate.getDistribution();
        String name = processModel.getModelScopeId() + "_" + nodeId.toString();
        try {
            NumericalDist<?> desmojDist = SimulationUtils.getDistribution(distribution, model, name, nodeId, showInReport, showInTrace);
            desmojDist.setSeed(randomSeed);
            arrivalRateDistributions.put(nodeId, new SimpleEntry<NumericalDist<?>, TimeUnit>(desmojDist, timeUnit));
        } catch (InstantiationException e) {
            e.printStackTrace();
            continue;
        }
    }
    return arrivalRateDistributions;
}
Also used : ProcessModel(de.hpi.bpt.scylla.model.process.ProcessModel) HashMap(java.util.HashMap) NumericalDist(desmoj.core.dist.NumericalDist) SimulationConfiguration(de.hpi.bpt.scylla.model.configuration.SimulationConfiguration) Distribution(de.hpi.bpt.scylla.model.configuration.distribution.Distribution) TimeUnit(java.util.concurrent.TimeUnit) TimeDistributionWrapper(de.hpi.bpt.scylla.model.configuration.distribution.TimeDistributionWrapper) SimulationModel(de.hpi.bpt.scylla.simulation.SimulationModel)

Example 5 with TimeDistributionWrapper

use of de.hpi.bpt.scylla.model.configuration.distribution.TimeDistributionWrapper in project scylla by bptlab.

the class ProcessSimulationComponents method init.

public void init() {
    try {
        Map<Integer, TimeDistributionWrapper> arrivalRates = simulationConfiguration.getArrivalRates();
        Map<Integer, TimeDistributionWrapper> durations = simulationConfiguration.getDurations();
        Map<Integer, TimeDistributionWrapper> setUpDurations = simulationConfiguration.getSetUpDurations();
        Map<Integer, TimeDistributionWrapper> arrivalRatesAndDurations = new HashMap<Integer, TimeDistributionWrapper>();
        arrivalRatesAndDurations.putAll(arrivalRates);
        arrivalRatesAndDurations.putAll(durations);
        setSmallestTimeUnit(arrivalRatesAndDurations);
        setSmallestTimeUnit(setUpDurations);
        convertToDesmojDistributions(arrivalRatesAndDurations, false);
        convertToDesmojDistributions(setUpDurations, true);
        extensionDistributions = DistributionConversionPluggable.runPlugins(this);
        Map<Integer, SimulationConfiguration> configurationsOfSubProcesses = simulationConfiguration.getConfigurationsOfSubProcesses();
        for (Integer nodeId : configurationsOfSubProcesses.keySet()) {
            SimulationConfiguration scOfSubProcess = configurationsOfSubProcesses.get(nodeId);
            ProcessModel pmOfSubProcess = processModel.getSubProcesses().get(nodeId);
            ProcessSimulationComponents desmojObjects = new ProcessSimulationComponents(model, this, pmOfSubProcess, scOfSubProcess);
            desmojObjects.init();
            children.put(nodeId, desmojObjects);
        }
    } catch (InstantiationException e) {
        DebugLogger.error(e.getMessage());
        DebugLogger.error("Instantiation of simulation model failed.");
    }
}
Also used : ProcessModel(de.hpi.bpt.scylla.model.process.ProcessModel) SimulationConfiguration(de.hpi.bpt.scylla.model.configuration.SimulationConfiguration) HashMap(java.util.HashMap) TimeDistributionWrapper(de.hpi.bpt.scylla.model.configuration.distribution.TimeDistributionWrapper)

Aggregations

TimeDistributionWrapper (de.hpi.bpt.scylla.model.configuration.distribution.TimeDistributionWrapper)8 ProcessModel (de.hpi.bpt.scylla.model.process.ProcessModel)5 HashMap (java.util.HashMap)5 TimeUnit (java.util.concurrent.TimeUnit)4 SimulationConfiguration (de.hpi.bpt.scylla.model.configuration.SimulationConfiguration)3 Distribution (de.hpi.bpt.scylla.model.configuration.distribution.Distribution)3 Element (org.jdom2.Element)3 ScyllaValidationException (de.hpi.bpt.scylla.exception.ScyllaValidationException)2 Namespace (org.jdom2.Namespace)2 BranchingBehavior (de.hpi.bpt.scylla.model.configuration.BranchingBehavior)1 ResourceReference (de.hpi.bpt.scylla.model.configuration.ResourceReference)1 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