public override MEL_ArmRepertoire__Individual Generate_Offspring( Random randomness_provider, MEL_ArmRepertoire__Individual parent ) { List <double> genome_copy = parent.genotype.DeepCopy(); double value_range = max_gene_value - min_gene_value; for (int i = 0; i < genome_copy.Count; i++) { double mutation_value = Math_Utilities.Map_Value( randomness_provider.NextDouble(), 0.0, 1.0, -mutation_step, mutation_step ); genome_copy[i] += mutation_value; if (genome_copy[i] > max_gene_value) { genome_copy[i] -= value_range; } else if (genome_copy[i] < min_gene_value) { genome_copy[i] += value_range; } } MEL_ArmRepertoire__Individual offspring = new MEL_ArmRepertoire__Individual(genome_copy); return(offspring); }
public static Bitmap To_HeatMap( this double[,] values_table, double min_value, double max_value, Color out_of_range__low__color, Color out_of_range__high__color, Color not_a_number__color ) { int w = values_table.GetLength(0); int h = values_table.GetLength(1); Bitmap image = new Bitmap(w, h); for (int x = 0; x < w; x++) { for (int y = 0; y < h; y++) { if (min_value == max_value) { double value = values_table[x, y]; if (Double.IsNaN(value)) { image.SetPixel(x, y, not_a_number__color); } else { Color c = Color.FromArgb(0, 0, 0); image.SetPixel(x, y, c); } } else { double value = values_table[x, y]; if (Double.IsNaN(value)) { image.SetPixel(x, y, not_a_number__color); } else if (value < min_value) { image.SetPixel(x, y, out_of_range__low__color); } else if (value > max_value) { image.SetPixel(x, y, out_of_range__high__color); } else { double cv = Math_Utilities.Map_Value(value, min_value, max_value, 0.0, 255.0); int ci = (int)cv; Color c = Color.FromArgb(ci, ci, ci); image.SetPixel(x, y, c); } } } } return(image); }
public static Bitmap To_HeatMap( this int[,] values_table, int min_value, int max_value, Color out_of_range__low__color, Color out_of_range__high__color ) { Bitmap image = new Bitmap(values_table.GetLength(0), values_table.GetLength(1)); for (int x = 0; x < values_table.GetLength(0); x++) { for (int y = 0; y < values_table.GetLength(1); y++) { double value = values_table[x, y]; if (value < min_value) { image.SetPixel(x, y, out_of_range__low__color); } else if (value > max_value) { image.SetPixel(x, y, out_of_range__high__color); } else { if (min_value == max_value) { Color c = Color.FromArgb(0, 0, 0); image.SetPixel(x, y, c); } else { double cv = Math_Utilities.Map_Value(value, min_value, max_value, 0.0, 255.0); int ci = (int)cv; Color c = Color.FromArgb(ci, ci, ci); image.SetPixel(x, y, c); } } } } return(image); }
public override MEL_Rastrigin__Individual Generate_Individual(Random randomness_provider) { List <double> genotype = new List <double>(); for (int i = 0; i < num_dimensions; i++) { double this_gene_value = Math_Utilities.Map_Value( randomness_provider.NextDouble(), 0.0, 1.0, min_gene_value, max_gene_value ); genotype.Add(this_gene_value); } MEL_Rastrigin__Individual individual = new MEL_Rastrigin__Individual( genotype ); return(individual); }