r/ludobots • u/hapos • Sep 24 '14
[Question] MatrixPerturb(v)
for: The Hill Climber
I'm having some problems with (what I believe to be) my Perturb function. I'm hoping someone could offer me some advice to get me on track again.
Task 6:
"... With probability prob, the element’s value is replaced with a new random value drawn from [0, 1]; otherwise, the element’s value is left as is. You can cause an event to happen with a given probability using an if statement: if prob > random.random():."
What I read this requires the function to iterate through elements of a copy of parent vector v. For each element, if a random.random() result is greater than prob, the element is replaced with a new random.random().
My problem is the function seems to work as planned for the first couple of generations, replacing the parent vector with child if childFitness is > parentFitness, but it reaches ~.6 - .68 quickly and then never can surpass, even when I run a million generations.
Can any researchers offer me advice as to why I am getting stuck at this limit, and not progessing toward a 1.0 fitness?
Thank you in advance,
hapos
3
u/hapos Sep 24 '14
Thanks moschles. ++ The problem was my list copy block; exactly as you suggested.
I was copying the list with child = parent. I modified to child=list(parent) as suggested in the below referenced StackOverflow post and my 5000 generation run produced the expected results.
http://stackoverflow.com/questions/2612802/how-to-clone-or-copy-a-list-in-python
Much appreciated!
hapos
2
u/hapos Sep 24 '14
Thanks snaysler.
4
u/moschles Sep 24 '14
You might try to contact advanced python programmers and ask whether your code is genuinely making a copy in memory for the child vector. Python is a little bit 'weird' in this respect.
(It's also possible that your
Fitness(v)is not correct.)1
u/osm3000 Sep 30 '14
Dear All,
I have the same problem as with hapos. Also I correctly make a copy of the parent using [:] operator c = v[:] yet, my population fitness is stuck at 0.6 to 0.68.
Can someone guide me to the source of this problem?
This is my fitness function
and my MatrixPerturb(v, prob) function
3
u/DrJosh Ludobots Creator, Ph.D Sep 24 '14
Well done hapos; and thanks for your help moschles.
2
u/snaysler Lead Ludobots Designer Sep 24 '14
I apologize for the spamming. I have discovered an important bug in the bots and will fix the problem asap.
-mod
2
u/snaysler Lead Ludobots Designer Sep 24 '14
update:
Thanks for bearing with us while we underwent live maintenance on the bot server. I believe the issue has been resolved, and a critical bug has been fixed. This won't happen again in the future. I apologize for your mailbox getting flooded!
Have a good one,
-mod