Search This Blog

11 August 2005

ai thoughts

ok, realistically, I don't expect anyone to be seeing this anyways, so instead of putting these thoughts in notepad where I will obviously loose them, just going to blog them so I can find them later...

1. if no one succeeds, then one with most correct wins
2. if equal number correct, then one that is shorter wins

so... longer-no-match < shorter-no-match < longer-match < shorter-match < longer-correct < shorter-correct

3. if two are identical, mutate
4. chance of going to next round based on overall fitness
5. if equal fitness, one with ancestors of highest fitness win (ie: noble blood; ie: adaptive bloodline)

how best to do this? pass some "ancestoral fitness" value to children...?
if you really suck, but all your parents won greatly, chances are your bloodline might get better with mutation
so we want to keep you around... but not at the expense of an algorithm that did better..
especially not if it did better than your ancestors...

if each child knows what the fitness value of both parents were (duplicate if cloned)... then we have a 3-way to determine
child's fitness... a triangle if you will...can we just average the 3?
let's think about that:

parent A1: 0.5
parent B1: 0.0
child C1: 0.2 --> average: 0.233

parent A2: 0.75
parent B2: 0.25
child C2: 0.67 --> average: 0.556

child C1: 0.233
child C2: 0.556
grandchild D: 0.4 --> 0.396

so, what do we have? original parents were:
0.5
0.0
0.75
0.25
and grandchild is:
0.396

if parent A2 and parent A1 were cloned into second round, however:
parent A1: 0.5
parent A2: 0.75
child C3: 0.80 --> 0.683
and if child C2 mated with C3:
child c2: 0.556
child c3: 0.683
grandchild D2: 0.75 --> 0.663
which is much better than grandchild D at .396

what if the averaging function counted the child itself twice? so...
parent A1: 0.5
parent B2: 0.0
parent A2: 0.75
parent B2: 0.25
child C1: 0.2 --> .225
child C2: 0.67 --> .585
child C3: 0.80 --> .713
grandchild D: 0.4 --> .403
grandchild D2: 0.75 --> .7

yeah, I think that more accurately represents it...

then, even if children do semi-poorly, their heritage might help them stand out (as in the case of grandchild D going up slightly)
why, you ask, did grandchild D2 loose a little? because they weren't quite as good as their parent child C3.


so, if we take a real-world example, say... solving some truth tables....
let's say we define a truth table:
0 0 0
0 1 0
1 0 0
1 1 1
(ie: and)
and let's say our children do this:
child 1: no outputs correct, 5 components
child 2: 1 output correct, 20 components
child 3: 1 output correct, 5 components
child 4: all outputs correct, 100 components
child 5: all outputs correct, 3 components
child 6: no outputs correct, 100 components
then our ranking would be:
(high) 5,4,3,2,1,6 (low)
our new population might be:
5 cloned
4 cloned
5+4 breed
4+3 breed
3+2 breed
2+5 breed

something like that? or maybe we have custom reproduction routine:
1) clone all 'all outputs correct'
2) breed -- parental preferences:
a. all outputs correct
b. some outputs correct
c. least # components
so, let's say we give them a breeding fitness too?
((NumberOutputsCorrect+1) * (2*MAX_COMPONENTS)) - NUM_COMPONENTS
then, breeding fitness' are:
child 1: (1*200)-5: 195
child 2: (2*200)-20: 380
child 3: (2*200)-5: 395
child 4: (5*200)-100: 900
child 5: (5*200)-3: 997
child 6: (1*200)-100: 100
now, in order:
child 5: 997
child 4: 900
child 3: 395
child 2: 380
child 1: 195
child 6: 100
now, let's say we clone top 2
grandchild 1: clone of 5
grandchild 2: clone of 4
and let's say we give % chance of reproduction based on the breeding score... so...
we could do roulette... where child 6 gets the first 100 slots, child 1 gets next 195, etc... well, we could randomize slots too
but anyways, total # slots would be: 2967.. then each parent would be chosen based on a random turn of the slot? this would
give the better a higher chance...

of course, that could lead to local optimum... could instead give slots = rank:
child 5: 6 slots
child 4: 5 slots
child 3: 4 slots
child 2: 3 slots
child 1: 2 slots
child 6: 1 slot

No comments:

Post a Comment