Re: Haldane's Dilemma - clarifications - and Felsenstein [LONG]



[moderator's note: So far as I know there's no bar on posting
raw code in a sci.* newsgroup, so I let this through; note it's
a rather long posting, but with modern bandwidth, that should
not be a problem. Complaints to me, please. - JAH]

"Walter ReMine" <science@xxxxxxxx> wrote

There are MANY confusion factors concerning the cost of substitution.
And those are COMBINED TOGETHER in innumerable ways. Each researcher
incorporates his own unique blend of confusion factors. It would take
several chapters of a book to give a full diagnosis of each author's
approach. But my paper does not even pretend to be a full diagnosis of
each author's individual blend of confusions, nor is it a historical
treatment of the subject (or who said what, when). My paper is plenty
long enough without those side issues that are unnecessary for my
paper's stated purpose. Rather, my paper is what it claims to be -- a
clarification of the cost concept. My paper identifies the fundamental
CONFUSION FACTORS, shows why they are bad, and eliminates them.

OK. I will accept for the sake of argument that I am confused.

Here is a model, similar to one I wrote earlier, which shows beneficial
alleles spreading through a population. Can you tell me how to modify the
model to incorporate a cost of substitution to show the limit you are
interested in.

We have a population of diploid organisms, with alleles which can be
favourable ('A') or unfavourable ('a'). Initially all alleles are
unfavourable. Every generation there is a single mutation, which switches a
random locus from one state to the other.
To represent fitness, for each child slot in the next generation we take two
candidate mothers and two candidate fathers, chosen at random, and select
the one with the highest count of 'A' alleles. Alleles are thus additive and
with a fairly high selection coefficient.
The output is that, after 5000 generations, average fitness is around 2500,
substantially higher than your limit.

I appreciate that not everyone can read C code, though you ought to be able
to follow the basics. If we can build a model that shows the effect you are
interested in, we are in a position to talk. I am happy to spend as much
time as it takes testing out ideas.

I've looked at your website. You seem to accuse evolutionists of fudging
your evidence. Here's your chance.

/*
Model of favourable mutations spreading through a sexually-
reproducing population.
*/

#include <stdio.h>
#include <stdlib.h>


#define NGENES 2000 /* number of genes each creature has */
#define POPSIZE 1000 /* the size of the population */
#define NGENERATIONS 5000 /* number of generations to run simualtion for
*/

typedef struct
{
char matchromosome[NGENES]; /* maternal chromosome */
char patchromosome[NGENES]; /* paternal chromosome */
int fitness; /* fitness score (total of 'A' alleles) */
} CREATURE;

typedef struct
{
CREATURE males[POPSIZE/2]; /* males in population */
CREATURE females[POPSIZE/2]; /* females in population */
} GENERATION;

typedef struct
{
GENERATION gen1; /* generation 1 */
GENERATION gen2; /* generation 2 */
int toggle; /* flag to switch generations between child
and parent */
} WORKSPACE;

/*
generate a binary random number (to fix up technical deficiencies in
rand())
*/
int coinflip(void)
{
return rand() > RAND_MAX/2 ? 1 : 0;
}

/*
choose a parent
Params: candidates - list of potential parents
N - number in list
Returns: the selected parent
We take two at random, and return the one with the highest fitness,
or the second to be examined if equal.
*/
int choose(CREATURE *candidates, int N)
{
int one;
int two;

one = rand() % N;
two = rand() % N;

if(candidates[one].fitness > candidates[two].fitness)
return one;
else
return two;
}

/*
generate a child from two parents
Params: child - return for child
mother - parent 1
father - parent 2
The child has a maternal and a paternal chromosome, formed by
random recombination of the parental chromosomes.
This is as in most diploid organisms.
The child's fitness is his total of 'A' genes.
*/
void makechild(CREATURE *child, CREATURE *mother, CREATURE *father)
{
int crossover;
int fitness = 0;
int chromosome;
int i;

crossover = rand() % NGENES;
chromosome = coinflip();

if(chromosome)
{
memcpy(child->matchromosome, mother->matchromosome, crossover);
memcpy(child->matchromosome + crossover, mother->patchromosome +
crossover, NGENES - crossover);
}
else
{
memcpy(child->matchromosome, mother->patchromosome, crossover);
memcpy(child->matchromosome + crossover, mother->matchromosome +
crossover, NGENES - crossover);
}


crossover = rand() % NGENES;
chromosome = coinflip();

if(chromosome)
{
memcpy(child->patchromosome, father->matchromosome, crossover);
memcpy(child->patchromosome + crossover, father->patchromosome +
crossover, NGENES - crossover);
}
else
{
memcpy(child->patchromosome, father->patchromosome, crossover);
memcpy(child->patchromosome + crossover, father->matchromosome +
crossover, NGENES - crossover);
}

for(i=0;i<NGENES;i++)
{
if(child->matchromosome[i] == 'A')
fitness++;
if(child->patchromosome[i] == 'A')
fitness++;
}
child->fitness = fitness;
}

/*
generate a mutation.
A random target gene is flipped from 'a' to 'A' or back
*/
void mutate(GENERATION *gen)
{
int sex;
int chromosome;
int gene;
int id;
int fitness = 0;
CREATURE *creature;
char *target;
int i;


sex = coinflip();
id = rand() % (POPSIZE/2);
chromosome = coinflip();
gene = rand() % NGENES;

if(sex)
creature = &gen->males[id];
else
creature = &gen->females[id];

if(chromosome)
target = &creature->patchromosome[gene];
else
target = &creature->matchromosome[gene];

if(*target == 'a')
*target = 'A';
else
*target = 'a';


for(i=0;i<NGENES;i++)
{
if(creature->matchromosome[i] == 'A')
fitness++;
if(creature->patchromosome[i] == 'A')
fitness++;
}
creature->fitness = fitness;
}

/*
generate the next generation
*/
void nextgeneration(GENERATION *children, GENERATION *parents)
{
int i;
int mother;
int father;

for(i=0;i<POPSIZE/2;i++)
{
mother = choose(parents->females, POPSIZE/2);
father = choose(parents->males, POPSIZE/2);
makechild(&children->males[i], &parents->females[mother],
&parents->males[father]);
mother = choose(parents->females, POPSIZE/2);
father = choose(parents->males, POPSIZE/2);
makechild(&children->females[i], &parents->females[mother],
&parents->males[father]);

}
mutate(children);
}

/*
run the simualtion for one step
(we toggle generations to avoid unnecessary copying of data)
*/
void step(WORKSPACE *wk)
{
if(wk->toggle)
nextgeneration(&wk->gen1, &wk->gen2);
else
nextgeneration(&wk->gen2, &wk->gen1);

wk->toggle = 1 - wk->toggle;
}

/*
set up intial creature with all 'a' alleles
*/
void initialisecreature(CREATURE *creature)
{
int i;

for(i=0;i<NGENES;i++)
{
creature->matchromosome[i] = 'a';
creature->patchromosome[i] = 'a';
}
creature->fitness = 0;
}

/*
set up the initial generations
*/
void initialisegen(GENERATION *gen)
{
int i;

for(i=0;i<POPSIZE/2;i++)
{
initialisecreature(&gen->males[i]);
initialisecreature(&gen->females[i]);
}
}

/*
initialise the workspace
*/
void intialiseworkspace(WORKSPACE *wk)
{
initialisegen(&wk->gen1);
initialisegen(&wk->gen2);
wk->toggle = 0;
}

int main(void)
{
static WORKSPACE workspace;
int i;

intialiseworkspace(&workspace);
for(i=0;i<NGENERATIONS;i++)
{
step(&workspace);
printf("%d\n", workspace.gen1.males[0].fitness);
}

for(i=0;i<POPSIZE/2;i++)
printf("%d\n", workspace.gen1.males[i].fitness);

return 0;
}
--
Buy my book 12 Common Atheist Arguments (refuted)
$1.25 download or $7.20 paper, available www.lulu.com/bgy1mm



.



Relevant Pages

  • Re: Bryns next album due out in September
    ... Int. ... CD 477 588-6 Bryn Terfel ... Mozart was the original crossover composer - what do you think Eine ... And then, of course, there is Mr Mozart's music for the dancing horses. ...
    (rec.music.opera)
  • Re: Bryns next album due out in September
    ... (Unless Mozart composed some crossover stuff that I was previously ... Int. ... CD 477 588-6 Bryn Terfel ... Kleine Nachtmusik is...? ...
    (rec.music.opera)
  • Re: Class/structure/something else in class
    ... measurecurrent(channel as int) ... measureamp as this is just send a textstring to the serial port. ... Create a class for the Measure and ScanAdd properties, and make their constructors take either a reference to the serial port object or the parent object. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Missing Data in Cube / MDX Question
    ... It is probably more likely that the hierarchy should be the other way ... It sounds like your dimension records possibly start out in a parent ... EquipHierarchyKey int not null, ...
    (microsoft.public.sqlserver.olap)
  • Re: OpenXML Inserting to 4 Existing Tables
    ... the parent to join to the child. ... importParentId int) ... DECLARE @importId uniqueidentifier ... > derivativeTable elements and not the ownershipDocument. ...
    (microsoft.public.sqlserver.xml)