roneditor.converter
Class RuleSimulator

java.lang.Object
  extended by roneditor.converter.RuleSimulator

public class RuleSimulator
extends java.lang.Object

This class uses the graph transformation engine AGG to transform an object net according to an object net rule.

Author:
enrico

Field Summary
private  java.util.Vector<org.eclipse.emf.ecore.EObject> createdArcs
           
private  java.util.Vector<ronmodel.ONNode> createdNodes
           
private  java.util.Vector<org.eclipse.emf.ecore.EObject> deletedArcs
           
private  java.util.Vector<ronmodel.ONNode> deletedNodes
           
private  boolean executed
           
private  agg.xt_basis.Graph graph
           
private  ronmodel.ObjectNet net
           
private  java.util.HashMap<ronmodel.ONArc,agg.xt_basis.Arc> net2graphArcMap
           
private  java.util.HashMap<ronmodel.ONNode,agg.xt_basis.Node> net2graphNodeMap
           
private  ronmodel.RonmodelFactory ronFactory
           
private  int TOKEN
           
private  agg.xt_basis.TypeSet typeSet
           
private  boolean undone
           
private  int WEIGHT
           
 
Constructor Summary
RuleSimulator()
          Creates a new RuleSimulator instance with precreated AGG type graph and Ronmodel factory.
 
Method Summary
 boolean applyRule(java.util.HashMap<ronmodel.ONNode,ronmodel.ONNode> mapping, ronmodel.Rule onRule, ronmodel.ObjectNet net)
          Applies an object net rule to an object net.
 boolean applyRule(ronmodel.Rule onRule, ronmodel.ObjectNet net)
          Applies an object net rule to an object net.
 java.util.Vector<java.util.HashMap<ronmodel.ONNode,ronmodel.ONNode>> calculateMappings(java.util.HashMap<ronmodel.ONNode,ronmodel.ONNode> mapping, ronmodel.Rule onRule, ronmodel.ObjectNet net)
           
private  void createMorphismNACs(agg.xt_basis.Rule aggRule)
          A petrinet morphism requires that the environment around each transition is preserved, meaning that the sum of all incoming arcs must remain constant (same for outoging arcs).
private  java.util.HashMap<ronmodel.ONNode,ronmodel.ONNode> createONMapping(agg.xt_basis.Match aggMatch, ronmodel.ObjectNet source, ronmodel.ObjectNet target, java.util.HashMap<ronmodel.ONNode,agg.xt_basis.Node> sourceMap, java.util.HashMap<ronmodel.ONNode,agg.xt_basis.Node> targetMap)
           
private  void createTypeGraph()
          Creates an AGG type graph with Place, Transition, ArcPT and ArcTP.
private  ronmodel.ONNode getONNodeByAggNode(agg.xt_basis.Node aggNode, java.util.HashMap<ronmodel.ONNode,agg.xt_basis.Node> map)
           
 boolean isApplicable(java.util.HashMap<ronmodel.ONNode,ronmodel.ONNode> mapping, ronmodel.Rule onRule, ronmodel.ObjectNet net)
          Checks whether the specified rule is applicable to the object net.
 boolean isApplicable(ronmodel.Rule onRule, ronmodel.ObjectNet net)
          Checks whether the specified rule is applicable to the object net.
private  void net2graph(ronmodel.ObjectNet net, agg.xt_basis.Graph graph, java.util.HashMap<ronmodel.ONNode,agg.xt_basis.Node> net2graphNodeMap, java.util.HashMap<ronmodel.ONArc,agg.xt_basis.Arc> net2graphArcMap)
          This method will convert an object net instance to an AGG graph.
private  void onMapping2aggMapping(java.util.HashMap<ronmodel.ONNode,ronmodel.ONNode> onMapping, agg.xt_basis.Match aggMapping, java.util.HashMap<ronmodel.ONNode,agg.xt_basis.Node> lhsMap, java.util.HashMap<ronmodel.ONNode,agg.xt_basis.Node> graphMap)
          Creates a mapping between a LHS of an AGG rule and an AGG graph based on a mapping defined between ONNodes
private  java.util.HashMap<ronmodel.ONNode,agg.xt_basis.Node> onRule2aggRule(ronmodel.Rule onRule, agg.xt_basis.Rule aggRule)
          converts a petri net rule to an AGG rule
 void redo()
          Redoes the rule application.
 void undo()
          Undoes the rule application.
private  void updateObjectNet(ronmodel.ObjectNet net, agg.xt_basis.Graph graph, java.util.HashMap<ronmodel.ONNode,agg.xt_basis.Node> net2graphNodeMap, java.util.HashMap<ronmodel.ONArc,agg.xt_basis.Arc> net2graphArcMap)
          Updates an object net according to an AGG graph.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

typeSet

private agg.xt_basis.TypeSet typeSet

net

private ronmodel.ObjectNet net

graph

private agg.xt_basis.Graph graph

ronFactory

private ronmodel.RonmodelFactory ronFactory

net2graphNodeMap

private java.util.HashMap<ronmodel.ONNode,agg.xt_basis.Node> net2graphNodeMap

net2graphArcMap

private java.util.HashMap<ronmodel.ONArc,agg.xt_basis.Arc> net2graphArcMap

createdNodes

private java.util.Vector<ronmodel.ONNode> createdNodes

deletedNodes

private java.util.Vector<ronmodel.ONNode> deletedNodes

createdArcs

private java.util.Vector<org.eclipse.emf.ecore.EObject> createdArcs

deletedArcs

private java.util.Vector<org.eclipse.emf.ecore.EObject> deletedArcs

executed

private boolean executed

undone

private boolean undone

TOKEN

private final int TOKEN
See Also:
Constant Field Values

WEIGHT

private final int WEIGHT
See Also:
Constant Field Values
Constructor Detail

RuleSimulator

public RuleSimulator()
Creates a new RuleSimulator instance with precreated AGG type graph and Ronmodel factory.

Method Detail

createTypeGraph

private void createTypeGraph()
Creates an AGG type graph with Place, Transition, ArcPT and ArcTP.


applyRule

public boolean applyRule(ronmodel.Rule onRule,
                         ronmodel.ObjectNet net)
Applies an object net rule to an object net.

Parameters:
onRule - An object net rule that should be applied to an object net.
net - The object net the rule should be applied to.
Returns:
true, if the rule was successfully applied

applyRule

public boolean applyRule(java.util.HashMap<ronmodel.ONNode,ronmodel.ONNode> mapping,
                         ronmodel.Rule onRule,
                         ronmodel.ObjectNet net)
Applies an object net rule to an object net.

Parameters:
mapping - A mapping between ONNodes in the LHS and the object net the rule should be applied to.
onRule - An object net rule that should be applied to an object net.
net - The object net the rule should be applied to.
Returns:
true, if the rule was successfully applied

calculateMappings

public java.util.Vector<java.util.HashMap<ronmodel.ONNode,ronmodel.ONNode>> calculateMappings(java.util.HashMap<ronmodel.ONNode,ronmodel.ONNode> mapping,
                                                                                              ronmodel.Rule onRule,
                                                                                              ronmodel.ObjectNet net)

isApplicable

public boolean isApplicable(ronmodel.Rule onRule,
                            ronmodel.ObjectNet net)
Checks whether the specified rule is applicable to the object net.

Parameters:
onRule - An object net rule that should be applied to an object net.
net - The object net the rule should be applied to.
Returns:
true, if the rule is applicable to the object net

isApplicable

public boolean isApplicable(java.util.HashMap<ronmodel.ONNode,ronmodel.ONNode> mapping,
                            ronmodel.Rule onRule,
                            ronmodel.ObjectNet net)
Checks whether the specified rule is applicable to the object net.

Parameters:
mapping - A mapping between ONNodes in the LHS and the object net the rule should be applied to.
onRule - An object net rule that should be applied to an object net.
net - The object net the rule should be applied to.
Returns:
true, if the rule is applicable to the object net

net2graph

private void net2graph(ronmodel.ObjectNet net,
                       agg.xt_basis.Graph graph,
                       java.util.HashMap<ronmodel.ONNode,agg.xt_basis.Node> net2graphNodeMap,
                       java.util.HashMap<ronmodel.ONArc,agg.xt_basis.Arc> net2graphArcMap)
This method will convert an object net instance to an AGG graph.

Parameters:
net - The object net which should be converted.
graph - A preferably empty graph where the result will be stored.
net2graphNodeMap - Stores the correspondence between petri net places/transitions and agg nodes (can be null)
net2graphArcMap - Stores the correspondence between petri net arcs and agg arcs (can be null)

onRule2aggRule

private java.util.HashMap<ronmodel.ONNode,agg.xt_basis.Node> onRule2aggRule(ronmodel.Rule onRule,
                                                                            agg.xt_basis.Rule aggRule)
converts a petri net rule to an AGG rule

Parameters:
onRule - The petri net rule that will be converted.
aggRule - A preferably empty rule where the result will be stored.
Returns:
HashMap of corresponding nodes between the ONRule LHS and the AGG rule LHS

onMapping2aggMapping

private void onMapping2aggMapping(java.util.HashMap<ronmodel.ONNode,ronmodel.ONNode> onMapping,
                                  agg.xt_basis.Match aggMapping,
                                  java.util.HashMap<ronmodel.ONNode,agg.xt_basis.Node> lhsMap,
                                  java.util.HashMap<ronmodel.ONNode,agg.xt_basis.Node> graphMap)
Creates a mapping between a LHS of an AGG rule and an AGG graph based on a mapping defined between ONNodes

Parameters:
onMapping - corresponding ONNodes in a LHS and in an object net
aggMapping - initially empty AGG match that will be updated according to the onMapping
lhsMap - relation between the ONRule LHS and the AGG LHS
graphMap - relation between the object net and the AGG graph

createMorphismNACs

private void createMorphismNACs(agg.xt_basis.Rule aggRule)
A petrinet morphism requires that the environment around each transition is preserved, meaning that the sum of all incoming arcs must remain constant (same for outoging arcs). This method adds NACs that ensure that the matching morphism will be a valid petrinet morphism.

Parameters:
aggRule - The rule the NACs should be added to.

updateObjectNet

private void updateObjectNet(ronmodel.ObjectNet net,
                             agg.xt_basis.Graph graph,
                             java.util.HashMap<ronmodel.ONNode,agg.xt_basis.Node> net2graphNodeMap,
                             java.util.HashMap<ronmodel.ONArc,agg.xt_basis.Arc> net2graphArcMap)
Updates an object net according to an AGG graph. Note that the graph will be completly rebuild if no HashMaps are specified.

Parameters:
graph - The graph corresponding with the object net.
net2graphNodeMap - HashMap with corresponding places/transitions and AGG nodes.

createONMapping

private java.util.HashMap<ronmodel.ONNode,ronmodel.ONNode> createONMapping(agg.xt_basis.Match aggMatch,
                                                                           ronmodel.ObjectNet source,
                                                                           ronmodel.ObjectNet target,
                                                                           java.util.HashMap<ronmodel.ONNode,agg.xt_basis.Node> sourceMap,
                                                                           java.util.HashMap<ronmodel.ONNode,agg.xt_basis.Node> targetMap)

getONNodeByAggNode

private ronmodel.ONNode getONNodeByAggNode(agg.xt_basis.Node aggNode,
                                           java.util.HashMap<ronmodel.ONNode,agg.xt_basis.Node> map)

undo

public void undo()
Undoes the rule application.


redo

public void redo()
Redoes the rule application.