[DM-dev] thoughts on modelling genetic data
Brought to you by:
acdalton,
henningsen
|
From: stephan b. <st...@s1...> - 2005-12-17 14:10:15
|
Hi again! i just got main.cpp building under toc and was poking around the code a bit... The Config type contains a variable (or container) for all of the various genes. As part of a different project i wrote up a class template for modelling genes in a generic manner, plus a container (Genome) to hold series of genes in. Attached are a couple of files which demonstrate how it works. It's based around two types, Gene<ValueType> and Genome<GeneType,KeyType>, and provides a consistent API for writing "breeding functors." These functors are used to breed genes using arbitrary algorithms/heuristics. If the genetic data is moved to such a model, classes like Config don't have to be updated for new gene types. The Genome type acts like a map, so to add new types you simply refer to them in your client code, thereby automatically adding them. The genetic data is also serializable using the s11n framework. A short demo of how to use it: typedef gene::Gene<int> Gene; typedef gene::Genome<Gene> Genome; Genome him; him["geekness"] = 5; him["taste_in_clothes"] = -2; Genome her; her["geekness"] = 0; her["taste_in_clothes"] = 7; Genome them = gene::breed_genomes( him, her, gene::breed_average_f() ); The results in this case would look like: geekness=2 taste_in_closes=2 but arbitrary breeder functors can be used to breed genes in arbitrary ways. -- ----- st...@s1... http://s11n.net "...pleasure is a grace and is not obedient to the commands of the will." -- Alan W. Watts |