Search in sources :

Example 1 with Distribution

use of de.hpi.bpt.scylla.model.configuration.distribution.Distribution 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 Distribution

use of de.hpi.bpt.scylla.model.configuration.distribution.Distribution 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 3 with Distribution

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

the class DataObjectDistributionConversionPlugin method convertToDesmoJDistributions.

@SuppressWarnings("unchecked")
@Override
public Map<Integer, Object> convertToDesmoJDistributions(ProcessSimulationComponents pSimComponents) {
    SimulationConfiguration simulationConfiguration = pSimComponents.getSimulationConfiguration();
    Map<Integer, Object> dataObjects = (Map<Integer, Object>) simulationConfiguration.getExtensionValue(getName(), "dataObjects");
    Long randomSeed = simulationConfiguration.getRandomSeed();
    ProcessModel processModel = pSimComponents.getProcessModel();
    SimulationModel model = pSimComponents.getModel();
    boolean showInReport = model.reportIsOn();
    boolean showInTrace = model.traceIsOn();
    for (Integer nodeId : dataObjects.keySet()) {
        Map<String, DataObjectField> dataObjectFields = (Map<String, DataObjectField>) dataObjects.get(nodeId);
        String name = processModel.getModelScopeId() + "_" + nodeId.toString();
        for (String fieldName : dataObjectFields.keySet()) {
            DataObjectField dataObjectField = dataObjectFields.get(fieldName);
            DataDistributionWrapper distWrapper = dataObjectField.getDataDistributionWrapper();
            Distribution dist = distWrapper.getDistribution();
            if (dist == null)
                continue;
            NumericalDist<?> desmojDist = null;
            try {
                desmojDist = SimulationUtils.getDistribution(dist, model, name, nodeId, showInReport, showInTrace);
            } catch (InstantiationException e) {
                DebugLogger.error(e.getMessage());
                DebugLogger.error("Instantiation of dmn model failed.");
                return null;
            }
            desmojDist.setSeed(randomSeed);
            distWrapper.setDesmojDistribution(desmojDist);
        }
    }
    return dataObjects;
}
Also used : ProcessModel(de.hpi.bpt.scylla.model.process.ProcessModel) SimulationConfiguration(de.hpi.bpt.scylla.model.configuration.SimulationConfiguration) Distribution(de.hpi.bpt.scylla.model.configuration.distribution.Distribution) Map(java.util.Map) SimulationModel(de.hpi.bpt.scylla.simulation.SimulationModel)

Example 4 with Distribution

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

the class DataObjectSCParserPlugin method parse.

@Override
public /* pasrses the datobjects and creates the distWrapper*/
Map<String, Object> parse(SimulationConfiguration simulationInput, Element sim) throws ScyllaValidationException {
    Namespace simNamespace = sim.getNamespace();
    ProcessModel processModel = simulationInput.getProcessModel();
    Map<Integer, Map<String, DataObjectField>> dataObjects = new HashMap<Integer, Map<String, DataObjectField>>();
    for (Element el : sim.getChildren()) {
        String elementName = el.getName();
        if (elementName.equals("dataObject") || elementName.equals("dataInput")) {
            String identifier = el.getAttributeValue("id");
            if (identifier == null) {
                DebugLogger.log("Warning: Simulation configuration definition element '" + elementName + "' does not have an identifier, skip.");
                // no matching element in process, so skip definition
                continue;
            }
            Integer nodeId = processModel.getIdentifiersToNodeIds().get(identifier);
            if (nodeId == null) {
                DebugLogger.log("Simulation configuration definition for process element '" + identifier + "', but not available in process, skip.");
                // no matching element in process, so skip definition
                continue;
            }
            Map<String, DataObjectField> dataObjectFields = new HashMap<String, DataObjectField>();
            for (Element field : el.getChildren("field", simNamespace)) {
                String fieldName = field.getAttributeValue("name");
                String fieldType = field.getAttributeValue("type");
                DataDistributionType dataDistributionType = DataDistributionType.getEnum(fieldType);
                DataDistributionWrapper distWrapper = new DataDistributionWrapper(dataDistributionType);
                for (Element fieldElement : field.getChildren()) {
                    if (fieldElement.getName().endsWith("Distribution")) {
                        Distribution distribution = SimulationConfigurationParser.getDistribution(field, simNamespace, fieldType);
                        distWrapper.setDistribution(distribution);
                    }
                /*else if (fieldElement.getName().equals("range")) {
                			try{
                				double min = Double.parseDouble(fieldElement.getAttributeValue("min"));
                				distWrapper.setMin(min);
                			} catch (NumberFormatException e) {
                				// do nothing: min was not set and is automatically -Double.MAX_VALUE
                			}
                			
                			try{
                				double max = Double.parseDouble(fieldElement.getAttributeValue("max"));
                				distWrapper.setMax(max);
                			} catch (NumberFormatException e) {
                				// do nothing: max was not set and is automatically Double.MAX_VALUE
                			}
                			Distribution distribution = new UniformDistribution(distWrapper.getMin(), distWrapper.getMax());
                			distWrapper.setDistribution(distribution);
                		}*/
                }
                dataObjectFields.put(fieldName, new DataObjectField(distWrapper, nodeId, fieldName, fieldType));
            }
            dataObjects.put(nodeId, dataObjectFields);
        }
    }
    // System.out.println(processModel.getDataObjectsGraph().print());
    HashMap<String, Object> extensionAttributes = new HashMap<String, Object>();
    extensionAttributes.put("dataObjects", dataObjects);
    return extensionAttributes;
}
Also used : ProcessModel(de.hpi.bpt.scylla.model.process.ProcessModel) HashMap(java.util.HashMap) Element(org.jdom2.Element) Namespace(org.jdom2.Namespace) Distribution(de.hpi.bpt.scylla.model.configuration.distribution.Distribution) Map(java.util.Map) HashMap(java.util.HashMap)

Example 5 with Distribution

use of de.hpi.bpt.scylla.model.configuration.distribution.Distribution 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)

Aggregations

Distribution (de.hpi.bpt.scylla.model.configuration.distribution.Distribution)6 TimeDistributionWrapper (de.hpi.bpt.scylla.model.configuration.distribution.TimeDistributionWrapper)3 ProcessModel (de.hpi.bpt.scylla.model.process.ProcessModel)3 TimeUnit (java.util.concurrent.TimeUnit)3 SimulationConfiguration (de.hpi.bpt.scylla.model.configuration.SimulationConfiguration)2 BinomialDistribution (de.hpi.bpt.scylla.model.configuration.distribution.BinomialDistribution)2 ConstantDistribution (de.hpi.bpt.scylla.model.configuration.distribution.ConstantDistribution)2 EmpiricalDistribution (de.hpi.bpt.scylla.model.configuration.distribution.EmpiricalDistribution)2 EmpiricalStringDistribution (de.hpi.bpt.scylla.model.configuration.distribution.EmpiricalStringDistribution)2 ErlangDistribution (de.hpi.bpt.scylla.model.configuration.distribution.ErlangDistribution)2 ExponentialDistribution (de.hpi.bpt.scylla.model.configuration.distribution.ExponentialDistribution)2 NormalDistribution (de.hpi.bpt.scylla.model.configuration.distribution.NormalDistribution)2 PoissonDistribution (de.hpi.bpt.scylla.model.configuration.distribution.PoissonDistribution)2 TriangularDistribution (de.hpi.bpt.scylla.model.configuration.distribution.TriangularDistribution)2 UniformDistribution (de.hpi.bpt.scylla.model.configuration.distribution.UniformDistribution)2 SimulationModel (de.hpi.bpt.scylla.simulation.SimulationModel)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Element (org.jdom2.Element)2 ScyllaValidationException (de.hpi.bpt.scylla.exception.ScyllaValidationException)1