guofei9987 / guofei9987/scikit-opt
ACA算法发生除0问题
Open
- 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
Assessment
This issue has not been assessed yet.