/** * Innermost method for a reduction rule. Implementation of the abstract method from superclass. * * @net YNet to perform reduction * @element an for consideration. returns a reduced YNet or null if a given net cannot be reduced. */ public YNet reduceElement(YNet net, YExternalNetElement nextElement) { YNet reducedNet = net; if (nextElement instanceof YCondition) { YCondition condition = (YCondition) nextElement; Set postSet = condition.getPostsetElements(); Set preSet = condition.getPresetElements(); // \pre{p} = 1, \post{p} = 1 if (preSet.size() == 1 && postSet.size() == 1) { YTask t = (YTask) preSet.toArray()[0]; YTask u = (YTask) postSet.toArray()[0]; Set preSetOfu = u.getPresetElements(); Set postSetOfu = u.getPostsetElements(); // t,u and p are not reset // u does not have reset arcs Set postSetOft = new HashSet(t.getPostsetElements()); postSetOft.retainAll(postSetOfu); if (t.getSplitType() == YTask._AND && u.getSplitType() == YTask._AND && preSetOfu.size() == 1 && u.getRemoveSet().isEmpty() && t.getCancelledBySet().isEmpty() && u.getCancelledBySet().isEmpty() && condition.getCancelledBySet().isEmpty() && (!checkReset(postSetOfu)) && postSetOft.isEmpty()) { // set postflows from u to t Iterator postFlowIter = postSetOfu.iterator(); while (postFlowIter.hasNext()) { YExternalNetElement next = (YExternalNetElement) postFlowIter.next(); t.addPostset(new YFlow(t, next)); } // remove condition from postset of t t.removePostsetFlow(new YFlow(condition, t)); reducedNet.removeNetElement(condition); reducedNet.removeNetElement(u); t.addToYawlMappings(condition); t.addToYawlMappings(condition.getYawlMappings()); t.addToYawlMappings(u); t.addToYawlMappings(u.getYawlMappings()); return reducedNet; } // if nested } // if - size 1 } // endif - condition return null; }