SAR*_*ose 2 python algorithm math
我有一个模拟退火算法,我有一个像
result = w1*x1 + w2*x2 + ... + wn*xn
当w选择新值时,模拟退火的每个循环如何确保总和w等于1并且没有单个w值小于0?
非常感谢大家!
result = w1*x1 + w2*x2 + ... + wn*xn你能做到的result = np.dot(w, x).你想要的条件w似乎可能来自:
non_negative_w = np.abs(w)
sum_w = np.sum(non_negative_w)
normalized_non_negative_w = non_negative_w / sum_w
Run Code Online (Sandbox Code Playgroud)| 归档时间: |
|
| 查看次数: |
526 次 |
| 最近记录: |