Search in sources :

Example 1 with SimulationConfiguration

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

the class InclusiveGatewayDistributionConversionPlugin method convertToDesmoJDistributions.

@SuppressWarnings("unchecked")
@Override
public Map<Integer, Object> convertToDesmoJDistributions(ProcessSimulationComponents pSimComponents) {
    Map<Integer, Object> branchingDistributionsInclusive = new HashMap<Integer, Object>();
    SimulationConfiguration simulationConfiguration = pSimComponents.getSimulationConfiguration();
    Map<Integer, BranchingBehavior> branchingBehaviors = (Map<Integer, BranchingBehavior>) simulationConfiguration.getExtensionValue(getName(), "branchingBehaviors");
    Long randomSeed = simulationConfiguration.getRandomSeed();
    ProcessModel processModel = pSimComponents.getProcessModel();
    SimulationModel model = pSimComponents.getModel();
    boolean showInReport = model.reportIsOn();
    boolean showInTrace = model.traceIsOn();
    for (Integer nodeId : branchingBehaviors.keySet()) {
        BranchingBehavior branchingBehavior = branchingBehaviors.get(nodeId);
        Map<Integer, Double> branchingProbabilities = branchingBehavior.getBranchingProbabilities();
        String name = processModel.getModelScopeId() + "_" + nodeId.toString();
        Map<Integer, BoolDistBernoulli> inclusiveDistributions = new HashMap<Integer, BoolDistBernoulli>();
        for (Integer nextNodeId : branchingProbabilities.keySet()) {
            Double probability = branchingProbabilities.get(nextNodeId);
            BoolDistBernoulli desmojDist = new BoolDistBernoulli(model, name, probability, showInReport, showInTrace);
            desmojDist.setSeed(randomSeed);
            inclusiveDistributions.put(nextNodeId, desmojDist);
        }
        branchingDistributionsInclusive.put(nodeId, inclusiveDistributions);
    }
    return branchingDistributionsInclusive;
}
Also used : ProcessModel(de.hpi.bpt.scylla.model.process.ProcessModel) BoolDistBernoulli(desmoj.core.dist.BoolDistBernoulli) HashMap(java.util.HashMap) BranchingBehavior(de.hpi.bpt.scylla.model.configuration.BranchingBehavior) SimulationConfiguration(de.hpi.bpt.scylla.model.configuration.SimulationConfiguration) Map(java.util.Map) HashMap(java.util.HashMap) SimulationModel(de.hpi.bpt.scylla.simulation.SimulationModel)

Example 2 with SimulationConfiguration

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

use of de.hpi.bpt.scylla.model.configuration.SimulationConfiguration 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 4 with SimulationConfiguration

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

the class ExclusiveGatewayDistributionConversionPlugin method convertToDesmoJDistributions.

@SuppressWarnings("unchecked")
@Override
public Map<Integer, Object> convertToDesmoJDistributions(ProcessSimulationComponents pSimComponents) {
    Map<Integer, Object> branchingDistributionsExclusive = new HashMap<Integer, Object>();
    SimulationConfiguration simulationConfiguration = pSimComponents.getSimulationConfiguration();
    Map<Integer, BranchingBehavior> branchingBehaviors = (Map<Integer, BranchingBehavior>) simulationConfiguration.getExtensionValue(getName(), "branchingBehaviors");
    Long randomSeed = simulationConfiguration.getRandomSeed();
    ProcessModel processModel = pSimComponents.getProcessModel();
    SimulationModel model = pSimComponents.getModel();
    boolean showInReport = model.reportIsOn();
    boolean showInTrace = model.traceIsOn();
    for (Integer nodeId : branchingBehaviors.keySet()) {
        BranchingBehavior branchingBehavior = branchingBehaviors.get(nodeId);
        Map<Integer, Double> branchingProbabilities = branchingBehavior.getBranchingProbabilities();
        String name = processModel.getModelScopeId() + "_" + nodeId.toString();
        DiscreteDistEmpirical<Integer> desmojDist = new DiscreteDistEmpirical<Integer>(model, name, showInReport, showInTrace);
        for (Integer nextNodeId : branchingProbabilities.keySet()) {
            Double probability = branchingProbabilities.get(nextNodeId);
            desmojDist.addEntry(nextNodeId, probability);
        }
        desmojDist.setSeed(randomSeed);
        branchingDistributionsExclusive.put(nodeId, desmojDist);
    }
    return branchingDistributionsExclusive;
}
Also used : ProcessModel(de.hpi.bpt.scylla.model.process.ProcessModel) DiscreteDistEmpirical(desmoj.core.dist.DiscreteDistEmpirical) HashMap(java.util.HashMap) BranchingBehavior(de.hpi.bpt.scylla.model.configuration.BranchingBehavior) SimulationConfiguration(de.hpi.bpt.scylla.model.configuration.SimulationConfiguration) Map(java.util.Map) HashMap(java.util.HashMap) SimulationModel(de.hpi.bpt.scylla.simulation.SimulationModel)

Example 5 with SimulationConfiguration

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

the class SimulationConfigurationParserPluggable method runPluginsPerSC.

private static void runPluginsPerSC(SimulationManager simEnvironment, SimulationConfiguration simulationConfiguration, ProcessModel processModel, Element sim) throws ScyllaValidationException {
    run(simEnvironment, SimulationConfigurationParserPluggable.class, simulationConfiguration, sim);
    Map<Integer, SimulationConfiguration> configurationsOfSubProcesses = simulationConfiguration.getConfigurationsOfSubProcesses();
    for (Element el : sim.getChildren()) {
        String elementName = el.getName();
        if (elementName.equals("subProcess")) {
            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;
            }
            SimulationConfiguration childSimulationConfiguration = configurationsOfSubProcesses.get(nodeId);
            ProcessModel subProcess = processModel.getSubProcesses().get(nodeId);
            runPluginsPerSC(simEnvironment, childSimulationConfiguration, subProcess, el);
        }
    }
}
Also used : ProcessModel(de.hpi.bpt.scylla.model.process.ProcessModel) SimulationConfiguration(de.hpi.bpt.scylla.model.configuration.SimulationConfiguration) Element(org.jdom2.Element)

Aggregations

SimulationConfiguration (de.hpi.bpt.scylla.model.configuration.SimulationConfiguration)10 ProcessModel (de.hpi.bpt.scylla.model.process.ProcessModel)10 SimulationModel (de.hpi.bpt.scylla.simulation.SimulationModel)6 HashMap (java.util.HashMap)6 Map (java.util.Map)5 Element (org.jdom2.Element)4 ScyllaValidationException (de.hpi.bpt.scylla.exception.ScyllaValidationException)3 BranchingBehavior (de.hpi.bpt.scylla.model.configuration.BranchingBehavior)3 TimeDistributionWrapper (de.hpi.bpt.scylla.model.configuration.distribution.TimeDistributionWrapper)3 Distribution (de.hpi.bpt.scylla.model.configuration.distribution.Distribution)2 DiscreteDistEmpirical (desmoj.core.dist.DiscreteDistEmpirical)2 TimeUnit (java.util.concurrent.TimeUnit)2 ResourceReference (de.hpi.bpt.scylla.model.configuration.ResourceReference)1 Resource (de.hpi.bpt.scylla.model.global.resource.Resource)1 CommonProcessElements (de.hpi.bpt.scylla.model.process.CommonProcessElements)1 CommonProcessElementsParser (de.hpi.bpt.scylla.parser.CommonProcessElementsParser)1 GlobalConfigurationParser (de.hpi.bpt.scylla.parser.GlobalConfigurationParser)1 ProcessModelParser (de.hpi.bpt.scylla.parser.ProcessModelParser)1 SimulationConfigurationParser (de.hpi.bpt.scylla.parser.SimulationConfigurationParser)1 BoolDistBernoulli (desmoj.core.dist.BoolDistBernoulli)1