# [Answered] Real numbers (constants) in genetic programming

This topic is 2094 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello,

I can't figure out how a genetically programmed A.I. can determine when there should be a constant in the final equation. If I take the formula F(m) = ma; F(m) = m9.8, how can the A.I. know what the real number 9.8 actually is? I understand that instead of putting the final number in the binary tree, you can actually put a symbol that describes a constant and then later calculate or guess what is its value in a certain way. How would you do it?

Thank you,
Thecheeselover

##### Share on other sites

I don't quite understand the question or what it has to do with genetic algorithms. GAs are just a way of gradually tweaking function parameters by employing genetics and evolutional methods. The goal is to improve the overall 'fitness' of the system.

##### Share on other sites

I don't quite understand the question or what it has to do with genetic algorithms. GAs are just a way of gradually tweaking function parameters by employing genetics and evolutional methods. The goal is to improve the overall 'fitness' of the system.

If I use GP to find the quadratic formula, how an individual could find the constants? (-b +- sqrt(b² - 4ac)) / (2a) In this example, the constants are 4 and 2.

##### Share on other sites

who cares about making it complex, just kill off freaks so only the most fitting survives.  just make it regenerate its sense data :)

##### Share on other sites

The implementation that I used for genetic programming was representing the program as a tree.  Each node in the the tree had an INode interface with a method 'Evaluate( INode[] params)'

Then I had concrete implementations of nodes for each of the different operators I wanted to represent

operator+

operator*

sqrt

while(...)

if(...)

and so on...

I also had a literal operator which just returned a bounded value which was generated randomly at instantiation of the tree (through initial creation or mutation)

so at runtime I would create a concrete class through c# IL  e.g.

class literal5 : INode

{

INode Execute(INode[] params)

{

return 5.0;

}

}

hope that helps

• 18
• 29
• 11
• 24
• 20
×

## Important Information

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!