Esempio n. 1
0
        protected virtual void OnPartialSolutionFound(SolutionFoundEventArgs e)
        {
            EventHandler <SolutionFoundEventArgs> handler = PartialSolutionFound;

            if (handler != null)
            {
                handler(this, e);
            }
        }
Esempio n. 2
0
        private static void G_SolutionFound(object sender, SolutionFoundEventArgs e)
        {
            var chromosome = e.Solution;
            var v1         = (int)chromosome.Data[0];
            var v2         = (int)chromosome.Data[1];
            var v3         = (int)chromosome.Data[2];
            var v4         = (int)chromosome.Data[3];

            Console.WriteLine($"{v1} {v2} {v3} {v4} | {v1 + v2 + v3 + v4}");
        }
Esempio n. 3
0
        private void Gs_SolutionFound(object sender, SolutionFoundEventArgs e)
        {
            Chromosome c = e.Solution;

            var s = new StringBuilder();

            foreach (var d in c.Data)
            {
                s.Append(d.ToString());
            }

            Decode(c);

            MessageBox.Show($"Iteration Count : { e.IterationCount } | {s.ToString()}");
        }
Esempio n. 4
0
        private void Gs_SolutionFound(object sender, SolutionFoundEventArgs e)
        {
            var solution = e.Solution;

            queen_positions = new List <Point>();

            foreach (var pt in solution.Data)
            {
                queen_positions.Add((Point)pt);
            }

            Chessboard.Refresh();

            MessageBox.Show("Solution found");
        }
Esempio n. 5
0
        private void Gs_SolutionFound(object sender, SolutionFoundEventArgs e)
        {
            resultlist.Items.Add("= Solution Found ==============");

            int val1  = (int)e.Solution.Data[0];
            int val2  = (int)e.Solution.Data[1];
            int val3  = (int)e.Solution.Data[2];
            int val4  = (int)e.Solution.Data[3];
            int val5  = (int)e.Solution.Data[4];
            int val6  = (int)e.Solution.Data[5];
            int val7  = (int)e.Solution.Data[6];
            int val8  = (int)e.Solution.Data[7];
            int val9  = (int)e.Solution.Data[8];
            int val10 = (int)e.Solution.Data[9];

            resultlist.Items.Add($"{val1} + {val2} + {val3} + {val4} + {val5} = {val1 + val2 + val3 + val4 + val5}");
            resultlist.Items.Add($"{val6} * {val7} * {val8} * {val9} * {val10} = {val6 * val7 * val8 * val9 * val10}");
        }
Esempio n. 6
0
        private bool Search(List <int> solution)
        {
            if (_control.Right == _control)
            {
                var args = new SolutionFoundEventArgs(solution);

                SolutionFound(this, args);

                return(args.Terminate);
            }

            DancingLinksHeader header = GetNextColumn();

            Cover(header);
            for (DancingLinksNode node = header.Down; node != header; node = node.Down)
            {
                solution.Add(node.RowID);
                for (DancingLinksNode tmp = node.Right; tmp != node; tmp = tmp.Right)
                {
                    Cover(tmp);
                }

                if (Search(solution))
                {
                    return(true);
                }

                solution.RemoveAt(solution.Count - 1);
                for (DancingLinksNode tmp = node.Right; tmp != node; tmp = tmp.Right)
                {
                    Uncover(tmp);
                }
            }
            Uncover(header);

            return(false);
        }
Esempio n. 7
0
 protected virtual void OnSolutionFound(object sender, SolutionFoundEventArgs e) => SolutionFound?.Invoke(this, e);
Esempio n. 8
0
 private static void G_SolutionFound(object sender, SolutionFoundEventArgs e)
 {
     Console.WriteLine("Solution found");
     Decode(e.Solution);
 }
Esempio n. 9
0
 private static void DlxSolutionFound(object sender, SolutionFoundEventArgs e)
 {
     cancellationTokenSource.Cancel();
 }