本文整理汇总了Python中node.Node.update方法的典型用法代码示例。如果您正苦于以下问题:Python Node.update方法的具体用法?Python Node.update怎么用?Python Node.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类node.Node
的用法示例。
在下文中一共展示了Node.update方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update
# 需要导入模块: from node import Node [as 别名]
# 或者: from node.Node import update [as 别名]
def update(self):
Node.update(self)
if self.initiation:
if self.aware:
self.system_awaken()
else:
self.init()
if not self.initiate:
return
integrity = self.system_integrity()
if not integrity:
self.system_failure()
示例2: test_tree_policy
# 需要导入模块: from node import Node [as 别名]
# 或者: from node.Node import update [as 别名]
def test_tree_policy(self):
data = [(31.16,105),(52.89,153),(113.05,285),
(6.87,44),(100.89,259),(16.5,70),(22.05,84)]
v0 = Node(7)
v0.update= 1000
for i in range(7):
child = Node(7)
child.val, child.update = data[i]
child.parent = v0
v0.children[i] = child
v0.unvisited = 0
v_l = self.M.tree_policy(v0, self.G)
eq_(v0.children[1], v_l.parent) # best child is children[1]
示例3: test_calc_node_score
# 需要导入模块: from node import Node [as 别名]
# 或者: from node.Node import update [as 别名]
def test_calc_node_score(self):
data = [(31.16,105),(52.89,153),(113.05,285),
(6.87,44),(100.89,259),(16.5,70),(22.05,84)]
v0 = Node(7)
v0.update= 1000
ans = [0.55325390369,0.558168573334,0.552351405228\
,0.552361600287,0.552848864639,0.549851545954,0.549266772644]
for i in range(7):
child = Node(7)
child.val, child.update = data[i]
child.parent = v0
v0.children[i] = child
ok_(abs(ans[i] - self.M.calc_node_score(child, 1.0/math.sqrt(2))) < 0.000001)
示例4: test_calc_node_score
# 需要导入模块: from node import Node [as 别名]
# 或者: from node.Node import update [as 别名]
def test_calc_node_score(self):
root = Node(7)
root.val = 50
root.update = 1350
v0 = Node(7)
v0.val = 80+90+100/3
v0.update = 1380
v0.parent = root
# child num < 2 case
child = Node(7)
child.val, child.update = 50,100
v0.children[0] = child
# mean operator case
eq_(1.0*v0.val/v0.update, self.M.calc_node_score(v0,0))
data =[ (80,450), (90,400), (100, 500)]
for i in range(3):
child = Node(7)
child.val, child.update = data[i]
child.parent = v0
v0.children[i] = child
# max operator case
eq_(100/500.0, self.M.calc_node_score(v0,0))
data =[ (80,450), (90,400), (100, 400)]
for i in range(3):
child = Node(7)
child.val, child.update = data[i]
child.parent = v0
v0.children[i] = child
# mean operator case
eq_(1.0*v0.val/v0.update, self.M.calc_node_score(v0,0))
示例5: test_best_child
# 需要导入模块: from node import Node [as 别名]
# 或者: from node.Node import update [as 别名]
def test_best_child(self):
data = [(31.16,105),(52.89,153),(113.05,285),
(6.87,44),(100.89,259),(16.5,70),(22.05,84)]
v0 = Node(7)
v0.update= 1000
for i in range(7):
child = Node(7)
child.val, child.update = data[i]
child.parent = v0
v0.children[i] = child
eq_(2,self.M.best_child(v0, 0))
eq_(1,self.M.best_child(v0, 1.0/math.sqrt(2)))
data = [(20.57,83),(33.24,113),(112.03,285),
(1025.74,2029),(139.79,343),(22.06,86),(11.96,61)]
v0 = Node(7)
v0.update= 3000
for i in range(7):
child = Node(7)
child.val, child.update = data[i]
child.parent = v0
v0.children[i] = child
eq_(3,self.M.best_child(v0, 0))
eq_(3,self.M.best_child(v0, 1.0/math.sqrt(2)))