Re: Bug in the Genome class? (right example now)

idevx <[email protected]> Wed, 15 Jun 2005 22:48:34 -0300 (ART)
Newsgroups gmane.comp.breve
Message-ID <[email protected]>
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:
---
@include "Control.tz"

@use Genome.

Controller myController.

Control : myController {
    + variables:
        thing1 (object).
        thing2 (object).
        thing3 (object).
               =20
    + to init:
        i (int).
        thing1 =3D new CrossoverTestThing.
        thing2 =3D new CrossoverTestThing.
        thing3 =3D 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.
       =20
        for i=3D0, i < 5, i++:
        {
	        thing3 crossover from-parent-1 thing1
from-parent-2 thing2.
	        print
"After_________________________________".
	        thing1 print-self.
	        thing2 print-self.
	        thing3 print-self.
        }
       =20
        self end-simulation.
}
       =20
Genome : CrossoverTestThing
{
    + variables:
        value (3 floats).
       =20
    + to set-values one newOne (float) two newTwo
(float) three newThree (float):
        value[0] =3D newOne.
        value[1] =3D newTwo.
        value[2] =3D newThree.
       =20
    + 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


	=09
___________________________________=20
A tu celular =BFno le falta algo?=20
Us=E1 Yahoo! Messenger y Correo Yahoo! en tu tel=E9fono celular.=20
M=E1s informaci=F3n en http://movil.yahoo.com.ar
_______________________________________________
breve mailing list
[email protected]
http://lists.spiderland.org/mailman/listinfo/breve