示例#1
0
        public void Find()
        {
            if (string.IsNullOrWhiteSpace(Settings.Term_Pool))
            {
                throw new Exception("Setting TermPool is empty. Check the configuration file, and set the AppSetting value to a comma delimited list of allowed values for the key \"Term.Pool\".");
            }

            int parseOut = 0;
            List<int> termPool = new List<int>();
            foreach (string term in Settings.Term_Pool.Split(','))
            {
                parseOut = 0;
                if (int.TryParse(term, out parseOut))
                {
                    termPool.Add(parseOut);
                }
            }

            equationArgs = new  EquationFinderArgs(Settings.Equations_Goal, Settings.Operations_Quantity, termPool, Settings.Operand_Pool);
            threadArgs = new ThreadSpawnerArgs(previousfoundResults, LogSolution, Settings.Round_TimeToLive, Settings.Round_Threads, Settings.Round_Quantity, equationArgs);

            ThreadedEquationFinder<AlgebraicTuple> equationFinder = new ThreadedEquationFinder<AlgebraicTuple>(threadArgs);
            if (File.Exists(outputFilename))
            {
                equationFinder.Results.AddRange(File.ReadAllLines(outputFilename));
            }
            equationFinder.Run();
        }
示例#2
0
        private void BeginSearch()
        {
            if (TermPool == null || TermPool.Count < 1)
            {
                MessageBox.Show("Term cannot be empty.", "Input missing", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (string.IsNullOrWhiteSpace(OperatorPool))
            {
                MessageBox.Show("You must select at least one operation.", "Input missing", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            equationArgs = new EquationFinderArgs(targetValue, numberOfOperations, TermPool, OperatorPool);

            string[] previousResults = GetOutputLines();
            if (previousResults != null && previousResults.Length > 0)
            {
                threadArgs = new ThreadSpawnerArgs(previousResults.ToList(), null, timeToLive, numberOfThreads, numberOfRounds, equationArgs);
            }
            else
            {
                threadArgs = new ThreadSpawnerArgs(null, timeToLive, numberOfThreads, numberOfRounds, equationArgs);
            }

            if (backgroundWorker_ThreadSpawner.IsBusy == false)
            {
                ToggleControlsVisibility(false);
                timerCollectResults.Start();
                backgroundWorker_ThreadSpawner.RunWorkerAsync(threadArgs);
            }
        }
 public AlgebraicTuple(EquationFinderArgs equationArgs)
 {
     GenerateNewAndEvaluate(equationArgs);
 }