Tweak matcher (compute connected components in advance). Simple pattern matching with RAMification (incl. Python expressions) seems to work.
This commit is contained in:
parent
bed3529676
commit
4160a8953e
13 changed files with 388 additions and 70 deletions
|
|
@ -7,7 +7,10 @@ from services.scd import SCD
|
|||
from framework.conformance import Conformance
|
||||
from services.od import OD
|
||||
from transformation.ramify import ramify
|
||||
from services.bottom.V0 import Bottom
|
||||
from services.primitives.integer_type import Integer
|
||||
from pattern_matching import mvs_adapter
|
||||
from pattern_matching.matcher import MatcherVF2
|
||||
|
||||
import sys
|
||||
|
||||
|
|
@ -62,6 +65,9 @@ def main():
|
|||
int_type_id = state.read_dict(state.read_root(), "Integer")
|
||||
int_type = UUID(state.read_value(int_type_id))
|
||||
|
||||
string_type_id = state.read_dict(state.read_root(), "String")
|
||||
string_type = UUID(state.read_value(string_type_id))
|
||||
|
||||
# scd2 = SCD(scd_node, state)
|
||||
# for el in scd2.list_elements():
|
||||
# print(el)
|
||||
|
|
@ -70,7 +76,7 @@ def main():
|
|||
model_id = state.create_node()
|
||||
scd = SCD(model_id, state)
|
||||
scd.create_class("Abstract", abstract=True)
|
||||
scd.create_class("A", min_c=1, max_c=10)
|
||||
scd.create_class("A", min_c=1, max_c=2)
|
||||
scd.create_inheritance("A", "Abstract")
|
||||
scd.create_model_ref("Integer", int_type)
|
||||
scd.create_attribute_link("A", "Integer", "size", False)
|
||||
|
|
@ -97,16 +103,46 @@ def main():
|
|||
od = OD(model_id, inst_id, state)
|
||||
|
||||
od.create_object("a", "A")
|
||||
od.create_object("a2", "A")
|
||||
od.create_object("b", "B")
|
||||
od.create_link("A2B", "a", "b")
|
||||
od.create_link("A2B", "a2", "b")
|
||||
|
||||
od.create_slot("size", "a", od.create_integer_value(42))
|
||||
od.create_slot("size", "a", od.create_integer_value("a.size", 42))
|
||||
|
||||
print("checking conformance....")
|
||||
conf2 = Conformance(state, inst_id, model_id)
|
||||
print("conforms?", conf2.check_nominal(log=True))
|
||||
|
||||
ramify(state, model_id)
|
||||
ramified_MM_id = ramify(state, model_id)
|
||||
|
||||
pattern_id = state.create_node()
|
||||
pattern = OD(ramified_MM_id, pattern_id, state)
|
||||
|
||||
pattern.create_object("a1", "A")
|
||||
pattern.create_slot("size", "a1", pattern.create_string_value("a1.size", 'v < 100'))
|
||||
# pattern.create_object("a2", "A")
|
||||
# pattern.create_slot("size", "a2", pattern.create_string_value("a2.size", '99'))
|
||||
|
||||
pattern.create_object("b1", "B")
|
||||
# pattern.create_link("A2B", "a1", "b1")
|
||||
|
||||
conf3 = Conformance(state, pattern_id, ramified_MM_id)
|
||||
print("conforms?", conf3.check_nominal(log=True))
|
||||
|
||||
host = mvs_adapter.model_to_graph(state, inst_id)
|
||||
guest = mvs_adapter.model_to_graph(state, pattern_id)
|
||||
|
||||
print(host.vtxs)
|
||||
print(host.edges)
|
||||
|
||||
print("matching...")
|
||||
matcher = MatcherVF2(host, guest, mvs_adapter.RAMCompare(Bottom(state)))
|
||||
prev = None
|
||||
for m in matcher.match():
|
||||
print("\nMATCH:\n", m)
|
||||
input()
|
||||
print("DONE")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue