sharpneat icon indicating copy to clipboard operation
sharpneat copied to clipboard

AddNodeStrategy.CreateChildGenome() has an unhandled case that results in an IndexOutOfRangeException

Open joelmeaders opened this issue 5 months ago • 3 comments

I'm running into a case where insertIdx1 is resolved to -1, which leads to stopIdx, copyLen and parentIdx being -1. IndexOutOfRangeException is thrown at connArr[childIdx] = newConnArr[newConIdx];

newConnArr: 0,14 8,0

newWeightArr: -0.4854858 1

parentConnArr: 0,14 4,14 8,14 13,14

parentWeightArr: -4.0975833 -3.7439632 -0.4854858 0.24271071

joelmeaders avatar Jul 28 '25 15:07 joelmeaders

Hi. Was this on main branch? And have you seen this more than once?

colgreen avatar Jul 28 '25 22:07 colgreen

This was on the main branch.

I may have tracked down the cause. I was reusing AddNodeStrategy rather than creating a new one for subsequent generations so the original sequence IDs were being reused.

joelmeaders avatar Jul 28 '25 22:07 joelmeaders

At first glance it does seem that method doesn't handle when insertIdx1 is -1, so it's a bit odd that I've never seen this issue. It's quite a complex method and it's late here, so I'll need to take a fresh look at it another time. I feel like this method should be simplified and that I over optimised it perhaps.

colgreen avatar Jul 28 '25 23:07 colgreen