org.jbpt.petri.unfolding.SoundUnfoldingMSMS 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.unfolding;
/**
* Unfolding for soundness checks (multi-source-multi-sink nets)
*
* @author Artem Polyvyanyy
*/
public class SoundUnfoldingMSMS extends SoundUnfolding {
/*protected NetSystem originativeSystem = null;
protected Map nodeMapping = null;
*//**
* @assumption Net system is free-choice
* @assumption Net system is multi-terminal
* @assumption Net system is acyclic
*//*
public SoundUnfoldingMSMS(NetSystem sys) {
this.originativeSystem = sys;
this.nodeMapping = new HashMap();
this.sys = this.constructAugmentedVersion();
this.initialBranchingProcess = new Cut(this.sys);
this.totalOrderTs = new ArrayList(this.sys.getTransitions());
BranchingProcessSetup setup = new BranchingProcessSetup();
setup.ADEQUATE_ORDER = new EsparzaAdequateOrderForArbitrarySystems();
setup.MAX_BOUND = Integer.MAX_VALUE;
setup.MAX_EVENTS = Integer.MAX_VALUE;
this.setup = setup;
// construct unfolding
this.construct();
}
*//**
* Construct the augmented version of the net
* - Add a fresh source place s
* - Add a fresh start transition t_c for every combination c of source places of the net
* - Add a fresh flow from s to every start transition
* - For every start transition t_c, add fresh flow from t_c to every place in c
*//*
private NetSystem constructAugmentedVersion() {
NetSystem result = this.originativeSystem.clone(this.nodeMapping);
Collection sources = result.getSourcePlaces();
Place s = new Place();
for (int i=0; i cg = new CombinationGenerator(sources, i+1);
while (cg.hasMore()) {
Collection comb = cg.getNextCombination();
Transition t = new Transition();
result.addFlow(s,t);
for (Place p : comb) {
result.addFlow(t,p);
}
}
}
result.loadNaturalMarking();
return result;
}
@Override
public NetSystem getOriginativeNetSystem() {
return this.originativeSystem;
}
@Override
public boolean isSound() {
Collection augTs = new ArrayList(this.sys.getTransitions());
Collection augStartTs = new ArrayList(this.sys.getPostset(this.sys.getSourcePlaces().iterator().next()));
augTs.removeAll(augStartTs);
Set cs = new HashSet(this.getLocallyUnsafeConditions());
cs.addAll(this.getLocalDeadlockConditions());
for (Event e : this.getEvents()) {
boolean flag = false;
for (Condition c : cs) {
if (this.areCausal(e,c) || this.areCausal(c,e)) {
flag = true;
break;
}
}
if (flag) continue;
augTs.remove(e.getTransition());
}
return augTs.isEmpty();
}
public void completeOriginativeSystemWithCorrectInstantiations() {
Set errors = new HashSet(this.getLocallyUnsafeConditions());
// TODO
//errors.addAll(this.getLocalDeadlockConditions());
OccurrenceNet occ = this.getOccurrenceNet();
Collection starts = new ArrayList(occ.getPostset(occ.getSourcePlaces().iterator().next()));
Collection correctStarts = new ArrayList();
TransitiveClosure tc = new TransitiveClosure(occ);
for (Transition start : starts) {
boolean flag = true;
for (ICondition error : errors) {
if (tc.hasPath(start, occ.getPlace(error))) {
flag = false;
break;
}
}
if (flag)
correctStarts.add(start);
}
Place src = new Place();
this.originativeSystem.addPlace(src);
for (Transition start : correctStarts) {
Transition t = new Transition();
this.originativeSystem.addFlow(src,t);
for (Place p : occ.getPostset(start)) {
Place pp = this.getOriginativePlace(occ,p);
this.originativeSystem.addFlow(t,pp);
}
}
}
private Place getOriginativePlace(IOccurrenceNet occ, Place p) {
Place pp = occ.getCondition(p).getPlace(); // place in this.sys
for (Map.Entry entry : this.nodeMapping.entrySet()) {
if (entry.getValue().equals(pp))
return (Place) entry.getKey();
}
return null;
}
*//**
* Get original net without augmentation
* @return original net
*//*
public PetriNet getOriginalNet() {
return this.originativeSystem;
}*/
}