public bool Validate(BPMNTrail trail) { this.trail = trail; StartEvent se = trail.GetFirstStartEvent(); RunStates(se, graph); return(results.TrueForAll(x => x.Equals(true))); }
public BPMNTrail Clean(BPMNTrail trail) { this.trail = trail; FindEvents(); RemoveEvents(); RemoveRedundantMergeAndSplitNodes(); CombineLinkedSplitNodes(); CombineLinkedMergeNodes(); return(trail); }
public XMLBuilder(Processor graph, List <List <string> > trace, Dictionary <string, string> idLabel, Dictionary <string, string> labelId) { trail = new BPMNTrail(); this.graph = graph; this.trace = trace; tree = new Dictionary <string, HashSet <Tuple <string, string> > >(); optimus = new XMLOptimizer(); this.idLabel = idLabel; this.labelId = labelId; }
private void RemoveRepeatingEvents(Processor graph, List <List <string> > traces, BPMNTrail trail, Validator validator, out BPMNTrail workingTrail) { workingTrail = trail; BPMNTrail oldTrail; List <string> ids = FindRepeatingEvents(traces); foreach (string id in ids) { oldTrail = workingTrail; workingTrail.RemoveTaskAndMoveSequences(id); if (!validator.Validate(workingTrail)) { workingTrail = oldTrail; } } }
private void RemoveRepeatingSequences(Processor graph, List <List <string> > traces, BPMNTrail trail, Validator validator, out BPMNTrail workingTrail) { //Key = the repeating sequence Value = the start loc and a list of start locs of the repeats. Dictionary <List <string>, Tuple <int, List <int> > > dict; Dictionary <string, string> idGate = new Dictionary <string, string>(); workingTrail = trail; BPMNTrail oldTrail; foreach (List <string> trace in traces) { dict = FindRepeatingSequence(trace); if (dict.Keys.Count > 0) { //Move relevant XOR gates here. //Starting at the first of the repeating sequences go through the flow in the graph. //If it contains XORs that needs fx 12121 move the XOR to after 1. foreach (List <string> repSeq in dict.Keys) { FixMergeGateLocationsInRepeatedSequences(repSeq, dict[repSeq], trace, workingTrail); string eventId = string.Empty; string gateId = string.Empty; for (int i = 0; i <= dict[repSeq].Item1; i++) { eventId += trace[i]; } if (!eventId.Equals(string.Empty) && !idGate.Keys.Contains(eventId)) { oldTrail = workingTrail; gateId = "mergeGate" + buffer; workingTrail.InsertMergeGate(eventId, gateId, "seqflowgateevent" + buffer); idGate[eventId] = gateId; List <string> ids = new List <string>(); foreach (int pos in dict[repSeq].Item2) { string doubleEventId = string.Empty; for (int i = 0; i < pos + repSeq.Count; i++) { doubleEventId += trace[i]; if (i >= pos) { ids.Add(doubleEventId); } } } workingTrail.AddBackLoopingSequence(gateId, ids[0], "backLoopSeqFlow" + buffer); foreach (string id in ids) { workingTrail.RemoveTaskAndMoveSequences(id); } buffer++; if (!validator.Validate(workingTrail)) { workingTrail = oldTrail; } } } } } }
private BPMNTrail FixMergeGateLocationsInRepeatedSequences(List <string> repSeq, Tuple <int, List <int> > startLocs, List <string> trace, BPMNTrail workingTrail) { string idString = string.Empty; List <string> repSeqIds = new List <string>(); List <string> ids = new List <string>(); for (int i = 0; i < repSeq.Count + startLocs.Item1; i++) { idString += trace[i]; if (i >= startLocs.Item1) { repSeqIds.Add(idString); } } if (!(repSeqIds[0] + repSeqIds[0]).Equals(repSeqIds[1])) { foreach (int pos in startLocs.Item2) { idString = string.Empty; for (int i = 0; i < pos + repSeq.Count; i++) { idString += trace[i]; if (i >= pos) { ids.Add(idString); } } } Task current = workingTrail.GetTask(repSeqIds.Last <string>()); Task helperTask1 = null; Task helperTask2 = null; ExclusiveGateway eg = null; SequenceFlow seqFlow = null; int index = 0; string nextId = ids[0]; string helper = string.Empty; while (!current.id.Equals(ids.Last <string>())) { helper = workingTrail.GetSequenceFlow(current.outgoing[0]).targetRef; if (helper.Equals(nextId)) { if (!nextId.Equals(ids.Last <string>())) { nextId = ids[index += 1]; } current = workingTrail.GetTask(helper); } else if (workingTrail.ExclusiveGatewayExists(helper)) { eg = workingTrail.GetExclusiveGateWay(helper); foreach (string s in eg.outgoing) { helper = workingTrail.GetSequenceFlow(s).targetRef; if (helper.Equals(nextId)) { seqFlow = workingTrail.GetSequenceFlow(s); helperTask1 = workingTrail.GetTask(helper); helperTask2 = workingTrail.GetTaskByNameIfIdInList(helperTask1.name, repSeqIds); if (!repSeqIds.Contains(current.id)) { workingTrail.MoveMergeGate(eg.id, workingTrail.GetSequenceFlowByTargetRefId(helperTask2.id).sourceRef, helperTask1.id); } if (!nextId.Equals(ids.Last <string>())) { nextId = ids[index += 1]; } current = helperTask1; break; } } } } } return(workingTrail); }
internal BPMNTrail Optimize(Processor graph, List <List <string> > traces, Dictionary <string, HashSet <Tuple <string, string> > > tree, BPMNTrail trail, Dictionary <string, string> labelId) { //MAKE A TEST CASE WHERE THIS IS TRUE PLZ //FIND WAY TO LOOP EVEN ON A SINGLE EVENT IF IT OCCURS SEVERAL TIMES //test if we can execute the events in the graph if we skip the events lying in between //the the original list and the repeats i.e. if a1 -> a2 -> a3 -> a1 -> a2 -> a4 is the original //then a1 -> a2 -> a4 must also be possible //if this is the case remove the events in the bpmn that corrosponds to the second a1 -> a2 //add a merge gate infront of the first a1 -> a2 let a3 point to that and let the first a2 -> a4 //also find a way to handle when we have several alternating states fx a1 -> a2 -> a1 -> a2 -> ... //test that all new executions that may result from the change is still valid in dcr //collapse diverging gates if chained //finally sweep and remove any merge/xor gates with a 1:1 in/out //Maybe take longest found repeating sequence do the thing, and then rerun the finder etc. //If split inside of a repeating sequence find a way to move it back to the corret predeceding event. Cleaner cleaner = new Cleaner(traces, labelId); Validator validator = new Validator(graph, labelId); BPMNTrail workingTrail; RemoveRepeatingSequences(graph, traces, trail, validator, out workingTrail); RemoveRepeatingEvents(graph, traces, workingTrail, validator, out workingTrail); workingTrail = cleaner.Clean(workingTrail); return(workingTrail); }
public void Optimize() { trail = optimus.Optimize(graph, trace, tree, trail, labelId); }