Re: The "evolution" of GA Math

new topic     » goto parent     » topic index » view thread      » older message » newer message

DB James wrote:

> Hi Al,
> 
> Having read your post, I scratched my head and decided to replicate your test
> with
> y=a*log(x+1).  As you see, I used "log" rather than "ln".
> 
> So, I brought up eval.e and made the necessary changes, then had to modify GA
> Math
> to add the log function and to handle multiple-character function-name input.
> (You
> had to do something similar.)
> 
> Okay, so I ran the thing and got a weird result, so I created a test for
> eval.e to
> see how it handled the formula "y=a*log(x+1)".  Whoa, it only calcuated
> "y=log(x+1)",
> dropping the "a*" part. (I copied the final test to the bottom of this
> message.)
> 
> So, when David Cuny warned about left-to-right evaluation, he wasn't kidding. 
>
> 
> If you use "y=a*(log(x+1))", then it works fine.  Here are two example
> reports:
> 
> --------------------------------------------------
> GA Math Beings Report
> --------------------------------------------------
> Math Beings working on formula    : y=a*(log(x+1))
> Number of try-sets per run        : 1200
> Number of runs this session       : 7
> Number of tries per try-set       : 8
> This is try-set number            : 60
> Target value                      : 0.0010
> Current closeness (percent)       : 0.000785
> 
> Most successful being's original register values:
>   {[10.67] , [9.75] , [7.06] , [0.99] , [0] , [0] , [0]}
> 
> 
> Most successful being's genes:
> rec, 4, 6
>   {[10.67] , [9.75] , [7.06] , [0.99] , [0] , [1.01] , [0]}
> add, 6, 2, 6
>   {[10.67] , [9.75] , [7.06] , [0.99] , [0] , [10.76] , [0]}
> log, 6, 5
>   {[10.67] , [9.75] , [0.99] , [0.99] , [2.38] , [10.76] , [7.06]}
> mul, 5, 1, 7
>   {[10.67] , [9.75] , [1.01] , [0.99] , [2.38] , [10.76] , [25.34]}
> 
> Last actual answer from formula: 25.339
> 
> --------------------------------------------------
> GA Math Beings Report
> --------------------------------------------------
> Math Beings working on formula    : y=a*(log(x+1))
> Number of try-sets per run        : 1200
> Number of runs this session       : 3
> Number of tries per try-set       : 8
> This is try-set number            : 500
> Target value                      : 0.0010
> Current closeness (percent)       : 0.000000
> 
> Most successful being's original register values:
>   {[9.37] , [1.23] , [2.50] , [1.24] , [0] , [0] , [0]}
> 
> 
> Most successful being's genes:
> div, 1, 1, 4
>   {[9.37] , [1.23] , [-2.50] , [1.00] , [0] , [0] , [0]}
> add, 2, 4, 2
>   {[9.37] , [2.23] , [-2.50] , [1.00] , [0] , [0] , [0]}
> sub, 1, 5, 4
>   {[9.37] , [2.23] , [-2.50] , [9.37] , [0] , [0] , [0]}
> log, 2, 3
>   {[9.37] , [2.23] , [0.80] , [9.37] , [0] , [0] , [0]}
> mul, 4, 3, 7
>   {[-2.23] , [2.23] , [0.80] , [9.37] , [0] , [0] , [7.53]}
> 
> Last actual answer from formula: 7.531
> 
> --Quark
> 
> The test:
> function RandRangeDec(integer lo, integer hi)
>     return rand(hi-lo+1)+lo-1 + rand(999)/1000
> end function
> sequence f
> for i=1 to 10 do
>     var['a']=RandRangeDec(0,11)
>     var['x']=RandRangeDec(0,11)
>     printf(1,"a=%f ",var['a'])
>     printf(1,"x=%f\n",var['x'])
>     f="y=a*(log(x+1))"
>     printf(1,"eval(f): %f  ",eval(f))
>     printf(1,"actual: %f\n", var['a']*log(var['x']+1))
> end for
> 

Hi Quark,

Yes, i had found that eval.e cant handle a multiplication before
a function such as a*ln(x) or k*sin(x), etc., so i ended up doing
the same thing temporarily.  Putting parens around the function
seemed to work so i did that too: y=a*(ln(x+1))
This means i was doing basically the same thing you were doing :)
BTW i used "ln" instead of "log" because in the math world "log"
usually refers to log base 10 and ln refers to log base e, and
in GA Math i ended up making it skip the "l" and the "n" as variables
(it wanted to make l and n variables at first).

The interesting thing is, both of your runs came out algebraically
either exact or nearly so, so perhaps my run was a fluke or something
where it somehow got sidetracked, or perhaps returning a large
negative number as a 'penalty' isnt a good idea?
So what did you use for the log function in GA Math then...
when the number is positive i guess it's log(), but what about
when it's negative, or zero?  Those are three possibilities so
if i knew what lines you used in GA Math for function #11 i could
try the same.


Take care,
Al

And, good luck with your Euphoria programming!

My bumper sticker: "I brake for LED's"

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu