Saturday, May 5, 2012

C++ : Symbolic Regression - Part 1

I'm not dead.  Just working on something that's taking an awful long amount of time.  That's my excuse for my recent post-truancy.

'Wired: Computer Self Discovers Laws of Physics'

See that article up there?  Click on it.  No?  Fine, here's what it says in a nutshell.  Some people over at Cornell University stuck a bunch of LED lights onto a chaotic pendulum, hooked up an LED detector onto a computer, and fed the data through some fancy algorithms based on symbolic regression that calculated the gravity equation from scratch.

Sounds complicated?  It's not.  It's actually extremely simple.  Here's the generalized workflow:
  1. Feed some data into the computer, like the positions of the LED lights.  These are your state variables.
  2. Use some fancy maths to find the partial derivatives between the state variables.  Partial derivatives are used to calculate relations between variables.
  3. Generate thousands of equations randomly, and use genetic algorithms for mutation (value mutation, crossover, etc.).  The equations that match the data the closest (via plugging in values) have the highest priority in mutation.  This is the symbolic regression step.
  4. Repeat step 3 a hundred thousand gazillion times and after an infinite number of iterations you should converge to the exact equation that fits the data.
That's all.  It's very simple.

Programming Symbolic Regression

The main programming obstacles here are as follows:
  1. Building equations in program-my form.  There's a predetermined set of operators made into functions and stored as function pointers (add(a,b), sub(a,b), mul(a,b), div(a,b), sin(a), cos(b), among others).
  2. Solving partial derivatives symbolically.  I have no idea how to do this yet but I'm sure it's not that hard?
  3. Optimizing it so it doesn't take a hundred thousand years to calculate something nice.
 That's the gist of it.  If I make any progress I'll mention it on the blog.

If you're interested in your own research, here's the material for the Cornell project.  It's a little intimidating to read but isn't all that bad; most of the unfamiliar terms can be figured out in context.

Overview: Distilling Free-Form Natural Laws from Experimental Data
Supporting Online Material


  1. Sounds complicated-y :P
    Me no understand (me haz IQ of 3) xD

    1. Pshh, it's not too bad. It's fancy-sounding and that's about it.

      Also WHOA I recognize you from GMC! What's going on whoa hi