WIP: premières explorations.
This commit is contained in:
parent
75c63e8e24
commit
ae6981a624
|
@ -126,7 +126,7 @@
|
||||||
|
|
||||||
</transition>
|
</transition>
|
||||||
|
|
||||||
<transition id="do_anything_you_want" date="1630000000" author="Ni moi !"
|
<transition id="do_anything_you_want !" date="1630000000" author="Ni moi !"
|
||||||
parent="9" probability="1">
|
parent="9" probability="1">
|
||||||
|
|
||||||
<arrow site="1" weight="0" x="0"/>
|
<arrow site="1" weight="0" x="0"/>
|
||||||
|
@ -136,7 +136,7 @@
|
||||||
|
|
||||||
</transition>
|
</transition>
|
||||||
|
|
||||||
<transition id="do_nothing" date="1630000000" author="Ni moi !"
|
<transition id="do_nothing or something" date="1630000000" author="Ni moi !"
|
||||||
parent="5" probability="1">
|
parent="5" probability="1">
|
||||||
|
|
||||||
<arrow site="1" weight="0" x="0"/>
|
<arrow site="1" weight="0" x="0"/>
|
||||||
|
|
Binary file not shown.
|
@ -5,55 +5,49 @@ import model
|
||||||
# TODO Contrôles de cohérence des données
|
# TODO Contrôles de cohérence des données
|
||||||
# 1) node_id <> pas de doublons
|
# 1) node_id <> pas de doublons
|
||||||
# 2) tout node doit avoir un node_parent_id
|
# 2) tout node doit avoir un node_parent_id
|
||||||
|
# Process
|
||||||
|
# 1) lors de l'adoption, le parent doit exister
|
||||||
|
|
||||||
|
|
||||||
class CondTreeNode(NodeMixin):
|
class TreeNode(NodeMixin):
|
||||||
def __init__(self, id, parent_id, x, site, weight):
|
def __init__(self, id, parent_id, weight, site, x, y, z):
|
||||||
super(CondTreeNode, self).__init__()
|
super(TreeNode, self).__init__()
|
||||||
self.id = id
|
self.id = id
|
||||||
self.parent_id = parent_id
|
self.parent_id = parent_id
|
||||||
self.parent = None
|
self.parent = None
|
||||||
self.x = x # TODO self.y = y,z...
|
|
||||||
self.site = site
|
|
||||||
self.weight = weight
|
self.weight = weight
|
||||||
|
self.site = site
|
||||||
|
self.x = x
|
||||||
|
self.y = y
|
||||||
|
self.z = z
|
||||||
|
|
||||||
def is_adopted_by(self, parent_node):
|
def is_adopted_by(self, parent_node):
|
||||||
# print('orphan node ', self.id, ' is adopted by node ', parent_node.id)
|
# print('orphan node ', self.id, ' is adopted by node ', parent_node.id)
|
||||||
self.parent = parent_node
|
self.parent = parent_node
|
||||||
|
|
||||||
|
|
||||||
class TransTreeNode(NodeMixin):
|
|
||||||
def __init__(self, id, parent_id):
|
|
||||||
super(TransTreeNode, self).__init__()
|
|
||||||
self.parent_id = parent_id
|
|
||||||
self.parent = None
|
|
||||||
self.id = id
|
|
||||||
|
|
||||||
def is_adopted_by(self, parent_node):
|
|
||||||
# print('orphan transition is adopted by leaf node', parent_node.id)
|
|
||||||
self.parent = parent_node
|
|
||||||
|
|
||||||
|
|
||||||
conditions_set = set()
|
conditions_set = set()
|
||||||
transitions_set = set()
|
transitions_set = set()
|
||||||
root = None
|
root = None
|
||||||
|
|
||||||
for i in range(0, len(model.testmodel.get_conditions().get_all())):
|
for i in range(0, len(model.testmodel.get_conditions().get_all())):
|
||||||
condition = model.testmodel.get_conditions().get_one(i)
|
condition = model.testmodel.get_conditions().get_one(i)
|
||||||
tmp = CondTreeNode(condition.get_self_id(),
|
tmp = TreeNode(condition.get_self_id(),
|
||||||
condition.get_parent_id(),
|
condition.get_parent_id(),
|
||||||
condition.get_coord("x"),
|
condition.get_weight(),
|
||||||
condition.get_site(),
|
condition.get_site(),
|
||||||
condition.get_weight())
|
condition.get_coord("x"),
|
||||||
|
None, None)
|
||||||
conditions_set.add(tmp)
|
conditions_set.add(tmp)
|
||||||
if tmp.parent_id == 0:
|
if tmp.parent_id == 0:
|
||||||
root = tmp
|
root = tmp
|
||||||
|
|
||||||
for i in range(0, len(model.testmodel.get_transitions().get_all())):
|
for i in range(0, len(model.testmodel.get_transitions().get_all())):
|
||||||
transition = model.testmodel.get_transitions().get_one(i)
|
transition = model.testmodel.get_transitions().get_one(i)
|
||||||
transitions_set.add(TransTreeNode(
|
transitions_set.add(TreeNode(
|
||||||
transition.get_id(),
|
transition.get_id(),
|
||||||
transition.get_parent()))
|
transition.get_parent(),
|
||||||
|
None, None, None, None, None))
|
||||||
|
|
||||||
for i in conditions_set:
|
for i in conditions_set:
|
||||||
for j in conditions_set:
|
for j in conditions_set:
|
||||||
|
@ -71,7 +65,7 @@ for condition_node in LevelOrderIter(root):
|
||||||
|
|
||||||
for pre, fill, node in RenderTree(root):
|
for pre, fill, node in RenderTree(root):
|
||||||
treestr = u"%s%s" % (pre, node.id)
|
treestr = u"%s%s" % (pre, node.id)
|
||||||
if type(node) == CondTreeNode:
|
if type(node) == TreeNode:
|
||||||
print(treestr.ljust(19), node.weight, ' arrow(s) at [site', node.site,
|
print(treestr.ljust(19), node.weight, ' arrow(s) at [site', node.site,
|
||||||
'in cell', node.x, end='')
|
'in cell', node.x, end='')
|
||||||
if not node.depth == 2: # tree.depth()
|
if not node.depth == 2: # tree.depth()
|
||||||
|
|
|
@ -19,16 +19,10 @@ print('path: ', tree.path)
|
||||||
print('children: ', tree.children)
|
print('children: ', tree.children)
|
||||||
print('descendants[0]: ', tree.descendants[0])
|
print('descendants[0]: ', tree.descendants[0])
|
||||||
|
|
||||||
print('\n to fix: (leaves)', end='\n\n')
|
|
||||||
for pre, fill, node in RenderTree(tree):
|
for pre, fill, node in RenderTree(tree):
|
||||||
treestr = u"%s%s" % (pre, node.id)
|
treestr = u"%s%s" % (pre, node.id)
|
||||||
if type(node) == rules_tree.CondTreeNode:
|
print(treestr.ljust(46))
|
||||||
print(treestr.ljust(19), node.weight, ' arrow(s) at [site', node.site,
|
|
||||||
'in cell', node.x, end='')
|
|
||||||
if not node.depth == 2: # tree.depth()
|
|
||||||
print(end=']\n')
|
|
||||||
else:
|
|
||||||
print('] --> ', node.children[0].id, end='\n')
|
|
||||||
|
|
||||||
|
print('\nNext step: single rule extraction from tree.',
|
||||||
print('\nNext step: single rule extraction from tree. 😃️')
|
' 😃️\nand learn how to use the Newick format.')
|
||||||
|
# http://etetoolkit.org/docs/2.3/tutorial/tutorial_trees.html
|
||||||
|
|
Loading…
Reference in New Issue