From 768e3ca8a374b2b9db1bb3945ebda4ef93a4d5fe Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Sun, 19 Dec 2021 23:50:15 +0100 Subject: [PATCH] =?UTF-8?q?WIP:=20DATA=20Repr=C3=A9sentation=20Dilemna:=20?= =?UTF-8?q?Client=20=20XML=20=20Initial=20commit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/__pycache__/model.cpython-39.pyc | Bin 18957 -> 18957 bytes src/glimpse.py | 177 --------------------------- src/model.py | 4 - 3 files changed, 181 deletions(-) delete mode 100644 src/glimpse.py diff --git a/src/__pycache__/model.cpython-39.pyc b/src/__pycache__/model.cpython-39.pyc index c5cff16fb97ad9a4ce6c0ad82fef5845d9f6c08c..3da8ddf389520e72f9e2f92ea86a5990fc012ac4 100644 GIT binary patch delta 22 ccmeC3!q_{7kvox>mx}=iI;QO3$j#&h07I|^xBvhE delta 22 ccmeC3!q_{7kvox>mx}=iR4w*x pas de doublon -# 2) pas de node sans un node_parent_id - -conditions_set = set() - -# TODO cnd.get_coord("y"),... -for i in range(0, len(model.testmodel.get_conditions().get_conditions_array())): - cnd = model.testmodel.get_conditions().get_condition(i) - conditions_set.add((cnd.get_node_self_id(), - cnd.get_node_parent_id(), - cnd.get_coord("x"), - cnd.get_site(), - cnd.get_weight())) - - -class TreeNode(object): - - # TODO self.y = y,... - def __init__(self, id, parent, x, site, weight): - self.id = id - self.parent = parent - self.ch = [] - self.x = x - self.site = site - self.weight = weight - - def id(self): - return id - - def add_child(self, ch_id): - self.ch.append(ch_id) - self.ch = sorted(self.ch, key=id) - - -lll = [] - -for i in conditions_set: # sorted(conditions_set, key=id): - cndt = TreeNode(i[0], i[1], i[2], i[3], i[4]) # TODO y,z,... - lll.append(cndt) - -for i in lll: - for j in lll: - if (i.id == j.parent): - i.add_child(j) - -print('\n', "conditions (node_id, parent_id, nb enfants, liste enfants)", '\n') - -dsp = '' - -for i in lll: - dsp = str(i.id) + ' ' + str(i.parent) + ' n=' + str(len(i.ch)) + ' ' - if len(i.ch) > 0: - for c in range(0, len(i.ch)): - dsp += str(i.ch[c].id) + ', ' - print(dsp) - - -## - -A = Node("A") -A1 = Node("A1", parent=A) -A2 = Node("A2", parent=A) -A21 = Node("A21", parent=A2) - -root = Node([0]) - - - -https://python-gtk-3-tutorial.readthedocs.io/en/latest/treeview.html - - -A -├── A1 -└── A2 - └── A21 - -with open('input.txt', 'r') as f: - lines = f.readlines()[1:] - root = Node(lines[0].split(" ")[0]) - - for line in lines: - line = line.split(" ") - Node("".join(line[1:]).strip(), parent=find_by_attr(root, line[0])) - - for pre, _, node in RenderTree(root): - print("%s%s" % (pre, node.name)) - - -## - -print("\n*** Conditions tree ***") -print(type(model.testmodel.get_conditions())) -print("\n") -print(model.testmodel.get_conditions().get_condition(0).get_coord('x')) -print("\n") -print() -""" - -sp = model.testmodel.get_states().get_space(0) -size = model.testmodel.get_parameters().spaceparam.get_dimension().get_x() -sites = int(model.testmodel.get_parameters().spaceparam.get_site_multiplicity()) -nb_arrows = int(model.testmodel.get_states().get_space(0).get_nb_arrows()) - - -print("\n space size = ", size, " nb de sites par cellule = ", sites, - " nb total de flèches dans l'espace = ", nb_arrows) - -print(' | ', end=' ') - -# TODO Contrôles de cohérence des données -# condition et arrow -# 1) weight < weight_max (à définir) -# 2) arrow.site < site_multiplicity -# 3) arrow.x < space-param.dimension.x (idem autres axes) -# condition -# 1) parent <= condition.node_id max value (donc deux lectures) -# 2) pas de node sans un node_parent_id - - -for n in range(0, size + 1): - for s in range(0, sites): - arr = 0 - for a in range(0, nb_arrows): - if ( - sp.get_arrow(a).get_coord("x") == n - and sp.get_arrow(a).get_site() == s - ): - arr = sp.get_arrow(a).get_weight() - if arr > 0: - print(str(arr), end=' ') - else: - print('.', end=' ') - - print(' | ', end=' ') - -print('\n ' + ' ' * sites * 2, end='') - - -for k in range(0, size + 1): - if k < 9: - print(k + 1, end=' ' + ' ' * sites * 2) - else: - print(k + 1, end=' ' + ' ' * sites * 2) - -print('\n', ' | ', end = "") - -for n in range(0, size + 1): - for s in range(0, sites): - arr = 0 - for a in range(0, nb_arrows): - if ( - sp.get_arrow(a).get_coord("x") == n - and sp.get_arrow(a).get_site() == s - ): - arr = sp.get_arrow(a).get_weight() - if arr > 0: - print(str(arr), end=' ') - else: - print('.', end=' ') - - print(' | ', end=' ') - -print('\n\n', model.testmodel.get_space(0, 0, 0)) - diff --git a/src/model.py b/src/model.py index 0997c05..73779f3 100644 --- a/src/model.py +++ b/src/model.py @@ -477,7 +477,3 @@ modelPath = "../models/dimers random walk.xml" schemaPath = "../schemas/models_0.2.1.xmls" testmodel = Model(modelPath, schemaPath) - -# print(testmodel.get_conditions().get_condition(0).get_weight()) - -# TODO weight_max