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

org.jbpt.petri.untangling.TreeStepIndex Maven / Gradle / Ivy

Go to download

The jBPT code library is a compendium of technologies that support research on design, execution, and evaluation of business processes.

The newest version!
package org.jbpt.petri.untangling;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import org.jbpt.petri.IFlow;
import org.jbpt.petri.IMarking;
import org.jbpt.petri.INode;
import org.jbpt.petri.IPlace;
import org.jbpt.petri.ITransition;

public class TreeStepIndex, N extends INode, P extends IPlace, T extends ITransition, M extends IMarking> 
{
	HashMap,Integer> s2p = new HashMap, Integer>();
	HashMap>> i2s = new HashMap>>();
	
	boolean isSignificant = true;

	class Interval {
		private int l;
	    private int r;
	    
	    public Interval(int l, int r){
	        this.l = l;
	        this.r = r;
	    }
	    
	    public int getL() { return l; }
	    public int getR() { return r; }
	    public void setL(int l) { this.l = l; }
	    public void setR(int r) { this.r = r; }
	    
	    @Override
		public String toString() {
			return "["+this.l+","+this.r+"]";
		}
	}
	
	public TreeStepIndex() {}
	
	public void process(TreeStep step) {
		Integer last	= step.getPosition();
		Integer preLast	= this.s2p.get(step);
		
		this.s2p.put(step,last);
		
		if (preLast!=null) {
			Interval interval = new Interval(preLast,last);
			
			Set> steps = new HashSet>();
			
			TreeStep s = step.getParent();
			if (s!=null) {
				while (s.getTransition()!=null) {
					if (s.getPosition()>interval.getL())
						steps.add(s);
					else if (s.getPosition()>> entry : this.i2s.entrySet()) {
			entry.getValue().remove(step);
			
			if (entry.getValue().isEmpty())
				this.isSignificant = false;
		}
	}

	public boolean isSignificant() {
		return this.isSignificant;
	}

	@Override
	protected TreeStepIndex clone() {
		TreeStepIndex clone = new TreeStepIndex();
		
		clone.isSignificant = this.isSignificant;
		
		clone.s2p = new HashMap, Integer>(this.s2p);
		
		clone.i2s = new HashMap>>();
		for (Map.Entry>> entry : this.i2s.entrySet()) {
			clone.i2s.put(entry.getKey(),new HashSet>(entry.getValue()));
		}
		
		return clone;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy