backup_hot.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:machine-learning 作者: zzw0929 项目源码 文件源码
def  hill_climbing_first_choice_simulated_annealing(status):
    '''??????????????????????????????????????

    ??????????
    '''
    global chess_status_count, temperature

    pos = [(x, y) for x in range(8) for y in range(8)]
    random.shuffle(pos)
    for col, row in pos:
        if status[col] == row:
            continue
        chess_status_count += 1
        status_copy = list(status)
        status_copy[col] = row
        delta = get_num_of_conglict(status) - get_num_of_conglict(status_copy)
        # ??
        if temperature > 0:
            temperature -= 0.0001
        if delta > 0:
            status[col] = row
            return status
        elif delta < 0 and temperature != 0:
            probability = math.exp(delta / temperature)
            random_num = random.random()
            if random_num < probability:
                status[col] = row
                return status
    return status
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号