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

de.uni.freiburg.iig.telematik.sepia.traversal.RandomPNTraverser 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.traversal;

import java.util.List;

import de.invation.code.toval.misc.valuegeneration.RandomChooser;
import de.invation.code.toval.validate.InconsistencyException;
import de.invation.code.toval.validate.ParameterException;
import de.invation.code.toval.validate.Validate;
import de.invation.code.toval.validate.ParameterException.ErrorCode;
import de.uni.freiburg.iig.telematik.sepia.petrinet.abstr.AbstractPetriNet;
import de.uni.freiburg.iig.telematik.sepia.petrinet.abstr.AbstractTransition;


/**
 * This flow control chooses the next transition to fire 
 * randomly out of the set of enabled Transitions.
 * 
 * @author Thomas Stocker
 */
public class RandomPNTraverser> extends PNTraverser {
	
	RandomChooser randomChooser = new RandomChooser();

	public RandomPNTraverser(AbstractPetriNet net) {
		super(net);
	}

	@Override
	public T chooseNextTransition(List enabledTransitions) throws InconsistencyException {
		if(!isValid())
			throw new ParameterException(ErrorCode.INCONSISTENCY, "Cannot provide transitions in invalid state.");
		Validate.notNull(enabledTransitions);
		Validate.noNullElements(enabledTransitions);
		
		if(enabledTransitions.isEmpty())
			return null;
		
		if(!net.getEnabledTransitions().containsAll(enabledTransitions))
			throw new ParameterException(ErrorCode.INCOMPATIBILITY, "Some of the given transitions re not enabled.");
		
		return randomChooser.chooseValue(enabledTransitions);
	}

	@Override
	public boolean isValid() {
		return randomChooser.isValid();
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy