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