Skip to content

Commit 4f3719d

Browse files
committed
Remove Ref workaround for rng broadcasting
1 parent c86d383 commit 4f3719d

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/update.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
function move!(state::ParticleSwarmState{T}, tuning::AbstractParticleSwarm) where {T}
44
rng, X, V = tuning.rng, state.X, state.V
55
w, c1, c2 = T(tuning.w), T(tuning.c1), T(tuning.c2)
6-
# Wrap rng in Ref for compatibility with Julia <= 1.3
7-
V .= w.*V .+ c1.*rand.(Ref(rng), T).*(state.pbest_X .- X) .+
8-
c2.*rand.(Ref(rng), T).*(state.gbest_X .- X)
6+
@. V = w*V + c1*rand(rng, T)*(state.pbest_X - X) + c2*rand(rng, T)*(state.gbest_X - X)
97
X .+= V
108
for (r, idx) in zip(state.ranges, state.indices)
119
constrain!(r, view(X, :, idx))

0 commit comments

Comments
 (0)