@@ -76,12 +76,12 @@ function Base.iterate(iter::LayoutIterator{<:SFDP{Dim,Ptype,T}}) where {Dim,Ptyp
7676 pin = [get (algo. pin, i, SVector {Dim,Bool} (false for _ in 1 : Dim)) for i in 1 : N]
7777
7878 # iteratorstate: (#iter, energy, step, progress, old pos, pin, stopflag)
79- return startpos, (1 , typemax (T), one (T), 0 , startpos, pin, false )
79+ return startpos, (1 , typemax (T), one (T), 0 , startpos, pin, rng, false )
8080end
8181
8282function Base. iterate (iter:: LayoutIterator{<:SFDP} , state)
8383 algo, adj_matrix = iter. algorithm, iter. adj_matrix
84- iter, energy0, step, progress, locs0, pin, stopflag = state
84+ iter, energy0, step, progress, locs0, pin, rng, stopflag = state
8585 K, C, tol = algo. K, algo. C, algo. tol
8686
8787 # stop if stopflag (tol reached) or nr of iterations reached
@@ -109,9 +109,7 @@ function Base.iterate(iter::LayoutIterator{<:SFDP}, state)
109109 end
110110 if any (isnan, force)
111111 # if two points are at the exact same location use random force in any direction
112- # copy rng from alg struct to not advance the "initial" rng state
113- # otherwise algo(g)==algo(g) might be broken
114- force += randn (copy (algo. rng), Ftype)
112+ force = randn (rng, Ftype)
115113 end
116114 mask = (! ). (pin[i]) # where pin=true mask will multiply with 0
117115 locs[i] = locs[i] .+ (step .* (force ./ norm (force))) .* mask
@@ -124,7 +122,7 @@ function Base.iterate(iter::LayoutIterator{<:SFDP}, state)
124122 stopflag = true
125123 end
126124
127- return locs, (iter + 1 , energy, step, progress, locs, pin, stopflag)
125+ return locs, (iter + 1 , energy, step, progress, locs, pin, rng, stopflag)
128126end
129127
130128# Calculate Attractive force
0 commit comments