Source code for kinship and fertility

This will include the C++ source code, a blank work sheet for more work and then a summary, which will include parameters used for the runs described in “Kinship governs fertility with pre- and post-zygotic mechanisms mediated by match of methylation patterns”  You may have to do some tweaking.   https://www.biorxiv.org/search/Kinship%252Bgoverns%252Bfertility%252Bwith%252Bpre-%252Band%252Bpost-zygotic%252Bmechanisms%252Bmediated%252Bby%252Bmatch%252Bof%252Bmethylation%252Bpatterns%252B%252B, and an example of a saved population.  Just for fun I put in notes from the search. 

SOURCE CODE (Microsoft visual C++ 6.0)
/* This is a program to simulate the behavior of a population that is limited in size by
decreasing fertility with greater size and less kin members on average.  The program models
the genetic makeup of the population.  Genetic is to be understood in the broadest possible
sense to include epigenetic effects or any other inheritable factor.  This progam is named
"Accumulatign" for "Accumulating infertilty."
First we load our tools.*/
#include <iostream>
#include <iomanip>
#include <cmath> 
#include <cstdlib>
#include <fstream> 
#include <ctime>
using std::ios;
using std::ofstream;
using std::ifstream;
using std::cout;
using std::cin;

// Next the variables.
int RunNumber;
int MaxSims;
int Sims;
int MaxGens;
int Gens;
int MaxProgeny;
int OffspringComing;
int maxprogeny;
int InitPopSize;
int initpopsize;
int MaxPopSize;
int PopSize = 0;
int InNextGeneration;
long TopofHeap;
int Genes;
long GeneMutRate;
int PreZsites;
long PreZMutRate;
long PreZImpact;
int PostZsites;
long PostZMutRate;
long PostZImpact;
int AddFile;
int Incoming;
int incoming;
long ID;
long Arrow;
long Dart;
int slot;
int Mate;
long FickleFinger;
long Chance;
int Courting;
long coin;
long Coin;
int Lethal;
long Loss;
long MisMatch;
long mismatch;
long PreZInfertility;
long PostZInfertility;
int Delay;
int delay;
long AccumulatedInfertility;
int NotLastRun = 1;
int End;

//Then we establish the arrays.
long Population[1000][542];
long CurrentMate[542];
long OtherMate[542];
long Offspring[542];
long NextGeneration[100000][542];
int EndPopulations[101];
long FinalGenerations[100];
long PopHistory[1000000];
long main (long)

            {//1 Main

// This is probably a good moment to start the random numbers.
srand(time(0));

// We let the user put his choices in.
RunNumber = 0;
cout << "\n What will be the number to identify this run?\n";
cin >> RunNumber;

            MaxSims = 101;
cout << "\n How many simulations do you want to run?  Don't go over 100. \n";
while (MaxSims > 100)
{//2 Choose MaxSims
cin >> MaxSims;
}//2 Choose MaxSims

            MaxGens = 1000001;
while (MaxGens > 1000000)
{//3 Choose MaxGens
cout << "\n Up to how many generations will each simulation last?\n";
cout << "\n Don't go over 1,000,000. No commas.\n";
cin >> MaxGens;
}//3 Choose MaxGens

            MaxProgeny = 201;
while(MaxProgeny>200)
{//4 Choose MaxProgeny
cout << "\n How many offspring maximum can one pair have? (200 is the maximum.)\n";
cin >> MaxProgeny;
}//4 Choose MaxProgeny
maxprogeny = MaxProgeny;

            InitPopSize = 1001;
while(InitPopSize>1000)
{//5 Choose InitPopSize
cout << "\n What size will your initial population be?  \n";
cout << "\n 100 would be a good start.\n Don't go over 1,000.  No comma.\n";
cin >> InitPopSize;
}//5 Choose InitPopSize
initpopsize = InitPopSize;

            MaxPopSize = 1001;
while(MaxPopSize>1000)
{//6 Choose MaxPopSize
cout << "\n What will your maximum population be?  Don't go over 1,000.  \n";
cout << "\n Don't use commas.\n";
cin >> MaxPopSize;
}//6 Choose MaxPopSize

            Genes = 51;
while(Genes > 50)
{//7 Choose Genes
cout << "\n How many gene pairs subject to recessive lethal mutations?  \n";
cout << "\n Don't go over 50.\n";
cin >> Genes;
}//7 Choose Genes

            GeneMutRate = 100001;
while(GeneMutRate > 100000)
{//8 Choose GeneMutRate
cout <<"\n How many genetic mutations per site per 100,000 generations?  \n";
cout << "\n Don't go over 100,000. \n";
cin >> GeneMutRate;
}//8 Choose GeneMutRate

            PreZsites = 101;
while(PreZsites > 100)
{//9 Choose PreZsites
cout << "\n How many sites will affect pre zygotic fertility?  \n";
cout << "\n Don't go over 100.\n";
cin >> PreZsites;
}//9 Choose PreZsites

            PreZMutRate = 100001;
while(PreZMutRate > 100000)
{//10 Choose PreZMutRate
cout << "\n What change rate per site per 100,000 generations?  \n";
cout << "\n Don't go over 100,000.\n";
cin >> PreZMutRate;
}//10 Choose PreZMutRate

            PreZImpact = 100001;
while(PreZImpact > 100000)
{//11 Choose PreZImpact
cout << "\n How many thousandths of 1 offspring will a unit of mismatch result \n";
cout << "\n in losing.  500 would have a 50% chance of losing one. \n";
cout << "\n Don't go over 100,000.\n";
cin >> PreZImpact;
}//11 Choose PreZImpact

PostZsites = 101;
while(PostZsites > 100)
{//12 Choose PostZsites
cout << "\n How many sites will affect post zygotic fertility?  \n";
cout << "\n Don't go over 100.\n";
cin >> PostZsites;
}//12 Choose PostZsites

            PostZMutRate = 100001;
while(PostZMutRate > 100000)
{//13 Choose PostZMutRate
cout << "\n What change rate per site per 100,000 generations?  \n";
cout << "\n Don't go over 100,000.\n";
cin >> PostZMutRate;
}//13 Choose PostZMutRate

            PostZImpact = 100001;
while(PostZImpact > 100000)
{//14 Choose PostZImpact
cout << "\n How many thousandths of 1 offspring will a unit of mismatch result\n";
cout << "\n in losing.  500 would have a 50% chance of losing one. \n";
cout << "\n Don't go over 100,000.\n";
cin >> PostZImpact;
}//14 Choose PostZImpact

            Delay = 21;
while(Delay > 20)
{//102 Choose Delay
cout << "\n The program will let post zygotic infertilty accumulate for up to 20\n";
cout << "\n generations.  Choose at least 1 for any effect.  Don't go over 20.\n";
cin >> Delay;
}//102 Choose Delay

            AddFile = 0;
cout << "\n As the program runs, the screen will print out the number of offspring\n";
cout << "\n each generation.  Do you wish to add a file? 1 for yes, 0 for no.  \n";
cout << "\n Don't add more than are saved  or more than there is room for. \n";
cin >> AddFile;
if(AddFile == 1)
{//15a Add file
cout << " How many?  File should be saved on drive C as InPop.\n";
cin >> Incoming;
}//15a Add file
else
{//15b Add no file
}//15b Add no file

            cout << "\n";

            //We start running the simulations.
Sims = 1;
while(Sims<=MaxSims)
{//Begin Sims.//16 Sims
if(ID>1000000) //We make sure not to overrun ID.
{//17a Reset ID
ID = 0;
}//17a Reset ID
else
{//17b Don't reset ID
}//17b Don't reset ID
//We create a population.
PopSize = 0;
while(PopSize < InitPopSize)
{//Begin create population.//18 Create population
Population[PopSize][0] = ID;
ID = ID + 1;
Population[PopSize][1] = 0;
Arrow = 541;
while(Arrow >= 1)
{//19 Zero out array
Population[PopSize][Arrow] = 0;
Arrow = Arrow - 1;
}//19 Zero out array
PopSize = PopSize + 1;
}//End create population.//18 Create population

                        //We import a population.
if(AddFile == 1)
{// Begin import files. //20a Import population
incoming = Incoming;
ifstream File("C:\\InPop", ios:: in);
while(incoming > 0)
{//21 Importing
Arrow = 0;
while(Arrow<=541)
{//22 Copy one
File >> slot;
Population[PopSize][Arrow] = slot;
Arrow = Arrow + 1;
}//22 Copy one
Population[0][PopSize] = ID;
ID = ID + 1;
PopSize = PopSize + 1;
incoming = incoming - 1;
}//21 Importing
File.close();
}// End import files.//20a Import population

                        else //We do not import from a file.
{//20b Don't import
}//20b Don't import

                        //Begin running generations.
Gens = 1;
while(Gens <= MaxGens)
{//Begin Generations.//23 Gens
Mate = 0;
InNextGeneration = 0;
while(PopSize > 1)
{//Begin running the population.//24 Run pop
if (Mate == 0)
{//Begin find mates.//25a Find mates

                                                            //We take the first mate.
Arrow = 541;
while(Arrow>=0)
{//Begin copy current mate.//26 Copy current mate
TopofHeap = PopSize - 1;
CurrentMate[Arrow] = Population[TopofHeap][Arrow];
Arrow = Arrow - 1;
}//End copy current mate.//26 Copy current mate

                                                            //We take another mate from what is left.
TopofHeap = TopofHeap - 1;
if(TopofHeap == 0)
{//27a Out of mates
Courting = 0;
}//27a Out of mates
else
{//27b Find a mate
TopofHeap = TopofHeap + 1;
FickleFinger = rand()*rand();
Courting = FickleFinger % TopofHeap;
}//27b Find a mate
Arrow = 541;
while(Arrow>=0)
{//Begin copy other mate.//28 Copy other mate
OtherMate[Arrow] = Population[Courting][Arrow];
//Fill the place where other mate was.
Population[Courting][Arrow] = Population[TopofHeap][Arrow];

                                                                        Arrow = Arrow - 1;
}//End copy other mate.//28 Copy other mate
Mate = 1;
}//End find mates.//25a Find Mates
else
{//Begin make many offspring.//25b Make many offspring
OffspringComing = MaxProgeny;//We allow for infertility starting
//with pre zygotic.

//We calculate pre zygotic infertility.
if (PreZsites> 0 )
{//29a PreZsites > 0
Arrow = 50 + PreZsites;
Dart = 320 + PreZsites;
MisMatch = 0;
mismatch = 0;

                                                            while(Arrow > 100)                             
{//30 Count PreZsites
mismatch = Offspring[Arrow] - Offspring[Dart] ;
if(mismatch < 0)                                   
{//31a Change to positive
mismatch = mismatch * -1;
}//31a Change to positive
else
{//31b Leave positive
}//31b Leave positive
MisMatch = MisMatch + mismatch;
mismatch = 0;
Arrow = Arrow - 1;
Dart = Dart - 1;
}//30 Count PreZsites
PreZInfertility = 0;
Loss = PreZImpact * MisMatch;
if(Loss >= 1000)
{//32a Lower fertility one offspring at a time
while(Loss >= 1000)
{//33
PreZInfertility = PreZInfertility +1;
Loss = Loss - 1000;
}//33
}//32a Lower fertility one offspring at a time
else
{//32b No whole offspring lost
}//32b No whole offspring lost
coin = rand();
Coin = coin % 1000;
if(Loss > Coin)
{//34a Lose fractional offspring
PreZInfertility = PreZInfertility + 1;
}//34a Lose fractional offspring
else
{//34bKeep fractional offspring
}//34b Keep fractional offspring

                                                            OffspringComing = OffspringComing - PreZInfertility;
}//29a PreZsites > 0
else
{//29b PreZsites = 0
}//29b PreZsites = 0

//Then we take out the post zygotic infertility of each parent.

                                                            OffspringComing = OffspringComing - CurrentMate[541];
OffspringComing = OffspringComing - OtherMate[541];
if(OffspringComing >0)
{//35a If making offspring
while(OffspringComing > 0)
{//Make one offspring. //36Make one offspring
Offspring[0] = ID;
ID = ID + 1;
coin = rand();
Coin = coin % 2;
if(Coin == 1)
{//Begin copy one chromosome.//37a Copy one chromosome
Arrow = 270;
while(Arrow > 0)
{//38 Copy
Offspring[Arrow] = CurrentMate[Arrow];
Arrow = Arrow - 1;
}//38  Copy
}//37a Copy one chromosome
else
{//37b Copy other chromosome
Arrow = 270;
Dart = 540;
while(Arrow > 0)
{//39 Copy
Offspring[Arrow] = CurrentMate[Dart];
Arrow = Arrow - 1;
Dart = Dart - 1;
}//39 Copy
}//End copy one chromosome.//37b Copy other chromosome

                                                                                    coin = rand();
Coin = coin % 2;
if(Coin == 1)
{//Begin copy second chromosome//40a Copy second chromosome
Arrow = 540;
while(Arrow > 270)
{//41 Copy
Offspring[Arrow] = OtherMate[Arrow];
Arrow = Arrow - 1;
}//41 Copy
}//40a Copy second chromosome
else
{//40b Copy other second
Arrow = 540;
Dart = 540;
while(Arrow > 270)
{//42 Copy
Offspring[Arrow] = OtherMate[Dart];
Arrow = Arrow - 1;
Dart = Dart -1;
}//42 Copy
}//End copy second chromosome.40b Copy other second

//We check to see if there are matched recessive lethals.
Arrow = 50;
Dart = 320;
Lethal = 0;
while(Arrow > 0)
{//Check for lethal.//43 Check for lethal
if(Offspring[Arrow] + Offspring[Dart] > 1)
{//44a Lethal
Lethal = 1;
}//44a Lethal
else
{//44b Not Lethal
}//44b Not Lethal
Arrow = Arrow - 1;
Dart = Dart - 1;
}//43 Check for lethal
if(Lethal == 1)
{//45a Lose one offspring
OffspringComing = OffspringComing - 1;
}//End check for lethal//45a Lose one offspring.
else
{ //We continue .//45b Continue with offspring
OffspringComing = OffspringComing -1;

//We mutate the genes.
if(GeneMutRate > 0)//Begin mutate genes.
{//46a Mutate Genes
Arrow = 0 + Genes;
while(Arrow > 0)
{//47 Mutate one
FickleFinger = rand() * rand();
Chance = FickleFinger % 100000;
if(GeneMutRate > Chance)
{//48a change
Offspring[Arrow] = 1;
}//48a change
else
{//48b Don't change
}//48b// Don't change
Arrow = Arrow - 1;
}//47 Mutate one         
Arrow = 270 + Genes;
while(Arrow > 270)
{// 49 Mutate other
FickleFinger = rand() * rand();
Chance = FickleFinger % 100000;
if(GeneMutRate > Chance)
{//50a Change 
Offspring[Arrow] = 1;
}//50a Change
else
{//50b Don't change
}//50b Don't change
Arrow = Arrow -1;
}// 49 Mutate other
}//46a Mutate Genes
else
{//46b Don't mutate Genes                                                                                                       
}//End mutate // genes.//46b Don't mutate Genes

//We mutate the PreZsites.
if(PreZsites > 0)
{//Begin mutate PreZsites. //51a Mutate PreZsites
Arrow = 50 + PreZsites;
while(Arrow>50)//Mutate first PreZsites segment.
{//52 Count PreZsites one
FickleFinger = rand() * rand();
Chance = FickleFinger % 100000;
if(PreZMutRate > Chance)
{//53a Change
coin = rand();
Coin = coin % 2;
if(Coin = 1)
{//54a Increase
Offspring[Arrow] = Offspring[Arrow] + 1;
}//54a Increase
else
{//54b Decrease
Offspring[Arrow] = Offspring[Arrow] - 1;
}//54b Decrease
}//53a Change
else
{//53b Don't change
}//53b Don't change
Arrow = Arrow - 1;
}//52 Count PreZsites one

Arrow = 320 +PreZsites;
while(Arrow>320)//Mutate other PreZsites segment.  
{//55 Count PreZsites two
FickleFinger = rand() * rand();
Chance = FickleFinger % 100000;
if(PreZMutRate > Chance)
{//56a Change
coin = rand();
Coin = coin % 2;
if(Coin == 1)
{//57a Increase
Offspring[Arrow] = Offspring[Arrow] + 1;
}//57a Increase
else
{//57b Decrease
Offspring[Arrow] = Offspring[Arrow] - 1;
}//57b Decrease
}//56a Change
else
{//56b Don't change
}//56b Don't change
Arrow = Arrow - 1;
}//55 Count PreZsites two
}//51a Mutate PreZsites
else
{//51b Don't mutate PreZsites
}//51b Don't mutate PreZsites

//End mutate PreZsites.

                                                                                                //We mutate the PostZsites.
if(PostZsites > 0)
{//Begin mutate PostZsites.//58a Mutate PostZsites
Arrow = 150 + PostZsites;
while(Arrow>150)//Mutate first PostZsites segment.
{//59 Count PostZsites one
FickleFinger = rand() * rand();
Chance = FickleFinger % 100000;
if(PostZMutRate > Chance)
{//60a Change
coin = rand();
Coin = coin % 2;
if(Coin = 1)
{//61a Increase
Offspring[Arrow] = Offspring[Arrow] + 1;
}//61a Increase
else
{//61b Decrease
Offspring[Arrow] = Offspring[Arrow] - 1;
}//61b Decrease
}//60a Change
else
{//60a Don't change
}//60a Don't change
Arrow = Arrow - 1;
}//59 Count PostZsites one

Arrow = 420 +PostZsites;
while(Arrow>420)//Mutate other PostZsites segment.
{//62 Count PostZsites two
FickleFinger = rand() * rand();
Chance = FickleFinger % 100000;
if(PostZMutRate > Chance)
{//63a Change
coin = rand();
Coin = coin % 2;
if(Coin == 1)
{//64a Increase
Offspring[Arrow] = Offspring[Arrow] + 1;
}//64a Increase
else
{//64b Decrease
Offspring[Arrow] = Offspring[Arrow] - 1;
}//64b Decrease
}//63a Count PostZsites two
else
{//63b Don't change
}//63b Don't change
Arrow = Arrow - 1;
}//62 Count PostZsites two
}//58a Mutate PostZsites
else
{//58b Don't mutate PostZsites
}//58b Don't mutate PostZsites

//End mutate PostZsites.
if (PostZsites >0)//We calculate post zygotic
//infertility.
{Arrow = 150 + PostZsites;//65a Use PostZsites
Dart = 420 + PostZsites;
MisMatch = 0;
mismatch = 0;

                                                                                                            while(Arrow > 150)
{//66 Count PostZsites
mismatch = Offspring[Arrow] - Offspring[Dart] ;
if(mismatch < 0)
{//67a Change to positive
mismatch = mismatch * -1;
}//67a Change to positive
else
{//67b Leave positive
}//67b Leave postive
MisMatch = MisMatch + mismatch;
mismatch = 0;
Arrow = Arrow - 1;
Dart = Dart - 1;
}//66 Count PostZsites
PostZInfertility = 0;
Loss = PostZImpact * MisMatch;
if(Loss > 1000)
{//68a Lose whole offspring
while(Loss > 1000)
{//69 Lose one
PostZInfertility = PostZInfertility +1;
Loss = Loss - 1000;
}//69 Lose one
}//68a Lose whole offspring
else
{//68b No whole offspring lost
}//68b No whole offspring lost
coin = rand();
Coin = coin % 1000;
if(Loss > Coin)
{//70a Lose fractional offspring
PostZInfertility = PostZInfertility + 1;
}//70a Lose fractional offspring
else
{//70b Keep fractional offspring
}//70b Keep fractional offspring
Arrow = 251;
Dart = 252;
while (Arrow < 270)
{//103 Shuffle in post zygotic infertility
Offspring[Arrow] = Offspring[Dart];
Arrow = Arrow + 1;
Dart = Dart + 1;
}//103 Shuffle in post zytotic infertility
Offspring[270] = PostZInfertility;// Top off this chromosome

                                                                                                            Arrow = 521;
Dart = 522;
while (Arrow < 540)
{//103 Shuffle in post zygotic infertility
Offspring[Arrow] = Offspring[Dart];
Arrow = Arrow + 1;
Dart = Dart + 1;
}//103 Shuffle in post zytotic infertilty
Offspring[540] = PostZInfertility;// Top off this other chromosome
//Add up delayed infertiltiy.
AccumulatedInfertility = 0;
delay = Delay;
Arrow = 271 - Delay;
while (Arrow < 271)
{//104//Count 1 chromosome
AccumulatedInfertility = AccumulatedInfertility = Offspring[Arrow];
Arrow = Arrow + 1;
}//104//Count 1 chromosome
Arrow = 541 - Delay;
while (Arrow < 541)
{//105//Count other chromosome
AccumulatedInfertility = AccumulatedInfertility = Offspring[Arrow];
Arrow = Arrow + 1;
}//105//Count other chromosome
Offspring[541] = AccumulatedInfertility;//And put it in its place
}//65a Use PostZsites
else
{//65b Don't use PostZsites
}//65b Don't use PostZsites
//Transfer offspring to next generation.
Arrow = 541;
while(Arrow>=0)
{//71 Transfer offspring
NextGeneration[InNextGeneration][Arrow] = Offspring[Arrow];
Arrow = Arrow - 1;
}//71 Transfer offspring
InNextGeneration = InNextGeneration + 1;
}//45b Continue with offspring

}//36 Make one offspring
Mate = 0;
PopSize = PopSize - 2;
}//35a If making offspring
else
{//35b Finish making offspring
Mate = 0;
PopSize = PopSize - 2;
}//35b Finish making offspring
}//End make many offspring.//25b Make many offspring

                                                }//End running the population. //24 Run pop 
cout << InNextGeneration << " ";//We report total offspring this
//generation to screen and array.

                                                PopHistory[Gens] = InNextGeneration;//72 Write to array

                                    if(Gens==MaxGens)
{//73a Record last PopSize and Gens run
NotLastRun = 0;//We stop recording offspring to the array.
EndPopulations[Sims] = InNextGeneration;//We record last offsping and
//last generation number for this simulation.
FinalGenerations[Sims] = Gens;
}//73a Record last PopSize and Gens run
else
{//73b Not yet
}//73b Not yet

                                    //We transfer the new population.
if(InNextGeneration <2)//We see if the population has crashed.
{//74a If pop crashed prepare to shut down.
FinalGenerations[Sims] = Gens;
Gens = MaxGens;
}//74a If pop crashed prepare to shut down.
else
{//We prepare for a new cycle.//74b Prepare new cycle.
if(InNextGeneration <= MaxPopSize)//We transfer all of the population.
{//75a Transfer whole pop
Dart = InNextGeneration - 1;
PopSize = 0;
while(Dart >= 0)
{//76 Count down pop
Arrow = 541;
while(Arrow >= 0)
{//77 Transfer
Population[PopSize][Arrow] = NextGeneration [Dart][Arrow];
Arrow = Arrow - 1;
}//77 Transfer
PopSize = PopSize + 1;
Dart = Dart - 1;
}//76 Count down pop
}//75a Transfer whole pop
else//We transfer some of the population.
{//75b Transfer some pop
PopSize = 0;
TopofHeap = InNextGeneration - 1;
while(PopSize < MaxPopSize)
{//78 Count down pop
Arrow = 541;
FickleFinger = rand() * rand();
Dart = FickleFinger % InNextGeneration;
while (Arrow >= 0)
{//79 Transfer
Population[PopSize][Arrow] = NextGeneration[Dart][Arrow];
NextGeneration[Dart][Arrow] = NextGeneration[TopofHeap][Arrow];
Arrow = Arrow - 1;
}//79 Transfer
PopSize = PopSize +1;
TopofHeap = TopofHeap -1;
}//78 Count down pop
}//75b Transfer some pop
}//74b Prepare new cycle.                                                                   
Gens = Gens +1;
}//End Generations. //23 Gens
cout << " Simulation " << Sims << " done. \n";
Sims = Sims + 1;

                        }//End Sims. //16 Sims             
cout << "\n The final populations in the simulations were: ";
Arrow = 1;
while(Arrow <= MaxSims)
{//80 Print final pop to screen
cout << EndPopulations[Arrow] << " ";
Arrow = Arrow + 1;
}//80 Print final pop to screen
cout << "\n\n The number of generations run in the simulations were: ";
Arrow = 1;
while(Arrow <= MaxSims)
{//81 Print gens each Sim to screen
cout << FinalGenerations[Arrow] << " ";
Arrow = Arrow + 1;
}//81 Print gens each Sim to screen

            ofstream Summary("C:\\Summary",ios :: out);
Summary << "                                      Summary \n\n The run number was " << RunNumber
<< ".  The number of Simulations was " << MaxSims
<< ".  The parameters were: Maximum generations "
<< MaxGens << " . Maximum offspring " << MaxProgeny << ".  Initial population "
<< InitPopSize << ". Maximum Population " << MaxPopSize
<< ".  Number of gene pairs subject to recessive lethal mutations "
<< Genes << ".  Mutation rate of the genes " << GeneMutRate
<< ".  Number of sites affecting pre zygotic fertility was " << PreZsites
<< ".  Change rate at each site was " << PreZMutRate
<< " per site per 100,000 generations.  Number of thousandths of an offspring "
<< "lost per unit of mismatch was " << PreZImpact
<< ".  Number of sites affecting post zygotic fertility was "  << PostZsites
<< ".  Change rate for the sites affect post zygotic fertility was "
<< PostZMutRate << " per site per 100,000 generations.  "
<< "The number of thousandths of offspring lost per unit of mismatch was "
<< PostZImpact << ".  Infertility accumulated for " << Delay
<< " generations.  A file was added. (1 for yes, 0 for no.) "  << AddFile
<< ".\n\n  The offspring in the final population(s) of the(each) "
<< "simulation was(were): ";
Arrow = 1;
while(Arrow <= MaxSims)
{//82 Send final pops to summary
slot = EndPopulations[Arrow];
Summary << slot << " ";
Arrow = Arrow + 1;
}//82 Send final pops to summary
Summary << ".\n\n The generation(s) run by the(each) simulation was(were): ";
Arrow = 1;
while(Arrow <= MaxSims)
{//83 Send final Gens per Sim to summary
slot = FinalGenerations[Arrow];
Summary << slot  << " ";
Arrow = Arrow + 1;
}//83 Send final Gens per Sim to summary
Summary << "\n\n The numbers of offspring in each generation of the last simulation"
<<" were: ";
Arrow = 1;
while(Arrow <= MaxGens)
{//Send offpring each Gen in last Sim
slot = PopHistory[Arrow];
Summary << slot << " ";
Arrow = Arrow + 1;
}//Send offpring each Gen in last Sim
Summary.close();
cout << "\n\n The program will save a summary of the run as Summary.  It is also "
<< "able to save your remaining population as RemainingPop.  Files are saved "
<< "on drive C. \n Do you wish to save a population?  1 for yes, 0 for no.\n";
cin >> Coin;
if(Coin == 0)
{//85a No pop saved
}//85a No pop saved
else
{//85b Save a population
cout << " How many do you want to save?  Don't go over " << PopSize << ".\n";
cin >> Incoming;
ofstream OutFile("C:\\RemainingPop",ios :: out);
Dart = Incoming - 1;
Arrow = 0;
while(Dart >= 0)
{//86 Count down members
while(Arrow <= 541)
{//87 Count one member
slot = NextGeneration[Dart][Arrow];
OutFile << slot << " ";
Arrow = Arrow + 1;
}//87 Count one member
Dart = Dart - 1;
Arrow = 0;
}//86 Count down members
OutFile.close();
cout << "\n\n The key to reading Remaining Pop is:the first number is generally "
<< "a very large one and is the ID number for that individual.  Then 2 "
<< "through 51 are genes on the first chromosome; 52 through 151 pre "
<< "zygotic sites on that chromosome.  152 through 251 post zygotic sites; "
<< "252 through 271are the accumulating generations of infertilty on that "
<< "chromosome and then 272 - 321 genes, 322 - 421 pre, 422 -  521 post, 522 - 541 "
<< "accumulating infertilty on the other.  542 is post zygotic infertilty. /n/n";
}//85b Save a population
cout << "\n Enter any number to finish. \n";
cin >> End;

return 0;
}//1 Main

BLANK WORK SHEET I suggest hard copy; while eating my C++ program and old files the computer saw fit to wipe off all the entries from the work sheets. You can see that Dreamweaver has scrambled it, but you can see the components.

    Chart 1, page 1 Zygote program

                                 

Column number                1     2     3      4      5      6     7       8       9       10     11     12     13     14     15    

                                     ID number
Simulations run
 
Maximum generations                                                                                                                                     
 

Max offspring
                                          
Initial population
 

Max population                     
                                  
Genes per chromo 
 

Gene mutations
                                                                 
Prezygotic sites
 

Prezygotic mutations
                                                 
Prezygotic impact
 

Postzygotic sites
 

Postzygotic mutations
 

Postzygotic impact
 

Delay
                                               

                                     
Add a file?
 

Which file?
 

How many?
          
Other file?       
                                     
                                     

How many?

                                  

Final pop
                                     
                                     

Gens lasted

                                      Remarks


 

 

 

SUMMARY OF ONE RUN
Summary

 The run number was 25.  The number of Simulations was 10.  The parameters were: Maximum generations 1000 . Maximum offspring 25.  Initial population 200. Maximum Population 200.  Number of gene pairs subject to recessive lethal mutations 0.  Mutation rate of the genes 0.  Number of sites affecting pre zygotic fertility was 100.  Change rate at each site was 500 per site per 100,000 generations.  Number of thousandths of an offspring lost per unit of mismatch was 500.  Number of sites affecting post zygotic fertility was 100.  Change rate for the sites affect post zygotic fertility was 500 per site per 100,000 generations.  The number of thousandths of offspring lost per unit of mismatch was 500.  Infertility accumulated for 1 generations.  A file was added. (1 for yes, 0 for no.) 0.

  The offspring in the final population(s) of the(each) simulation was(were): 826 627 894 673 613 41 905 980 1022 985 .

 The generation(s) run by the(each) simulation was(were): 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000

 The numbers of offspring in each generation of the last simulation were: 2475 2308 2208 2104 1963 1871 1776 1696 1560 1547 1452 1352 1324 1216 1224 1088 1042 989 873 811 722 703 715 649 608 586 635 576 696 707 675 819 894 927 925 903 941 968 1051 933 1016 952 908 804 830 802 741 674 722 656 618 856 887 875 934 947 1065 1101 974 932 767 806 789 778 795 722 695 848 851 815 858 874 889 892 780 912 868 920 896 867 797 738 563 621 700 713 812 905 825 988 1047 1055 1022 988 992 889 918 820 767 755 795 655 727 747 628 689 726 763 757 525 662 623 452 451 477 717 712 866 854 914 894 711 640 531 499 539 661 579 678 805 644 676 696 671 796 899 1164 995 1136 1100 1006 854 726 768 705 873 746 683 653 472 458 501 505 412 318 377 309 105 91 162 408 607 639 643 531 581 727 788 856 832 668 732 904 909 1012 1061 1137 1126 1085 1003 914 803 651 622 709 511 616 492 650 530 767 661 669 622 784 812 760 807 619 737 769 798 819 881 843 627 640 568 608 589 557 707 906 948 1011 1284 1428 1434 1374 1283 1274 1240 1173 1167 1194 1204 1113 1031 946 935 729 672 567 574 561 657 647 702 797 815 754 692 559 598 567 479 469 646 635 742 671 520 642 750 730 835 946 972 1111 1101 1226 1239 1188 1076 1069 1154 1106 1047 1038 958 770 707 719 595 662 582 557 556 484 524 457 540 574 664 783 745 916 954 1041 1010 914 949 1095 1132 1070 1050 961 1007 982 891 818 838 733 861 763 840 884 959 1022 1085 1011 925 916 936 997 1004 971 901 819 850 874 865 873 843 819 470 583 548 514 514 300 467 684 873 860 1036 845 849 944 887 917 951 941 928 869 839 796 830 741 683 626 588 483 561 557 711 727 722 690 746 723 751 695 847 752 727 1023 1050 1163 1155 1146 1121 1109 1066 918 819 794 736 718 662 669 687 618 537 535 485 550 537 465 572 918 863 1011 1277 1276 1185 1219 1193 1166 1117 1068 1006 963 971 1020 1012 987 988 1003 1080 1205 1160 1103 1093 1072 963 918 783 789 771 781 754 736 691 730 741 710 768 875 715 616 707 885 942 796 795 819 789 740 780 741 796 840 842 934 971 891 742 811 744 729 781 691 656 735 704 858 798 806 777 706 607 636 605 586 708 675 630 518 537 525 457 608 524 706 638 804 896 980 849 888 865 885 929 883 872 814 681 852 869 857 909 899 1064 1032 1003 977 940 982 932 896 825 962 1021 1121 1105 1055 955 866 987 882 877 729 613 551 536 501 646 418 485 341 286 454 566 543 727 665 590 705 501 504 655 597 720 704 586 445 604 755 961 1091 1202 1196 1252 1160 1417 1456 1415 1461 1337 1218 1160 1116 1036 948 908 909 774 817 667 720 590 569 528 600 754 823 785 803 853 947 926 863 766 771 743 674 653 690 586 689 746 739 740 648 611 627 748 740 971 973 1007 1143 950 890 840 815 844 805 861 969 889 945 773 884 885 848 712 843 876 834 874 875 799 938 884 824 785 730 876 790 668 778 780 692 753 677 707 598 600 498 591 419 527 518 403 446 766 763 690 727 694 635 684 716 723 742 810 974 906 717 766 769 884 838 748 762 581 604 691 888 856 831 928 1027 1098 1061 1045 994 934 1027 918 917 845 733 723 671 703 539 449 419 393 327 583 497 626 657 848 716 798 911 963 1304 1385 1342 1295 1281 1245 1280 1105 1063 993 915 880 945 827 796 771 729 544 481 420 428 375 324 412 498 676 506 438 500 709 690 562 834 739 738 647 514 778 865 706 753 813 728 619 733 806 755 876 607 554 480 584 599 655 819 1005 1127 1091 1109 1011 956 909 879 803 893 904 842 701 852 768 702 633 699 728 698 676 714 797 961 1175 1285 1229 1212 1118 1066 1038 925 859 762 817 939 941 885 903 1047 960 1040 924 1004 994 913 809 780 749 718 723 757 784 792 835 758 864 803 688 501 605 482 541 412 402 526 307 475 564 656 935 1218 1128 1123 1184 1273 1240 1084 955 989 1027 851 858 837 770 668 747 775 878 801 925 933 1021 914 947 926 1004 1050 1023 929 933 851 911 808 732 701 703 702 798 749 730 674 782 683 747 593 791 905 939 841 771 737 697 553 623 565 586 767 784 617 582 526 432 522 617 801 773 949 1228 1267 1282 1205 1143 1063 942 913 1031 1030 927 819 743 841 943 964 932 962 964 871 902 1013 925 980 802 720 528 611 579 903 847 843 844 872 811 653 619 715 644 537 419 502 544 490 478 276 249 200 416 621 771 998 1092 1012 1014 1052 1106 1067 953 831 882 940 872 858 845 772 630 658 642 680 686 635 815 778 632 623 668 770 726 581 544 507 503 661 607 646 479 648 887 790 888 824 914 881 681 639 750 749 779 776 924 861 726 826 863 808 813 869 856 754 849 880 853 885 985

There is more in part 2

Home page.