Beispiel #1
0
 public static void relinkOutgoingArcs(PetriNet net, Node from, Node to) {
   for (Flow f : net.getFlowRelation()) {
     if (f.getSource().equals(from)) {
       net.addFlow(to, f.getTarget());
       net.removeEdge(f);
     }
   }
 }
Beispiel #2
0
  public static void splitMixedPlaces(PetriNet net) {
    // perform node splitting (places)
    Collection<Place> ps = new ArrayList<Place>(net.getPlaces());
    Iterator<Place> places = ps.iterator();
    while (places.hasNext()) {
      Place place = places.next();

      if (net.getPredecessors(place).size() > 1 && net.getSuccessors(place).size() > 1) {
        Place newP = addPlace(net);
        Transition newT = addTransition(net);
        relinkOutgoingArcs(net, place, newP);
        net.addFlow(place, newT);
        net.addFlow(newT, newP);
      }
    }
  }
Beispiel #3
0
  public static void isolateTransitions(PetriNet net) {
    Collection<Transition> ts = new ArrayList<Transition>(net.getTransitions());
    Iterator<Transition> transitions = ts.iterator();
    while (transitions.hasNext()) {
      Transition transition = transitions.next();

      if (net.getPredecessors(transition).size() > 1) {
        Place newP = addPlace(net);
        Transition newT = addTransition(net);
        relinkIncomingArcs(net, transition, newT);

        net.addFlow(newT, newP);
        net.addFlow(newP, transition);
      }
      if (net.getSuccessors(transition).size() > 1) {
        Place newP = addPlace(net);
        Transition newT = addTransition(net);
        relinkOutgoingArcs(net, transition, newT);

        net.addFlow(transition, newP);
        net.addFlow(newP, newT);
      }
    }
  }
Beispiel #4
0
 public static Place addPlace(PetriNet net) {
   Place newP = new Place();
   newP.setId(getId());
   net.addNode(newP);
   return newP;
 }
Beispiel #5
0
 public static Transition addTransition(PetriNet net) {
   Transition newT = new Transition();
   newT.setId(getId());
   net.addNode(newT);
   return newT;
 }