Difference between revisions of "User talk:Bigfatcat"
Skilgannon (talk | contribs) (another compiler speedup idea) |
|||
(4 intermediate revisions by 3 users not shown) | |||
Line 14: | Line 14: | ||
Another thought I had for speeding up the compiling would be to compile all the files you need with one big call to javac instead of lots of little calls. Each time you call javac it needs to load rt.jar which is about 30MB. Jikes gets around this by being implemented in C, but the sun javac is actually written in Java (hence the long init times). --[[User:Skilgannon|Skilgannon]] 15:14, 26 April 2011 (UTC) | Another thought I had for speeding up the compiling would be to compile all the files you need with one big call to javac instead of lots of little calls. Each time you call javac it needs to load rt.jar which is about 30MB. Jikes gets around this by being implemented in C, but the sun javac is actually written in Java (hence the long init times). --[[User:Skilgannon|Skilgannon]] 15:14, 26 April 2011 (UTC) | ||
+ | |||
+ | Just throwing a random thought out here, has anyone tried to evolve a population using GP against a population that uses NEAT? I'm wondering what would happen here: a population using GP tests its fitness against NEAT while at the same time, a NEAT population evolves and tests its fitness against the GP population.--[[User:Khanguy|Khanguy]] 20:37, 26 April 2011 (UTC) | ||
+ | |||
+ | I have no idea what NEAT is but sounds like a neat idea *sniggers*. With that in mind, I don't want to get anyone excited about my GP; this is a mini GP that probably wont be very human-competitive. I just want to make a proof of concept and practice my GP skills in preparation of my dissertation. I've taken your advice Voidious and I'm now culling my population after every cycle; I feel slightly evil but it's for a good cause, honestly. A complete 40-generation cycle now takes less than 20 minutes and it's providing some slightly satisfying results. I've also modified my fitness equation to take into account the average score of the three opponents, it seems to be more accurate. --[[User:Bigfatcat|Bigfatcat]] 20:54, 26 April 2011 (UTC) | ||
+ | |||
+ | These guys used NEAT - [http://www.youtube.com/watch?v=Ru9W-9CxdQ8 video] / [http://www.jonnielsen.net/RoboReportOfficial.pdf paper]. Yeah I wouldn't feel too embarrassed if your GP bots don't compete with the top hand coded bots. =) Maybe check out the "GPBots" in the rumble for comparison? Anyway, late response, but my GA pseudocode is kinda like this: | ||
+ | <syntaxhighlight> | ||
+ | mutationRate = 0.005 | ||
+ | crossoverRate = 0.7 | ||
+ | population=50 | ||
+ | battles=100 | ||
+ | |||
+ | newGeneration { | ||
+ | newPopulation = new List | ||
+ | while newPopulation.size < population { | ||
+ | random1, random2 = random members of population, | ||
+ | chosen with roulette wheel selection | ||
+ | if (Math.random() < crossoverRate) { | ||
+ | newPopulation.add(crossover(random1, random2)) | ||
+ | newPopulation.add(crossover(random1, random2)) | ||
+ | } else { | ||
+ | newPopulation.add(random1) | ||
+ | newPopulation.add(random2) | ||
+ | } | ||
+ | } | ||
+ | |||
+ | for each bit in each member of newPopulation { | ||
+ | if (Math.random() < mutationRate) | ||
+ | bit.flip | ||
+ | } | ||
+ | } | ||
+ | </syntaxhighlight> | ||
+ | I also protect against ever adding duplicates and account for other edge cases. You're right, I accept that I might lose something valuable, but odds are very very good that most of the good traits will live on and still have some diversity. Also, I'm running "battles" just simulating targeting runs with [[User:Voidious/WaveSim|WaveSim]], which is not real battles and is maybe 20x faster than a real Robocode battle. | ||
+ | |||
+ | --[[User:Voidious|Voidious]] 01:21, 27 April 2011 (UTC) | ||
+ | |||
+ | Thanks Voidious, I feel a bit better now, the function of my GP is very similar to yours in terms of reproduction, crossover and mutation although my mutation rate is 3% instead of 0.05%. I may do a test run with a much lower mutation rate to see what comes up. I forgot that you mentioned WaveSim; I'd use it myself but the optimisation my GP attempts to carry out is much more generic; move amounts, whether to dodge when hit, fire power and cautionary constraints regarding firing etc... With my new fitness function my GP produced a Robot last night that beats my own 'role model' robot 4/5 times; I'm quite happy! One thing I have noticed is that the average fitness of each generation does not consistently increase; it seems to reach a peek at around generation 10. Nevertheless the best-robot-of-generation does seem to improve consistently as generations increase. Of 40 generations my best robot arrived at generation 35. I think this is due to my combined use of Roulette Wheel and Elitism. Although considering I'm now killing 4% of the weakest population every generation you'd expect average generational fitness to increase exponentially. Despite this, average fitness of the entire population does increase after every generation. This is bordering on Philosophy! Cheers again for the interest --[[User:Bigfatcat|Bigfatcat]] 15:25, 27 April 2011 (UTC) |
Latest revision as of 16:25, 27 April 2011
Feel free to discuss my Genetic Programming project!
If you need to speed up the compiling you may with to try using Jikes instead of javac. It compiles much faster, but unfortunately only works for Java 1.4 and earlier, so you need to point at an old robocode.jar for your compile classpath. For running, if you have multiple cores you can turn on the robocode option to enable running the robots in parallel. Otherwise you could use something like RoboResearch which can network battles across multiple machines and set up a whole lab to run your battles. Some food for thought =) --Skilgannon 18:30, 25 April 2011 (UTC)
Thanks Skilgannon, really appreciate the suggestions, definitely food for thought :) I'll look into the dual core option, if I have time RoboResearch sounds like a good idea too. For now I'll halve the reproduction rate just so I can run a complete cycle of 50 generations and while I'm waiting I'll look into your suggestions. Cheers! --Bigfatcat 18:40, 25 April 2011 (UTC)
I've been tinkering with genetic algorithms with Robocode - not "genetic programming", just tuning parameters of algorithms. Why increase the population size over time? I just cull to the same population size each generation. My populations tend to be more like 20-50. Currently I breed using "roulette selection", which I think is pretty common. Also, note that you need to run a lot if battles to accurately evaluate performance, especially as your fitness goes up. Something like 50-100 battles (35 rounds each) is what I use until fitness improvement starts really slowing down. In general, as my fitness improvement slows down, I lower mutation rate, increase crossover rate, and increase the battle count. Of course, all these settings vary by the problem you're working with.
As you've noticed, running actual battles is kinda slow, though that also depends on the complexity of the bots. I'm using WaveSim just to work on targeting algorithms. If you can find any way to evaluate fitness without running actual battles, that could help a lot. Good luck. =) --Voidious 23:09, 25 April 2011 (UTC)
I halved the reproduction rate but once it reached the 40th generation it was still taking too long to run. For this reason I'm going to reduce the number of generations to 40. So when you cull your population I assume you just kill the 50% of your population (the weakest)? Doing that though, how do you ensure you're not losing some valuable variety? One of those weakest individuals may have one value that is perfect. Also when you say you run 50-100 battles with 35 rounds each...you do that for each robot? Surely that takes a hell of a long time?
I'm using Elitism and Roulette Wheel by the way; half of the reproduction pool is selected via elitism and half is selected via Roulette Wheel.--Bigfatcat 13:13, 26 April 2011 (UTC)
Another thought I had for speeding up the compiling would be to compile all the files you need with one big call to javac instead of lots of little calls. Each time you call javac it needs to load rt.jar which is about 30MB. Jikes gets around this by being implemented in C, but the sun javac is actually written in Java (hence the long init times). --Skilgannon 15:14, 26 April 2011 (UTC)
Just throwing a random thought out here, has anyone tried to evolve a population using GP against a population that uses NEAT? I'm wondering what would happen here: a population using GP tests its fitness against NEAT while at the same time, a NEAT population evolves and tests its fitness against the GP population.--Khanguy 20:37, 26 April 2011 (UTC)
I have no idea what NEAT is but sounds like a neat idea *sniggers*. With that in mind, I don't want to get anyone excited about my GP; this is a mini GP that probably wont be very human-competitive. I just want to make a proof of concept and practice my GP skills in preparation of my dissertation. I've taken your advice Voidious and I'm now culling my population after every cycle; I feel slightly evil but it's for a good cause, honestly. A complete 40-generation cycle now takes less than 20 minutes and it's providing some slightly satisfying results. I've also modified my fitness equation to take into account the average score of the three opponents, it seems to be more accurate. --Bigfatcat 20:54, 26 April 2011 (UTC)
These guys used NEAT - video / paper. Yeah I wouldn't feel too embarrassed if your GP bots don't compete with the top hand coded bots. =) Maybe check out the "GPBots" in the rumble for comparison? Anyway, late response, but my GA pseudocode is kinda like this:
mutationRate = 0.005
crossoverRate = 0.7
population=50
battles=100
newGeneration {
newPopulation = new List
while newPopulation.size < population {
random1, random2 = random members of population,
chosen with roulette wheel selection
if (Math.random() < crossoverRate) {
newPopulation.add(crossover(random1, random2))
newPopulation.add(crossover(random1, random2))
} else {
newPopulation.add(random1)
newPopulation.add(random2)
}
}
for each bit in each member of newPopulation {
if (Math.random() < mutationRate)
bit.flip
}
}
I also protect against ever adding duplicates and account for other edge cases. You're right, I accept that I might lose something valuable, but odds are very very good that most of the good traits will live on and still have some diversity. Also, I'm running "battles" just simulating targeting runs with WaveSim, which is not real battles and is maybe 20x faster than a real Robocode battle.
--Voidious 01:21, 27 April 2011 (UTC)
Thanks Voidious, I feel a bit better now, the function of my GP is very similar to yours in terms of reproduction, crossover and mutation although my mutation rate is 3% instead of 0.05%. I may do a test run with a much lower mutation rate to see what comes up. I forgot that you mentioned WaveSim; I'd use it myself but the optimisation my GP attempts to carry out is much more generic; move amounts, whether to dodge when hit, fire power and cautionary constraints regarding firing etc... With my new fitness function my GP produced a Robot last night that beats my own 'role model' robot 4/5 times; I'm quite happy! One thing I have noticed is that the average fitness of each generation does not consistently increase; it seems to reach a peek at around generation 10. Nevertheless the best-robot-of-generation does seem to improve consistently as generations increase. Of 40 generations my best robot arrived at generation 35. I think this is due to my combined use of Roulette Wheel and Elitism. Although considering I'm now killing 4% of the weakest population every generation you'd expect average generational fitness to increase exponentially. Despite this, average fitness of the entire population does increase after every generation. This is bordering on Philosophy! Cheers again for the interest --Bigfatcat 15:25, 27 April 2011 (UTC)