All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.uni.freiburg.iig.telematik.sepia.petrinet.pt.PTNet Maven / Gradle / Ivy

Go to download

SEPIA provides implementations for various types of Petri nets. Along Place/Transition-nets, it supports Petri nets with distinguishable token colors and defines coloured workflow nets, where coloured tokens are interpreted as data elements used during process execution. To support information flow analysis of processes, SEPIA defines so-called IF-Nets, tailored for security-oriented workflow modeling which enable users to assign security-levels (HIGH, LOW) to transitions, data elements and persons/agents participating in the process execution.

The newest version!
package de.uni.freiburg.iig.telematik.sepia.petrinet.pt;

import java.util.Set;

import de.uni.freiburg.iig.telematik.sepia.event.CapacityEvent;
import de.uni.freiburg.iig.telematik.sepia.exception.PNException;
import de.uni.freiburg.iig.telematik.sepia.mg.pt.PTMarkingGraph;
import de.uni.freiburg.iig.telematik.sepia.petrinet.abstr.AbstractPlace;
import de.uni.freiburg.iig.telematik.sepia.petrinet.pt.abstr.AbstractPTNet;


public class PTNet extends AbstractPTNet{
	
	private static final long serialVersionUID = 7377840837566864887L;

	public PTNet() {
		super();
	}

	public PTNet(Set places, Set transitions, PTMarking initialMarking) {
		super(places, transitions, initialMarking);
	}
	
	@Override
	public PTMarking fireCheck(String transitionName) throws PNException {
		PTMarking newMarking = cloneMarking();
		PTTransition transition = getTransition(transitionName);
		for(PTFlowRelation relation: transition.getIncomingRelations()){
			String inputPlaceName = relation.getPlace().getName();
			newMarking.set(inputPlaceName, newMarking.get(inputPlaceName) - relation.getWeight());
		}
		for(PTFlowRelation relation: transition.getOutgoingRelations()){
			String outputPlaceName = relation.getPlace().getName();
			Integer oldState = (newMarking.get(outputPlaceName) == null ? 0 : newMarking.get(outputPlaceName));
			newMarking.set(outputPlaceName, oldState + relation.getWeight());
		}
		return newMarking;
	}

	@Override
	public PTMarking createNewMarking() {
		return new PTMarking();
	}

	@Override
	protected PTTransition createNewTransition(String name, String label, boolean isSilent) {
		return new PTTransition(name, label, isSilent);
	}

	@Override
	protected PTPlace createNewPlace(String name, String label) {
		return new PTPlace(name, label);
	}

	@Override
	protected PTFlowRelation createNewFlowRelation(PTPlace place, PTTransition transition, Integer weight) {
		return new PTFlowRelation(place, transition, weight);
	}

	@Override
	protected PTFlowRelation createNewFlowRelation(PTTransition transition, PTPlace place, Integer weight) {
		return new PTFlowRelation(transition, place, weight);
	}
	
	@Override
	protected PTFlowRelation createNewFlowRelation(PTPlace place, PTTransition transition) {
		return new PTFlowRelation(place, transition);
	}

	@Override
	protected PTFlowRelation createNewFlowRelation(PTTransition transition, PTPlace place) {
		return new PTFlowRelation(transition, place);
	}

	@Override
	public PTNet newInstance() {
		return new PTNet();
	}

	@Override
	public void capacityChanged(CapacityEvent> o) {}
	
	@Override
	public Class getMarkingGraphClass() {
		return PTMarkingGraph.class;
	}

	public static void main(String[] args) {
		PTNet net = new PTNet();
		net.addPlace("p1");
		net.addTransition("t1");
		net.addFlowRelationPT("p1", "t1", 12);
		System.out.println(net);
		PTFlowRelation rel = net.addFlowRelationPT("p1", "t1", 2);
		System.out.println(rel);
		System.out.println(net);
		System.out.println(net.getPlace("p1").getOutgoingRelations().size());
                
	}
	
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy