Advertisemen
Regarding my earlier moan about making my FYP concurrent, I thought I had solved the error but I hadn't. After hours of debugging again, I *THINK* I've fixed it. Obviously, it's very hard to be sure when it's a seemingly random occurance. Solutions I've tried:
- Creating a custom clone method for the world (in additional - custom clone methods for all of its fields which got a bit messy with superclasses and subclasses (the Item hierarchy))
- Not resetting the chromosomes fitness each generation - this would work IF the map didn't change each generation and its not really fixing the problem, it's just a quick hack involving hiding the problem in a dark corner
- There are probably other solutions which I can't remember off the top of my head as it has been quite a few hours
evolverThread = new Thread(evolver);
evolverThread.start();
d out that the Evolver was being multiple times and this was causing a really weird error. Weird in that I assumed only one Evolver was running at the same time, and the error was a Concurrent Modification Exception. In my head I was like WTF as this is a procedural section of code. It was spouting the error when trying to add data into the graph's dataset, as a life form was being simulated at the same time. A previous fix was to stick the addition to the dataset in a synchronized block and ignore it (a major hack I know, but I was desperate at that point, it's a shame it came back to bite me in the ass.) Anyway, the GUI creation method was being called twice, causing two threads to run the same Evolver, thus where my Concurrent Modification Exception was occurring. The thread starting method required a quick fix:
The downside is that my simulation is no longer running at lightning speed - something did seem fishy about it. Anyway I've simulated up to Generation 63 and there have been no errors, I think I will restart a simulation, get a glass of water, watch some TV. Check back on the simulation after, if no drop in maximum fitness I shall commit, push and go to bed trying not to get my hopes up. If a drop, then commit and push and go to bed angrily. At least my cat is on my lap right now - looks like I won't be getting a drink though :(
if (evolverThread != null)
return;
evolverThread = new Thread(evolver);
evolverThread.start();
Advertisemen
Tidak ada komentar:
Posting Komentar