org.jbpt.petri.querying.AbstractUntanglingBasedBehavioralQuerying Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jbpt-petri Show documentation
Show all versions of jbpt-petri Show documentation
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.querying;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import org.jbpt.petri.IFlow;
import org.jbpt.petri.IMarking;
import org.jbpt.petri.INetSystem;
import org.jbpt.petri.INode;
import org.jbpt.petri.IPlace;
import org.jbpt.petri.ITransition;
import org.jbpt.petri.unfolding.IBPNode;
import org.jbpt.petri.unfolding.ICondition;
import org.jbpt.petri.unfolding.IEvent;
import org.jbpt.petri.untangling.AbstractReductionBasedRepresentativeUntangling;
import org.jbpt.petri.untangling.IProcess;
import org.jbpt.petri.untangling.SignificanceCheckType;
import org.jbpt.petri.untangling.UntanglingSetup;
/**
* An implementation of the {@link IBehavioralQuerying} interface (using untanglings).
*
* @author Artem Polyvyanyy
*/
public class AbstractUntanglingBasedBehavioralQuerying, C extends ICondition, E extends IEvent, F extends IFlow, N extends INode, P extends IPlace, T extends ITransition, M extends IMarking>
extends AbstractStructuralQuerying
implements IBehavioralQuerying {
protected Collection> untangling = null;
private AbstractReductionBasedRepresentativeUntangling repUnt = null;
public AbstractUntanglingBasedBehavioralQuerying(INetSystem sys) {
super(sys);
UntanglingSetup setup = new UntanglingSetup();
setup.REDUCE = false;
setup.ISOMORPHISM_REDUCTION = false;
setup.SIGNIFICANCE_CHECK = SignificanceCheckType.TREE_OF_RUNS;
this.repUnt = new AbstractReductionBasedRepresentativeUntangling(this.sys,setup);
this.untangling = repUnt.getProcesses();
}
public AbstractUntanglingBasedBehavioralQuerying(INetSystem sys, Collection> untangling) {
super(sys);
this.untangling=untangling;
}
@Override
public boolean canOccurAll(Set setOfLabels) {
if (setOfLabels==null) return true;
if (setOfLabels.isEmpty()) return true;
for (IProcess pi : this.untangling) {
Set sol = new HashSet(setOfLabels);
for (E e : pi.getEvents()) {
if (sol.remove(e.getTransition().getLabel()))
if (sol.isEmpty()) return true;
}
}
return false;
}
@Override
public boolean canOccurAllExpanded(Set> setsOfLabels) {
if (setsOfLabels==null) return true;
if (setsOfLabels.isEmpty()) return true;
for (IProcess pi : this.untangling) {
Set> sol = new HashSet>();
for (E e : pi.getEvents()) {
for (Set setOfLabels : setsOfLabels) {
if (setOfLabels.contains(e.getTransition().getLabel())) {
if (sol.add(setOfLabels))
if (setsOfLabels.size()==sol.size())
return true;
}
}
}
}
return false;
}
@Override
public boolean canOccurOne(Set setOfLabels) {
if (setOfLabels==null) return true;
if (setOfLabels.isEmpty()) return true;
for (IProcess pi : this.untangling) {
for (E e : pi.getEvents()) {
if (setOfLabels.contains(e.getTransition().getLabel()))
return true;
}
}
return false;
}
@Override
public boolean canOccurOneExpanded(Set> setsOfLabels) {
Set sol = new HashSet();
for (Set s : setsOfLabels)
sol.addAll(s);
return this.cannotOccurOne(sol);
}
@Override
public boolean cannotOccurAll(Set setOfLabels) {
return !this.canOccurAll(setOfLabels);
}
@Override
public boolean cannotOccurOne(Set setOfLabels) {
return !this.canOccurOne(setOfLabels);
}
@Override
public boolean cannotOccurAllExpanded(Set> setsOfLabels) {
return !this.canOccurAllExpanded(setsOfLabels);
}
@Override
public boolean cannotOccurOneExpanded(Set> setsOfLabels) {
return !this.canOccurOneExpanded(setsOfLabels);
}
}