public Indiv mat(Indiv par2) { string child_chromo1 = ""; string child_chromo2 = ""; string child_chromo3 = ""; int len, l1 = par2.chromo.Length; int l = chromo.Length; if (l1 < l) { len = l1; } else { len = l; } for (int i = 2; i < len; i++) { double p = GlobalMembers.random_weight(0, 1); //cout<<p<<" "; if (p < 0.6) { child_chromo1 += chromo[i]; } else if (p < 0.80) { child_chromo1 += par2.chromo[i]; } else { child_chromo1 += (char)GlobalMembers.mutated_genes(); } } for (int i = 2; i < len; i++) { double p = GlobalMembers.random_weight(0, 1); if (p < 0.6) { child_chromo2 += chromo[i]; } else if (p < 0.80) { child_chromo2 += par2.chromo[i]; } else { child_chromo2 += (char)GlobalMembers.mutated_genes(); } } for (int i = 2; i < len; i++) { double p = GlobalMembers.random_weight(0, 1); if (p < 0.6) { child_chromo3 += chromo[i]; } else if (p < 0.80) { child_chromo3 += par2.chromo[i]; } else { child_chromo3 += (char)GlobalMembers.mutated_genes(); } } child_chromo1 = "0." + child_chromo1; child_chromo2 = "0." + child_chromo2; child_chromo3 = "0." + child_chromo3; //cout<<child_chromosome1<<" "<<child_chromosome2<<" "<<child_chromosome3<<" "; string c1 = child_chromo1; string c2 = child_chromo2; string c3 = child_chromo3; double number, number1, number2; Double.TryParse(c1, out number); Double.TryParse(c2, out number1); Double.TryParse(c3, out number2); Indiv ret = new Indiv(number, number1, number2); return(ret); }