Here's what I want to write:
val alg10 = new GeneticAlgorithm[FlatDesign]
with PhenotypeSize(10)
with FlatDesignMutator
with ChildrenReplaceParents(numChildren=2)
with TargetFitnessFunction(targetPhenotype)
with PopulationSize(40)
with RunLength(numGenerations=100)
In other words, there are lots of constraints and parameters I'd like to set. For example, PhenotypeSize(10) has implications for the mutator and the fitness function. Abstract types ought to make it easy to implement/enforce all of those consistency constraints. Of course, traits can't take parameters, so this code won't work.
I love how composing traits lets you mix and match whatever functionality you need. The code above is so readable! With code like that, I could easily write a loop to try out the Cartesian product of lots and lots of variations to the algorithm.
I'm stuck, though, on finding a clean way to supply the parameters for those traits. Any suggestions?