Beispiel #1
0
        /// <summary>
        /// Reset the problem instance.
        /// </summary>
        private void resetData()
        {
            Cities = new City[_size];
            Route  = new List <int>(_size);
            bssf   = null;

            if (_mode == HardMode.Modes.Easy)
            {
                for (int i = 0; i < _size; i++)
                {
                    Cities[i] = new City(rnd.NextDouble(), rnd.NextDouble());
                }
            }
            else // Medium and hard
            {
                for (int i = 0; i < _size; i++)
                {
                    Cities[i] = new City(rnd.NextDouble(), rnd.NextDouble(), rnd.NextDouble() * City.MAX_ELEVATION);
                }
            }

            HardMode mm = new HardMode(this._mode, this.rnd, Cities);

            if (_mode == HardMode.Modes.Hard)
            {
                int edgesToRemove = (int)(_size * FRACTION_OF_PATHS_TO_REMOVE);
                mm.removePaths(edgesToRemove);
            }
            City.setModeManager(mm);

            cityBrushStyle          = new SolidBrush(Color.Black);
            cityBrushStartStyle     = new SolidBrush(Color.Red);
            routePenStyle           = new Pen(Color.Blue, 1);
            routePenStyle.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
        }
        // Reset the problem instance
        private void resetData()
        {
            cities = new City[size];
            bssf   = null;

            if (mode == HardMode.Modes.Easy)
            {
                for (int i = 0; i < size; i++)
                {
                    cities[i] = new City(rnd.NextDouble(), rnd.NextDouble());
                }
            }
            else // Medium and hard
            {
                for (int i = 0; i < size; i++)
                {
                    cities[i] = new City(rnd.NextDouble(), rnd.NextDouble(), rnd.NextDouble() * City.MAX_ELEVATION);
                }
            }

            HardMode mm = new HardMode(this.mode, this.rnd, cities);

            if (mode == HardMode.Modes.Hard)
            {
                int edgesToRemove = (int)(size * FRACTION_OF_PATHS_TO_REMOVE);
                mm.removePaths(edgesToRemove);
            }
            City.setModeManager(mm);
        }
Beispiel #3
0
        /// <summary>
        ///     Reset the problem instance.
        /// </summary>
        private void ResetData()
        {
            _cities = new City[Size];
            _route  = new List <City>(Size);
            _bssf   = null;

            if (_mode == HardMode.Modes.Easy)
            {
                for (var i = 0; i < Size; i++)
                {
                    _cities[i] = new City(_rnd.NextDouble(), _rnd.NextDouble());
                }
            }
            else // Medium and hard
            {
                for (var i = 0; i < Size; i++)
                {
                    _cities[i] = new City(_rnd.NextDouble(), _rnd.NextDouble(), _rnd.NextDouble() * City.MaxElevation);
                }
            }

            var mm = new HardMode(_mode, _rnd, _cities);

            if (_mode == HardMode.Modes.Hard)
            {
                var edgesToRemove = (int)(Size * FractionOfPathsToRemove);
                mm.RemovePaths(edgesToRemove);
            }
            City.SetModeManager(mm);

            _cityBrushStyle          = new SolidBrush(Color.Black);
            _cityBrushStartStyle     = new SolidBrush(Color.Red);
            _routePenStyle           = new Pen(Color.Blue, 1);
            _routePenStyle.DashStyle = DashStyle.Solid;
        }
Beispiel #4
0
 private HardMode.Modes getMode()
 {
     return(HardMode.getMode(cboMode.Text));
 }
Beispiel #5
0
 /// <summary>
 /// make a new problem with the given size, now including timelimit paremeter that was added to form.
 /// </summary>
 /// <param name="size">number of cities</param>
 public void GenerateProblem(int size, HardMode.Modes mode, int timelimit)
 {
     this._size = size;
     this._mode = mode;
     this.time_limit = timelimit*1000;                                   //convert seconds to milliseconds
     resetData();
 }
Beispiel #6
0
 /// <summary>
 /// make a new problem with the given size.
 /// </summary>
 /// <param name="size">number of cities</param>
 public void GenerateProblem(int size, HardMode.Modes mode)
 {
     this._size = size;
     this._mode = mode;
     resetData();
 }
Beispiel #7
0
        /// <summary>
        /// Reset the problem instance.
        /// </summary>
        private void resetData()
        {

            Cities = new City[_size];
            Route = new ArrayList(_size);
            bssf = null;

            if (_mode == HardMode.Modes.Easy)
            {
                for (int i = 0; i < _size; i++)
                    Cities[i] = new City(rnd.NextDouble(), rnd.NextDouble());
            }
            else // Medium and hard
            {
                for (int i = 0; i < _size; i++)
                    Cities[i] = new City(rnd.NextDouble(), rnd.NextDouble(), rnd.NextDouble() * City.MAX_ELEVATION);
            }

            HardMode mm = new HardMode(this._mode, this.rnd, Cities);
            if (_mode == HardMode.Modes.Hard)
            {
                int edgesToRemove = (int)(_size * FRACTION_OF_PATHS_TO_REMOVE);
                mm.removePaths(edgesToRemove);
            }
            City.setModeManager(mm);

            cityBrushStyle = new SolidBrush(Color.Black);
            cityBrushStartStyle = new SolidBrush(Color.Red);
            routePenStyle = new Pen(Color.Blue,1);
            routePenStyle.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
        }
Beispiel #8
0
 public static void setModeManager(HardMode modeManager)
 {
     City.modeManager = modeManager;
 }
Beispiel #9
0
 public static void setModeManager(HardMode modeManager)
 {
     City.modeManager = modeManager;
 }