I realize that arrays were not built this way in PHP. however I am experimenting with genetic algorithms for the first time, and as PHP is the language most familiar to me, I am writting it in PHP, later I will change it to Python. Anyway, i have two input arrays, one of which being:
$geneValues = array(
'0000' => 0,
'0001' => 1,
'0010' => 2,
'0011' => 3,
'0100' => 4,
'0101' => 5,
'0110' => 6,
'0111' => 7,
'1000' => 8,
'1001' => 9,
'1010' => '+',
'1011' => '-',
'1100' => '*',
'1101' => '/');
each key is a "gene" that stores a value. I am attempting to do this completely hands off other than the initial array setting, i have a function that creates The initial population by randomly combining the above array genes into a multidimensional array which groups the genes into, you guessed it, chromosomes. so i could have a chromosome that looks like: 011010100111
meaning => 6 + 7
this all works great. However I am at the point where I need to actually "compute" the chromosome, however as the addition operator has to be in quotes in the array, it makes a literal +
and not the operator. My question is, is there any way that I can get the operators in my array to be actual operators, I know of know function that will do this, and the only other option i can come up with would be to hard code the gene to the operator when i do the computations, which is what im trying to avoid.
I will post the whole code if needed, it's nothing sensitive, just trying to ease my way into neural networks and figured i would start with implementing genetic algorithms. Any one have a solution?