本文整理汇总了Python中state.State.get_cpy方法的典型用法代码示例。如果您正苦于以下问题:Python State.get_cpy方法的具体用法?Python State.get_cpy怎么用?Python State.get_cpy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类state.State
的用法示例。
在下文中一共展示了State.get_cpy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: sa_search
# 需要导入模块: from state import State [as 别名]
# 或者: from state.State import get_cpy [as 别名]
def sa_search(graph, budget, timer):
# Might be able to simplify this.
cycle = list(range(0, len(graph.nodelist)))
#random.shuffle(cycle)
state = State(graph, cycle, [])
best = state.get_cpy()
while timer.get_secs() < budget:
temp = Search.schedule(timer.get_secs(), budget)
if temp <= 0:
break
#nextop = random.choice(oplist)
nextstate = state.get_cpy()
nextstate.swap_nodes()
deltae = state.cost - nextstate.cost
if deltae > 0:
state = nextstate
else:
if math.exp(float(deltae)/float(temp)) > random.uniform(0,1):
state = nextstate
if state.cost < best.cost:
best = state.get_cpy()
return best
示例2: fc_search
# 需要导入模块: from state import State [as 别名]
# 或者: from state.State import get_cpy [as 别名]
def fc_search(graph, budget, timer):
# Might be able to simplify this.
cycle = list(range(0, len(graph.nodelist)))
#random.shuffle(cycle)
state = State(graph, cycle, [])
while timer.get_secs() < budget:
# Apply operation.
nextstate = state.get_cpy()
nextstate.swap_nodes()
deltae = state.cost - nextstate.cost
if deltae > 0:
state = nextstate
return state