예제 #1
0
 public GASolverInfo(ChromosomesType chromosomesType, SelectionType selectionType, CrossOverType crossOverType, MutationType mutationType, float mutationRate, int initialPopulationSize, int geneLength, Func <List <int>, double> calcFunc)
 {
     ChromosomesType       = chromosomesType;
     SelectionType         = selectionType;
     CrossOverType         = crossOverType;
     MutationType          = mutationType;
     MutationRate          = mutationRate;
     InitialPopulationSize = initialPopulationSize;
     GeneLength            = geneLength;
     CalcFunc = calcFunc;
 }
예제 #2
0
 /// <summary>
 /// 設定情報を表示します
 /// </summary>
 private void DisplaySettingInfo(ChromosomesType cht, SelectionType st, CrossOverType crt, MutationType mt, float mr, int size, int ittr)
 {
     SettingListBox.Items.Clear();
     SettingListBox.Items.Add($"染色体タイプ: {cht}");
     SettingListBox.Items.Add($"選択タイプ: {st}");
     SettingListBox.Items.Add($"交叉タイプ: {crt}");
     SettingListBox.Items.Add($"突然変異タイプ: {mt}");
     SettingListBox.Items.Add($"突然変異率: {mr} [%]");
     SettingListBox.Items.Add($"個体数: {size}");
     SettingListBox.Items.Add($"最大世代数: {ittr}");
 }
예제 #3
0
        /// <summary>
        /// 遺伝子を生成します
        /// </summary>
        /// <param name="chromosomesType"></param>
        /// <returns></returns>
        public static IntegerGene GenerateGene(ChromosomesType chromosomesType, Func <List <int>, double> calcFunc, int geneLength)
        {
            var gene = new IntegerGene
            {
                GenerationNum = 0,
                CalcFunc      = calcFunc,
                Fittness      = 0,
            };

            switch (chromosomesType)
            {
            case ChromosomesType.Binary:
                gene.Chromosomes = GenerateBinaryChromosomes(geneLength);
                break;

            case ChromosomesType.Permutaion:
                gene.Chromosomes = GeneratePermutationChromosomes(geneLength);
                break;
            }

            return(gene);
        }