I am a Python programmer that came to a situation in which i have to simulate genetical evolution of list's elements combination. The idea is presented below:
li #initial list
combinations=get_combinations(li) #not all possible combinations
results=[]
for c in combinations: results.append(do_stuff(li)) #do_stuff returns percantage of accuracu
At the end I have 2 lists: combinations
, that keeps some of the combinations of li
elements and results
, that keeps a percantage value o accuracy for each combination. The idea is to select a combination with the highest accuracy.
It is impossible to check all combinations of li
- that would take months of computing. I have to start from some random (I guess?) and then work my way to the best. What library should I use ? How to symulate evolution here ?
EDIT:
Alternatively: The set of elements evolves until it gets more than k% accuracy.
You have basically four possibilites:
This is, however, intractable as the number of combinations grows exponentially.
Generate random combinations until you get one good enough.
Start with some combination. Then make a small change to it. If the new one is better than the current one, make it the current one and repeat the process.
The above method can be vastly improved. One of the best such improvements (from my experience) is the Simmulated Annealing
Use an algorithm that simulates the natural evolution. The most basic evolutionary algorithm looks something like this:
Until the stopping condition is not met:
Either recombination or mutation must be present. Typically each is performed with some probabilty.
The challenge is to find a good representation allowing efficient recombination and mutation.