本文整理汇总了Python中Node.Node.getValue方法的典型用法代码示例。如果您正苦于以下问题:Python Node.getValue方法的具体用法?Python Node.getValue怎么用?Python Node.getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Node.Node
的用法示例。
在下文中一共展示了Node.getValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: simulate
# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import getValue [as 别名]
def simulate(self):
currentNode = Node(Sudoku(self.m_sudokuProblem, self.m_fixedNodes))
currentNode.m_sudoku.populate()
found = False
while not found:
self.m_temperature = self.scheduleTemp()
if currentNode.getValue() <= 0 and currentNode.m_sudoku.validateSudoku():
found = True
return currentNode
if self.m_temperature < 0.00027:
currentNode = self.reheat()
print "REHEAT"
nextNode = currentNode.getRandomSucessor()
deltaE = currentNode.getValue() - nextNode.getValue()
print nextNode.getValue()
probability = self.getProbability(deltaE)
if random.random() < probability:
currentNode = nextNode
示例2: __insert
# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import getValue [as 别名]
def __insert(self, root, value):
if root == None:
root = Node(value)
print(root.getValue())
return
# Go to the right if value >= value of the root
if value >= root.getValue():
if root.getRight():
self.__insert(root.getRight(), value)
else:
root.setRight(Node(value))
else:
if root.getLeft():
self.__insert(root.getLeft(), value)
else:
root.setLeft(Node(value))
示例3: build_path
# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import getValue [as 别名]
#.........这里部分代码省略.........
firstNode = nodes[0]
n = Node()
'''force first node of each path to absolute command'''
if pathIndex > 0 and firstNode.command.islower():
firstNode.command = firstNode.command.upper()
lastCoordinate = pathLastNode.getTarget()
firstNode.attrib = [ str(float(lastCoordinate[0]) + float(firstNode.attrib[0])), str(float(lastCoordinate[1]) + float(firstNode.attrib[1])) ]
n.attrib = firstNode.getTarget()
n.showCommand = True
n.command = "L"
nodes.insert(-1, n)
pathLastNode = n
lastNode = nodes.pop()
if self.options['circlepath']:
tempBuilt = built[:]
index = 0
while nodes:
if not self.isRunning: return
if not self.options['fullpath']:
# node = nodes.pop(0)
# built.append(node.getValue())
# built.append( points.pop(0) )
# while nodes and not re.match(r'^[a-zA-Z]$', nodes[0].showCommand):
command = nodes[0].command
while nodes:
node = nodes.pop(0)
# print node.getValue()
built.append(node.getValue())
if node.command.lower() != command.lower():
break
else:
if self.options['circlepath'] and closedPath:
if len(nodes) > 0:
node = nodes.pop(0)
leftPath.append(node)
if len(nodes) > 0:
node = nodes.pop()
rightPath.insert(0, node)
cleanPath = []
for node in nodes:
n = Node()
if node.command.islower():
n.command = "m"
else:
n.command = "M"
n.showCommand = True
n.attrib = node.attrib[-2:]
cleanPath.append(n)
if self.options['closepath']:
currentPoint = ["0", "0"]
absolutePath = False
for node in cleanPath:
if node.command.islower():
currentPoint[0] = str(float(currentPoint[0]) + float(node.attrib[0]))
currentPoint[1] = str(float(currentPoint[1]) + float(node.attrib[1]))