guofei9987 / guofei9987/scikit-opt

ACA算法发生除0问题

Open
#209 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
6.7k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

当prob中的元素极限小时,prob.sum()会得到0值,发生除0,请考虑
1. 将
next_point = np.random.choice(allow_list, size=1, p=prob)[0]
代码改为
if prob.sum() != 0:
prob = prob / prob.sum() # 概率归一化
next_point = np.random.choice(allow_list, size=1, p=prob)[0]
else:
next_point = np.random.choice(allow_list, size=1)[0]
或者
2.将
prob = prob / prob.sum()
代码改为
prob = prob / prob.sum() + 1e-10

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.