AtomicFrontierCode / keyboards

Simulated annealing code for video
MIT License
274 stars 32 forks source link

Code crashes after running for 32 hours #10

Closed Matseslats closed 7 months ago

Matseslats commented 7 months ago

After around 930 lines of the terminal displaying temperature 0.0, the program crashes with the error:

ERROR: LoadError: MethodError: no method matching Int64(::String)

Closest candidates are:
  (::Type{T})(::AbstractChar) where T<:Union{Int32, Int64}
   @ Base char.jl:51
  (::Type{T})(::AbstractChar) where T<:Union{AbstractChar, Number}
   @ Base char.jl:50
  (::Type{T})(::BigInt) where T<:Union{Int128, Int16, Int32, Int64, Int8}
   @ Base gmp.jl:367
  ...

Stacktrace:
 [1] drawKeyboard(myGenome::Vector{String}, id::String)
   @ Main C:\<DIR>\keyboards\keyboardSA.jl:488
 [2] runSA()
   @ Main C:\<DIR>\keyboards\keyboardSA.jl:789
 [3] top-level scope
   @ C:\<DIR>\keyboards\keyboardSA.jl:798
in expression starting at C:\<DIR>\keyboards\keyboardSA.jl:798

The last png saved was 23836.png (Possible Int16 overflow after that?), and my last iteration score was 0.01, 23836, -37.87043, -37.88911

AtomicFrontierCode commented 7 months ago

Interesting! I never got to temperatures below 1 degree (running with a full book or set of wikipedia articles takes way longer to run than the example) so my initial guess is that it might have something to do with hitting zero. I'll take a look, but for the meanwhile your final keyboard should be pretty good!

Matseslats commented 7 months ago

My first guess was that as well! But it seems to crash on the line where it saves the picture, line 488: savefig("$(Int(id)).png"). The issue is that you convert the id to an int, but if you finish the for loop for iteration in 1:num_iterations, you then try to save the best keyboard with the name "final". But the word "final" cannot be converted into an int in savefig("$(Int(id)).png") so it crashes :)

Matseslats commented 7 months ago

Looking at the commits, it seems like you found the problem as well 👍