A Very Simple Genetic Algorithm Written in Swift 3
gist.github.com
A Very Simple Genetic Algorithm Written in Swift 3
1–10 of 42 posts
Re: A Very Simple Genetic Algorithm Written in Swift 3
#2Surprising. Swift, a compiled, static language, is slower than python in this use case?
Re: A Very Simple Genetic Algorithm Written in Swift 3
#3> Note -- this is much slower than the python version Surprising. Swift, a compiled, static language, is slower than python in this use case?
var n = Double(arc4random_uniform(UInt32(weightTotal * 1000000.0))) / 1000000.0
Re: A Very Simple Genetic Algorithm Written in Swift 3
#4> Note -- this is much slower than the python version Surprising. Swift, a compiled, static language, is slower than python in this use case?
Certainly I have found my own Swift scripts seem to be a lot slower than compiled programs.
EDIT: from my own test with 1000 iterations, script version 17s, compiled version (release build) 5.4s
Re: A Very Simple Genetic Algorithm Written in Swift 3
#5> Note -- this is much slower than the python version Surprising. Swift, a compiled, static language, is slower than python in this use case?
stuff like this can't help var n = Double(arc4random_uniform(UInt32(weightTotal * 1000000.0))) / 1000000.0
Re: A Very Simple Genetic Algorithm Written in Swift 3
#6> Note -- this is much slower than the python version Surprising. Swift, a compiled, static language, is slower than python in this use case?
This is just speculation, but slowness might be because this is being run as a script via /usr/bin/swift, rather than being precompiled into a binary. Certainly I have found my own Swift scripts seem to be a lot slower than compiled programs. EDIT: from my own test with 1000 iterations, script version 17s, compiled version (release build) 5.4s
Re: A Very Simple Genetic Algorithm Written in Swift 3
#7> Note -- this is much slower than the python version Surprising. Swift, a compiled, static language, is slower than python in this use case?
This is just speculation, but slowness might be because this is being run as a script via /usr/bin/swift, rather than being precompiled into a binary. Certainly I have found my own Swift scripts seem to be a lot slower than compiled programs. EDIT: from my own test with 1000 iterations, script version 17s, compiled version (release build) 5.4s
Re: A Very Simple Genetic Algorithm Written in Swift 3
#8c'mon everyone knows genetic population is 30
(I kid I kid but that number has an interesting story https://statswithcats.wordpress.com/2010/07/11/30-samples-st... )
Re: A Very Simple Genetic Algorithm Written in Swift 3
#9Earlier quoted context omitted.
This is just speculation, but slowness might be because this is being run as a script via /usr/bin/swift, rather than being precompiled into a binary. Certainly I have found my own Swift scripts seem to be a lot slower than compiled programs. EDIT: from my own test with 1000 iterations, script version 17s, compiled version (release build) 5.4s
good stuff. tbh though, only ~3x slowdown in scripting imo is pretty damn good 8)