RE: Handling Overflow When Doing Random Math

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

> 
> I wrote a program once in C that used "math-beings" in a genetic
> algorithm to evolve equations from inputs.  Inaccurate beings were
> treated the way nature treats inadequate lifeforms, of course.  It
> worked, and the answers were interesting, even amusing -- the
> algorithms were so unlike ours.  I wanted to develop this to include a
> math parser, so the user could easily enter new formulas for the
> program to try to match, but never got around to doing that.  The
> distant ultimate goal was to have a "math-world" that could evolve
> genuinely new math responses from inputs, where the formula was not
> given (or even known).
> 
That is basically genetic programming you are describing, and it is 
almost exactly what my program does, using the procedure described at:

http://www.gene-expression-programming.com/

It is not limited to math functions, although that is mainly what I've 
been doing.  I also incorporate boolean operators so it can do 
comparisons, use if statements, etc.

The basic framework can handle any type of program, really.

> tiny).  I had to fight the overflow problem constantly and never took
> the time to do that job cleanly.  The point of all this is a question:
> does anyone think there would be a simple way to confine specialized
> randomly called math functions to numbers between -1 and +1 with a
> scaling function?  This would be a loose analogy to core wars where
> all the action is confined to a limited space.  I suspect there would
> be precision issues here, but maybe that could be handled, at least
> for the purposes of random math.  

If I'm trying to "discover" a function based on a series of examples, 
you just minimize the error and it automatically comes up with an 
appropriate function.  For example, given this as input:

1,2,3
2,3,7
3,4,13
4,5,21

where the first two numbers are inputs & the third is the output, it 
will quickly discover the equivalent of the function:

(a*a) + b

(i.e. (4*4)+5 = 21)

I say equivalent because as you noted it will come up with strange ways 
to represent things, using something like (a-a)*(b+a) to simply 
represent 0, for instance.


If you don't want to force a particular output or if you're trying to 
output a probability where you can't explicitly provide a target value 
because it all depends on context, I just let it make outputs on 
whatever scale it feels like, and then normalize them or re-scale them.  
Does that make sense?  I found it works somewhat better than trying to 
force it into a particular range when you don't have a specific target 
in that range.  (The exception is when you want a binary output -- 0/1.  
Then you force it.)

Of course, the math functions are already within a particular range 
because of the overflow problem.  When my system generates a function 
that causes overflows, it gets a low fitness and dies. You could of 
course make the overflow threshold anything you want, really.  (When I 
want a boolean output, for instance, only functions that output 0's & 
1's have a chance of getting a high fitness.)  Sometimes I specify 
positive numbers only, etc.

The key is the fitness function.  As long as you can evaluate the 
outputs it gives you, and rank them so that one is considered better 
than some other one, then any method will work, but some will take 
longer than others.  Such is the power of evolution...

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

Search



Quick Links

User menu

Not signed in.

Misc Menu