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;
}
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;
}
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;
}
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;
}
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);
}
}
}
Aggregations