TLmaK0 / rustneat

Rust Neat - NeuroEvolution of Augmenting Topologies
MIT License
68 stars 16 forks source link

panic in Specie::generate_offspring() #19

Open Boscop opened 6 years ago

Boscop commented 6 years ago

After running it on my problem for like an hour (with no improvement), I got this panic:

thread 'main' panicked at 'Range::new called with `low >= high`', C:\Users\me\.c
argo\registry\src\github.com-1ecc6299db9ec823\rand-0.3.18\src\distributions\rang
e.rs:60:8
stack backtrace:
   0: std::sys_common::backtrace::_print
             at C:\projects\rust\src\libstd\sys_common\backtrace.rs:92
   1: std::panicking::default_hook::{{closure}}
             at C:\projects\rust\src\libstd\panicking.rs:380
   2: std::panicking::default_hook
             at C:\projects\rust\src\libstd\panicking.rs:397
   3: std::panicking::rust_panic_with_hook
             at C:\projects\rust\src\libstd\panicking.rs:577
   4: <rand::ThreadRng as rand::Rng>::next_u64
   5: rustneat::specie::Specie::generate_offspring
   6: rustneat::population::Population::evolve
   7: ZIG_NORM_X
   8: ZIG_NORM_X
   9: panic_unwind::__rust_maybe_catch_panic
             at C:\projects\rust\src\libpanic_unwind\lib.rs:99
  10: std::rt::lang_start
             at C:\projects\rust\src\libstd\rt.rs:52
  11: __scrt_common_main_seh
             at f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:253
  12: BaseThreadInitThunk
TLmaK0 commented 6 years ago

Thanks, @boscop, I will check this.

shingtaklam1324 commented 6 years ago

@TLmaK0 I think I figured out the reason for the crash

https://github.com/TLmaK0/rustneat/blob/18b4fbfba6c2132f305e784ad7f4af4076c23f19/src/specie.rs#L84

This calls

https://github.com/rust-lang-nursery/rand/blob/8ce74354f5fc771ac177b4a052f0b74660281cbf/src/distributions/range.rs#L59-L62

It requires that the lower bound to be less than (and not equal to) the upper bound. This means that if self.organisms.len() is 0, then the function will panic.

TLmaK0 commented 6 years ago

thanks @shingtaklam1324, could you investigate when the organisms is 0 in species? Test go through here without errors (normally).

UrmelAusDemEis commented 5 years ago

Hey Everyone, I can confirm that this problem still exists. Have you guys made any process regarding this?

TLmaK0 commented 5 years ago

Hi @UrmelAusDemEis, I think it's fixed in feature/function_aproximation, but I have done a lot of changes there and I'm not sure that all is working right now

UrmelAusDemEis commented 5 years ago

Hi @TLmaK0, I just tried the other branch and the bug seems to be still in there

TLmaK0 commented 5 years ago

Thanks @UrmelAusDemEis, I will take a look!