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