using System; namespace Science.Biology.PopulationGenetics { /// /// SocialGene can be distinguished from ordinary genes. /// public class SocialGene { public SocialGene() { } private int numberOfAllele; private double[,] mutation; private double[,,] reproductionXX; private double[,,] reproductionXY; private void SetInitial() { mutation = new Double[numberOfAllele,numberOfAllele]; reproductionXX = new Double[numberOfAllele,numberOfAllele,numberOfAllele]; reproductionXY = new Double[numberOfAllele,numberOfAllele,numberOfAllele]; for(int j = 0; j < NumberOfAllele; j++) mutation[j,j] = 1.0; for (int j = 0; j < NumberOfAllele; j++) for (int jj = 0; jj < NumberOfAllele; jj++) for (int jjj = 0; jjj < NumberOfAllele; jjj++) { reproductionXX[j, jj, jjj] = 1.0; reproductionXY[j, jj, jjj] = 1.0; } } public int NumberOfAllele { get{return numberOfAllele;} set { numberOfAllele = value; SetInitial(); } } public double[,] Mutation { get{return mutation;} } public double[,,] ReproductionXX { get{return reproductionXX;} } public double[,,] ReproductionXY { get{return reproductionXY;} } private double modifiedvalue; public double ModifiedValue { set{modifiedvalue=value;} } private int from, to; public int From { set{from = value;} } public int To { set{to = value;} } public void SetMutation() // after set { mutation[from,to] = modifiedvalue; double sum = 0.0; for(int j = 0; j < NumberOfAllele; j++) if(j!=from) sum += mutation[from,j]; mutation[from,from] = 1.0 - sum; } private int whichFemale, whichMale, whichFemaleBaby, whichMaleBaby; public int WhichFemale { set{whichFemale = value;} } public int WhichMale { set{whichMale = value;} } public int WhichFemaleBaby { set{whichFemaleBaby = value;} } public int WhichMaleBaby { set{whichMaleBaby = value;} } public void SetReproductionXX() // after set { reproductionXX[whichFemale,whichMale,whichFemaleBaby] = modifiedvalue; } public void SetReproductionXY() // after set { reproductionXY[whichFemale,whichMale,whichMaleBaby] = modifiedvalue; } } }