Example #1
0
        static void Main(string[] args)
        {
            //dane do pobrania z GUI
            int    a          = 10;    //początek przedziału do losowania wartości komórek
            int    b          = 100;   //koniec przedziału do losowania wartości komórek
            int    ammount    = 10;    //ile chcemy pasujących antygenów na wyjściu
            double tollerance = 0.30;  // tolerancja odchylenia od wzorca zakres od 0 do 1 najlepiej z listy rozwijanej



            //przemielenie algorytmu
            NegativeSelectionAlgorithmClass algorithm = new NegativeSelectionAlgorithmClass(a, b, ammount, tollerance);

            //dane do wyprowadzenia na GUI


            System.Console.WriteLine("Wylosowana komórka macierzysta i jej wartość funkcji przystosowania");
            System.Console.WriteLine(algorithm.stemCell.getCellValue() + " i " + algorithm.stemCell.getCellValueOfFunction());

            System.Console.WriteLine("Populacja wyjściowa przeciwciał");
            for (int i = 0; i < algorithm.antibodies.Count; i++)
            {
                System.Console.WriteLine(algorithm.antibodies[i].getCellValue() + " i " + algorithm.antibodies[i].getCellValueOfFunction());
            }

            System.Console.WriteLine("Liczba epok potrzebna do osiągnięcia wyniku: " + algorithm.getAmmountOfEpochs());



            System.Console.WriteLine("Taka sytuacja");
            System.Console.ReadKey();

            // Klonalny

            var algorithm2 = ClonalSelectionAlgorithm.Instance;

            algorithm2.Function = x => x * x + 2 * x + 10;
            algorithm2.Options  = new AlgorithmOptions
            {
                MaxGens          = 30,
                Section          = new double[] { 10, 100 },
                SectionX_0       = 10,
                SectionX_1       = 100,
                nBestGensToTake  = 10,
                nWorstGenToThrow = 4,
                MaxCloneCountForMaxProbability = 20,
                MinProbability = 95,
                MaxGoodGens    = 20,
                StopCondition  = StopContition.PROB,
                MaxEpochsNumer = 10
            };

            algorithm2.StartAlgorithm();
        }
Example #2
0
        private void negativeSelection_Click(object sender, RoutedEventArgs e)
        {
            int    min = Convert.ToInt32(startTbx.Text);
            int    max = Convert.ToInt32(koniecTbx.Text);
            int    amountOfAntibodies   = Convert.ToInt32(antygenyTbx.Text);
            var    selectedComboBoxItem = odchylenieCbx.SelectedItem as ListBoxItem;
            var    comboBoxValue        = selectedComboBoxItem.Content.ToString().Replace(".", ",");
            double tollerance           = Convert.ToDouble(comboBoxValue);

            NegativeSelectionAlgorithmClass negativeSelectionAlgorithmClass = new NegativeSelectionAlgorithmClass(min, max, amountOfAntibodies, tollerance);

            recordToFileNegativeSelectionAlgorithm(negativeSelectionAlgorithmClass);
        }
Example #3
0
        public void recordToFileNegativeSelectionAlgorithm(NegativeSelectionAlgorithmClass negativeSelectionAlgorithmClass)
        {
            System.IO.File.Delete(@"D:\Wyniki programu.csv");
            using (StreamWriter sw = new StreamWriter(@"D:\Wyniki programu.csv", true))
            {
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.AppendFormat("Wylosowana komorka macierzysta: {0} i jej wartosc funkcji przystosowania: {1}{2}", negativeSelectionAlgorithmClass.stemCell.getCellValue().ToString(), negativeSelectionAlgorithmClass.stemCell.getCellValueOfFunction().ToString(), Environment.NewLine);

                stringBuilder.AppendFormat("Populacja wyjsciowa przeciwcial:\n");
                for (int i = 0; i < negativeSelectionAlgorithmClass.antibodies.Count; i++)
                {
                    stringBuilder.AppendFormat("{0} i {1} \n", negativeSelectionAlgorithmClass.antibodies[i].getCellValue().ToString(), negativeSelectionAlgorithmClass.antibodies[i].getCellValueOfFunction().ToString());
                }

                stringBuilder.AppendFormat("{0}Liczba epok potrzebna do osiagniecia wyniku: {1}", Environment.NewLine, negativeSelectionAlgorithmClass.getAmmountOfEpochs().ToString());
                sw.WriteLine(stringBuilder.ToString());

                wynikiTbx.Text = (stringBuilder.ToString());
            }
        }