随机选择一个整数 Args: i 第一个alpha的下标 m 所有alpha的数目 Returns: j 返回一个不为i的随机数,在0~m之间的整数值
(i, m)
| 110 | |
| 111 | |
| 112 | def selectJrand(i, m): |
| 113 | """ |
| 114 | 随机选择一个整数 |
| 115 | Args: |
| 116 | i 第一个alpha的下标 |
| 117 | m 所有alpha的数目 |
| 118 | Returns: |
| 119 | j 返回一个不为i的随机数,在0~m之间的整数值 |
| 120 | """ |
| 121 | j = i |
| 122 | while j == i: |
| 123 | j = int(random.uniform(0, m)) |
| 124 | return j |
| 125 | |
| 126 | |
| 127 | def selectJ(i, oS, Ei): # this is the second choice -heurstic, and calcs Ej |