16 Jun 2005 03:48
Re: Bug in the Genome class? (right example now)
idevx <idevx <at> yahoo.com.ar>
2005-06-16 01:48:34 GMT
2005-06-16 01:48:34 GMT
OK, here is the right code that shows the problem
(below). Basically, the array is considered as just
one variable, so the object resulting from the
crossover is _always_ equal to one of its parents -
not the expected result (ie, the crossover should
"flatten" all the variables & arrays -lists too, if
possible- select a crossing point, exchange and join.
I'm assuming arrays and/or list of the exact same
size, of course)
TIA
Ignacio
Code:
---
<at> include "Control.tz"
<at> use Genome.
Controller myController.
Control : myController {
+ variables:
thing1 (object).
thing2 (object).
thing3 (object).
+ to init:
i (int).
thing1 = new CrossoverTestThing.
thing2 = new CrossoverTestThing.
thing3 = new CrossoverTestThing.
thing1 set-values one 1.0 two 2.0 three 3.0.
thing2 set-values one 10.0 two 20.0 three
30.0.
thing3 set-values one 100.0 two 200.0 three
300.0.
print
"Before________________________________".
thing1 print-self.
thing2 print-self.
thing3 print-self.
for i=0, i < 5, i++:
{
thing3 crossover from-parent-1 thing1
from-parent-2 thing2.
print
"After_________________________________".
thing1 print-self.
thing2 print-self.
thing3 print-self.
}
self end-simulation.
}
Genome : CrossoverTestThing
{
+ variables:
value (3 floats).
+ to set-values one newOne (float) two newTwo
(float) three newThree (float):
value[0] = newOne.
value[1] = newTwo.
value[2] = newThree.
+ to print-self:
print "",self,":",value[0],value[1],value[2].
}
------------------
Output:
----
Before________________________________
CrossoverTestThing (0x48f6a30) : 1.000000 2.000000
3.000000
CrossoverTestThing (0x4d22dd0) : 10.000000 20.000000
30.000000
CrossoverTestThing (0x4d60a90) : 100.000000
200.000000 300.000000
After_________________________________
CrossoverTestThing (0x48f6a30) : 1.000000 2.000000
3.000000
CrossoverTestThing (0x4d22dd0) : 10.000000 20.000000
30.000000
CrossoverTestThing (0x4d60a90) : 1.000000 2.000000
3.000000
After_________________________________
CrossoverTestThing (0x48f6a30) : 1.000000 2.000000
3.000000
CrossoverTestThing (0x4d22dd0) : 10.000000 20.000000
30.000000
CrossoverTestThing (0x4d60a90) : 1.000000 2.000000
3.000000
After_________________________________
CrossoverTestThing (0x48f6a30) : 1.000000 2.000000
3.000000
CrossoverTestThing (0x4d22dd0) : 10.000000 20.000000
30.000000
CrossoverTestThing (0x4d60a90) : 10.000000 20.000000
30.000000
After_________________________________
CrossoverTestThing (0x48f6a30) : 1.000000 2.000000
3.000000
CrossoverTestThing (0x4d22dd0) : 10.000000 20.000000
30.000000
CrossoverTestThing (0x4d60a90) : 10.000000 20.000000
30.000000
After_________________________________
CrossoverTestThing (0x48f6a30) : 1.000000 2.000000
3.000000
CrossoverTestThing (0x4d22dd0) : 10.000000 20.000000
30.000000
CrossoverTestThing (0x4d60a90) : 1.000000 2.000000
3.000000
------------
http://www.wirelesshamster.com
___________________________________
A tu celular ¿no le falta algo?
Usá Yahoo! Messenger y Correo Yahoo! en tu teléfono celular.
Más información en http://movil.yahoo.com.ar
_______________________________________________
breve mailing list
breve <at> spiderland.org
http://lists.spiderland.org/mailman/listinfo/breve
RSS Feed