A companion blog post (When will evolution outperform local search?) introduces Contingent Parities Functions and compares the behavior of recombinative evolution and simulated annealing on a member of this class of fitness function.
Simulated annealing and a genetic algorithm can be run on a contingent parities function of order 2 and height 100 as follows:
import royalroads as rr rr.SA(rngSeed=1, numPeriods=1000)
import royalroads as rr rr.GA(rngSeed=1, numGenerations=1000, useClamping=False)
To compare the performance of the two algorithms on the contingent parities function:
import royalroads as rr rr.compareAlgorithms(numRuns=40)
mmh3, matplotlib, joblib