Esempio n. 1
0
def tree_from_order(order):
    nodes = script_tree.getNodes(tree)
    for n in nodes:
        if not script_tree.isRoot(tree, n):
            if script_tree.isLeaf(tree, n):
                index = len(order)
            else:
                index = order.index(script_tree.getBootstrap(tree, n))
            index_parent = order.index(script_tree.getBootstrap(tree, script_tree.getParent(tree, n)))
            script_tree.setLength(tree, n, index - index_parent)

    return script_tree.writeTree(tree, root, False)
Esempio n. 2
0
File: MaxTiC.py Progetto: ssolo/ALE
def tree_from_order(order):
  nodes = script_tree.getNodes(tree)
  for n in nodes:
    if not script_tree.isRoot(tree,n):
      if script_tree.isLeaf(tree,n):
	index = len(order)
      else:
	index = order.index(script_tree.getBootstrap(tree,n))
      index_parent = order.index(script_tree.getBootstrap(tree,script_tree.getParent(tree,n)))
      script_tree.setLength(tree,n,index-index_parent)

  return script_tree.writeTree(tree,root,False)
Esempio n. 3
0

#order.reverse()
#print order
print "after local search",value(order),"("+str(int(value(order)*100/total_transfers))+"%)"
'''
'''
sortie = open("list_of_constraints_conflicting_with_best_order","w")
index = {}
for i in range(len(order)):
  index[order[i]] = i
for e in edge_keys:
  sommets = e.split(",")
  if index.has_key(sommets[0]) and index.has_key(sommets[1]) and index[sommets[0]] > index[sommets[1]]:
      sortie.write(e+" "+str(edge[e])+"\n")
''' 

nodes = script_tree.getNodes(tree)
for n in nodes:
  if not script_tree.isRoot(tree,n):
    if script_tree.isLeaf(tree,n):
      index = len(order)
    else:
      index = order.index(script_tree.getBootstrap(tree,n))
    index_parent = order.index(script_tree.getBootstrap(tree,script_tree.getParent(tree,n)))
    script_tree.setLength(tree,n,index-index_parent)

print script_tree.writeTree(tree,root,False)