Ejemplo n.º 1
0
Archivo: Form1.cs Proyecto: dnorth/TSP
 private void GenerateProblem()
 {
     if (!Regex.IsMatch(this.tbProblemSize.Text.Trim(), "^[0-9]+$"))
     {
         MessageBox.Show("Problem size must be a positive integer.");
     }
     else if (!Regex.IsMatch(this.txtSeed.Text.Trim(), "^[0-9]*$"))
     {
         MessageBox.Show("Problem seed must be a nonnegative integer (or blank).");
     }
     else
     {
         int problemSize = int.Parse(this.tbProblemSize.Text);
         int seed;
         if (this.txtSeed.Text.Trim() == "")
         {
             CityData        = new ProblemAndSolver(ProblemAndSolver.DEFAULT_SEED, problemSize);
             lblProblem.Text = "--";
         }
         else if ((seed = int.Parse(this.txtSeed.Text)) != CityData.Seed || problemSize != CityData.Size)
         {
             CityData        = new ProblemAndSolver(seed, problemSize);
             problemCounter  = 1;
             lblProblem.Text = problemCounter.ToString();
         }
         else
         {
             CityData.GenerateProblem(problemSize);
             problemCounter++;
             lblProblem.Text = problemCounter.ToString();
         }
         this.Invalidate();
     }
 }
Ejemplo n.º 2
0
        // not necessarily a new problem but resets the state using the specified settings
        private void reset()
        {
            this.SetSeed(); // also resets the CityData variable

            int size = getProblemSize();

            HardMode.Modes mode = getMode();

            CityData.GenerateProblem(size, mode);
        }
Ejemplo n.º 3
0
        // not necessarily a new problem but resets the state using the specified settings
        private void reset()
        {
            SetSeed(); // also resets the CityData variable

            var size      = getProblemSize();
            var timelimit = getTimeLimit();
            var mode      = getMode();

            tbCostOfTour.Text   = " --";
            tbElapsedTime.Text  = " --";
            tbNumSolutions.Text = " --";              // re-blanking the text boxes that may have been modified by a solver

            _cityData.GenerateProblem(size, mode, timelimit);
        }