use of de.hpi.bpt.scylla.model.process.ProcessModel 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.process.ProcessModel in project scylla by bptlab.
the class SimulationModel method doInitialSchedules.
@Override
public void doInitialSchedules() {
TimeUnit timeUnit = DateTimeUtils.getReferenceTimeUnit();
for (String processId : pSimMap.keySet()) {
ProcessSimulationComponents desmojObj = pSimMap.get(processId);
// schedule for end of simulation (if defined), aligned to global start time
ZonedDateTime endDateOfSimulationConf = desmojObj.getSimulationConfiguration().getEndDateTime();
Long endTimeRelativeToGlobalStart = Long.MAX_VALUE;
if (endDateOfSimulationConf != null) {
endTimeRelativeToGlobalStart = DateTimeUtils.getDuration(startDateTime, endDateOfSimulationConf);
ProcessSimulationStopEvent endEvent = new ProcessSimulationStopEvent(this, processId, traceIsOn());
// java.util.Date getTime() returns milliseconds
endEvent.schedule(new TimeSpan(endTimeRelativeToGlobalStart, timeUnit));
}
// schedule for start of simulation, aligned to global start time
ZonedDateTime startDateOfSimulationConf = desmojObj.getSimulationConfiguration().getStartDateTime();
long startTimeRelativeToGlobalStart = DateTimeUtils.getDuration(startDateTime, startDateOfSimulationConf);
ProcessModel processModel = desmojObj.getProcessModel();
int processInstanceId = desmojObj.incrementProcessInstancesStarted();
ProcessInstance firstProcessInstance = new ProcessInstance(this, processModel, processInstanceId, traceIsOn());
ProcessInstanceGenerationEvent startEvent = new ProcessInstanceGenerationEvent(this, processId, endTimeRelativeToGlobalStart, traceIsOn());
startEvent.schedule(firstProcessInstance, new TimeSpan(startTimeRelativeToGlobalStart, timeUnit));
}
if (endDateTime != null) {
// / java.util.Date getTime() returns milliseconds
long simulationDuration = DateTimeUtils.getDuration(startDateTime, endDateTime);
TimeInstant timeInstant = new TimeInstant(simulationDuration, DateTimeUtils.getReferenceTimeUnit());
for (String processId : pSimMap.keySet()) {
ProcessSimulationStopEvent abortEvent = new ProcessSimulationStopEvent(this, processId, traceIsOn());
abortEvent.schedule(timeInstant);
}
}
}
use of de.hpi.bpt.scylla.model.process.ProcessModel in project scylla by bptlab.
the class BPMNEvent method addToLog.
protected void addToLog(ProcessInstance processInstance) {
long timestamp = Math.round(getModel().presentTime().getTimeRounded(DateTimeUtils.getReferenceTimeUnit()));
String taskName = displayName;
Set<String> resources = new HashSet<String>();
SimulationModel model = (SimulationModel) getModel();
ProcessModel processModel = processInstance.getProcessModel();
String processScopeNodeId = SimulationUtils.getProcessScopeNodeId(processModel, nodeId);
ProcessNodeInfo info;
info = new ProcessNodeInfo(nodeId, processScopeNodeId, source, timestamp, taskName, resources, ProcessNodeTransitionType.EVENT_BEGIN);
model.addNodeInfo(processModel, processInstance, info);
info = new ProcessNodeInfo(nodeId, processScopeNodeId, source, timestamp, taskName, resources, ProcessNodeTransitionType.EVENT_TERMINATE);
model.addNodeInfo(processModel, processInstance, info);
}
use of de.hpi.bpt.scylla.model.process.ProcessModel in project scylla by bptlab.
the class GatewayEvent method eventRoutine.
@Override
public void eventRoutine(ProcessInstance processInstance) throws SuspendExecution {
SimulationModel model = (SimulationModel) getModel();
ProcessModel processModel = processInstance.getProcessModel();
try {
Set<Integer> idsOfPreviousNodes = processModel.getIdsOfPreviousNodes(nodeId);
Set<Integer> idsOfNextNodes = processModel.getIdsOfNextNodes(nodeId);
String message = null;
GatewayType type = processModel.getGateways().get(nodeId);
String convergeDivergeName = "Join and Split";
if (idsOfPreviousNodes.size() == 1) {
convergeDivergeName = "Split";
} else if (idsOfNextNodes.size() == 1) {
convergeDivergeName = "Join";
}
if (type == GatewayType.DEFAULT) {
message = "Default " + convergeDivergeName + " Gateway: " + displayName;
}
if (type == GatewayType.EXCLUSIVE) {
message = "Exclusive " + convergeDivergeName + " Gateway: " + displayName;
} else if (type == GatewayType.EVENT_BASED) {
message = "Eventbased " + convergeDivergeName + " Gateway: " + displayName;
} else if (type == GatewayType.INCLUSIVE) {
message = "Inclusive " + convergeDivergeName + " Gateway: " + displayName;
} else if (type == GatewayType.PARALLEL) {
message = "Parallel " + convergeDivergeName + " Gateway: " + displayName;
} else if (type == GatewayType.COMPLEX) {
message = "Complex " + convergeDivergeName + " Gateway: " + displayName;
} else {
// TODO write to log because element not supported
SimulationUtils.abort(model, processInstance, nodeId, traceIsOn());
return;
}
sendTraceNote(message);
// i.e. for splits: default behavior is the one of a parallel gateway
for (Integer nextNodeId : idsOfNextNodes) {
List<ScyllaEvent> events = SimulationUtils.createEventsForNextNode(this, pSimComponents, processInstance, nextNodeId);
// next DesmoJ event occurs immediately after start event
TimeSpan timeSpan = new TimeSpan(0);
for (ScyllaEvent event : events) {
int index = getNewEventIndex();
nextEventMap.put(index, event);
timeSpanToNextEventMap.put(index, timeSpan);
}
}
GatewayEventPluggable.runPlugins(this, processInstance);
scheduleNextEvents();
} catch (NodeNotFoundException | ScyllaValidationException | ScyllaRuntimeException e) {
System.err.println(e.getMessage());
e.printStackTrace();
SimulationUtils.abort(model, processInstance, nodeId, traceIsOn());
return;
}
}
use of de.hpi.bpt.scylla.model.process.ProcessModel in project scylla by bptlab.
the class TaskBeginEvent method addToLog.
@Override
protected void addToLog(ProcessInstance processInstance) {
long timestamp = Math.round(getModel().presentTime().getTimeRounded(DateTimeUtils.getReferenceTimeUnit()));
String taskName = displayName;
Set<String> resources = new HashSet<String>();
Set<ResourceObject> resourceObjects = processInstance.getAssignedResources().get(source).getResourceObjects();
for (ResourceObject res : resourceObjects) {
String resourceName = res.getResourceType() + "_" + res.getId();
resources.add(resourceName);
}
ProcessNodeTransitionType transition = ProcessNodeTransitionType.BEGIN;
SimulationModel model = (SimulationModel) getModel();
ProcessModel processModel = processInstance.getProcessModel();
String processScopeNodeId = SimulationUtils.getProcessScopeNodeId(processModel, nodeId);
ProcessNodeInfo info = new ProcessNodeInfo(nodeId, processScopeNodeId, source, timestamp, taskName, resources, transition);
model.addNodeInfo(processModel, processInstance, info);
}
Aggregations