Automatic programming, an example

Say, that we have the fol­low­ing ob­ser­va­tional data:

Planet Aphe­lion
000 km
000 km
Or­bit time
Mer­cury 69,816 46,001 88
Venus 108,942 107,476 225
Earth 152,098 147,098 365
Mars 249,209 206,669 687
Jupiter 816,520 740,573 4,332
Saturn 1,513,325 1,353,572 10,760
Uranus 3,004,419 2,748,938 30,799
Nep­tune 4,553,946 4,452,940 60,190
Pluto 7,311,000 4,437,000 90,613

The min­i­mal, the max­i­mal dis­tance be­tween a planet and the Sun (both in thou­sands of kilo­me­tres) and the num­ber of (Earth) days for one rev­olu­tion around the Sun. Above is only the em­piri­cal data and no bind­ing al­gorithm among the three quan­tities. The ce­les­tial me­chan­ics rules which go by the name of the Ke­pler’s laws. Can those rules be (re)in­vented by a com­puter pro­gram and how?

The fol­low­ing pro­gram code will be put into a simu­la­tor:

//​dec­la­ra­tions of the in­te­ger type vari­ables
$DECLAREINT bad per­ihe­lion aphe­lion or­bit guess dif temp zero temp1

//​table with the known data in a simu­la­tor friendly for­mat
$INVAR per­ihe­lion(46001) aphe­lion(69816) or­bit(88)
$INVAR per­ihe­lion(107476) aphe­lion(108942) or­bit(225)
$INVAR per­ihe­lion(147098) aphe­lion(152098) or­bit(365)
$INVAR per­ihe­lion(206669) aphe­lion(249209) or­bit(687)
$INVAR per­ihe­lion(740573) aphe­lion(816520) or­bit(4332)
$INVAR per­ihe­lion(1353572) aphe­lion(1513325) or­bit(10760)
$INVAR per­ihe­lion(2748938) aphe­lion(3004419) or­bit(30799)
$INVAR per­ihe­lion(4452940) aphe­lion(4553946) or­bit(60190)
$INVAR per­ihe­lion(4437000) aphe­lion(7311000) or­bit(90613)
//​ vari­ables or­bit and bad can’t be touched by the simu­la­tor
//​to avoid a de­gen­er­a­tion to a triv­ial­ity
$RESVAR or­bit bad
//​do NOT use if clause, while clause do not set di­rect num­bers …
$RESCOM if while val_op­er­a­tion inc_dec
//​bad is the vari­able, by which the whole pro­gram will be judged
//​a big value of bad is bad. By this crite­ria pro­grams will be wiped out
//​from their vir­tual ex­is­tence. A kind of anti-fit­ness
//​do show the fol­low­ing vari­ables when simu­lat­ing
$SHOWVAR bad,or­bit,guess,dif
//​pe­nal­ize any com­mand with 0 (noth­ing) and ev­ery line by 1 point
$WEIGHTS com­mands=0 lines=1
//​min­i­mize the whole pro­gram to 20 lines or less
$MINIMIZE lines 20
//​the arena, where al­gorithms will be
//​cre­ated and the fittest only will sur­vive
//​test­ing area where the simu­la­tor has no write ac­cess to
//​here the bad (the pe­nal­ized vari­able) is calcu­lated
//​big­ger the differ­ence be­tween the known or­bit and the vari­able guess
//​worse is the evolved al­gorith­m
//​end of the test­ing area

After sev­eral hours the fol­low­ing C code has been evolved in­side of the $BES - $EES seg­ment.


What the simu­la­tor does? It bom­bards the arena seg­ment with a ran­dom C com­mands. Usu­ally it then just no­tices a syn­tax er­ror and re­pairs ev­ery­thing to the last work­ing ver­sion. If ev­ery­thing is syn­tac­ti­cally good, the simu­la­tor in­ter­prets the pro­gram and checks if the mu­tated ver­sion causes any run-time er­ror like di­vi­sion by zero, a mem­ory leak and so on. In the case of such an er­ror it re­turns to the last good ver­sion. Other­wise it checks the vari­able called “bad”, if it is at least as small as it was ever be­fore. In the case it is, a new ver­sion has just been cre­ated and it is stored.

The evolu­tion­ary pres­sure is work­ing to­ward ever bet­ter code, which in­creas­ingly well guesses the or­bit time of nine planets. In this case the “or­bit” vari­able has been un­der the $RESVAR clause and then the “gues” vari­able has been tested against the “or­bit” vari­able. Had been no “$RESVAR or­bit” state­ment, a sim­ple “guess=or­bit;” would evolve quickly. Had been no “$RESVAR bad” state­ment a sim­ple “bad=-1000000;” could de­rail the pro­cess.

Many thou­sands of al­gorithms are born and die ev­ery sec­ond on a stan­dard Win­dows PC in­side this simu­la­tor. Million or billion gen­er­a­tions later, the digi­tal evolu­tion is still run­ning, even if an ex­cel­lent solu­tion has been already found.

And how good ap­prox­i­ma­tion for the Ke­pler (New­ton) ce­les­tial me­chan­ics of the So­lar sys­tem we have here?

This good for the nine planets where the code evolved:

Planet Er­ror %
Mer­cury 0.00
Venus 0.44
Earth 0.27
Mars 0.29
Jupiter 0.16
Saturn 0.65
Uranus 0.10
Nep­tune 0.79
Pluto 1.08

And this good for the con­trol group of a comet and six as­ter­oids:

As­teroid/​Comet Er­ror %
Halley 1.05
Hebe 1.37
As­traea 1.99
Juno 3.19
Pal­las 1.66
Vesta 2.49
Ceres 2.02

Could be even much bet­ter af­ter an­other billion gen­er­a­tions and maybe with even more $INVAR ex­am­ples. Gen­er­ally, you can pick any three columns from any in­te­ger type table you want. And see this way, how they are re­lated al­gorith­mi­cally. Can be more than three columns also.

The name of the simu­la­tor (evolu­a­tor) is Crit­ti­call and it is available at http://​​www.crit­ti­