Esempio n. 1
0
        public Dictionary <int, InstructionsHelper> GenerateData(CargoShipCollection ships, ref ContainersCollection containers)
        {
            this._ships      = ships;
            this._containers = containers;
            Dictionary <int, InstructionsHelper> Solution = new Dictionary <int, InstructionsHelper>();

            InitialFill();
            log.Debug("Initial fill");
            for (var i = 0; i < cycles; ++i)
            {
                EvaluateSpecimens();
                Crossover();
            }
            log.Debug("Mutation and crossover done");

            Specimen bestSpec = _specimens[0];

            for (var i = 0; i < _ships.Count; ++i)
            {
                Solution.Add(i, bestSpec._shipCargo[i]);
            }
            log.Debug("Solution created");

            return(Solution);
        }
Esempio n. 2
0
        public Dictionary <int, InstructionsHelper> GenerateData(CargoShipCollection ships, ref ContainersCollection containers)
        {
            Logger.Trace("Starting data generation");

            Random r = new Random();

            Dictionary <int, InstructionsHelper> res = new Dictionary <int, InstructionsHelper>();

            foreach (Ship s in ships)
            {
                var helper = new InstructionsHelper(s);

                for (int i = 0; i < 20; i++)
                {
                    int id = r.Next(containers.Count - 1);
                    int x  = r.Next(s.Width - 1);
                    int y  = r.Next(s.Depth - 1);

                    if (!helper.CanOccupy(containers[id], x, y))
                    {
                        continue;
                    }

                    helper.Occupy(containers[id], x, y);
                    containers.RemoveAt(id);
                }

                res.Add(s.ID, helper);
            }

            Logger.Trace("Finished data generation");
            return(res);
        }
Esempio n. 3
0
        public MainWindow()
        {
#if !MINIMUM_MODE
            InitializeComponent();
            DataContext = this;
#endif

            _cargoShips      = new CargoShipCollection(shipDataGrid);
            SeriesCollection = new SeriesCollection();
            _containers      = new ContainersCollection();

            Tools.ContainerGenerator.Generate();
            _containers.LoadCsv("DataInputGroupPT1440.csv");
            _availableContainers = _containers.GetAvailable(_turn);

            for (int i = 0; i < 5; i++)
            {
                _cargoShips.Add(32, 30);
            }

            _cargoShips.DataGenStrategy = new IterativeStrategy();

#if MINIMUM_MODE
            Hide();
            _ss = new SummaryScreen();
            _ss.Show();
            _cargoShips.DataGenStrategy = new GenAlgorithm();

            // Make sure program closes after SS is closed
            _ss.SyncronizationClosedEvent += delegate { Close(); };
            GenerateLoadingInstructions();
#else
            UpdatePie();
#endif
        }
Esempio n. 4
0
            public List <InstructionsHelper> _shipCargo;         /* TODO, optional: <- create a manipulator method and make private again */

            ///<summary>
            /// Initializes specimen with its cargo holds/ships representation
            ///</summary>
            public Specimen(CargoShipCollection ships)
            {
                _fitness   = 0;
                _shipCargo = new List <InstructionsHelper>();
                _rng       = new Random();

                foreach (var ship in ships)
                {
                    _shipCargo.Add(new InstructionsHelper(ship));
                }
            }
Esempio n. 5
0
        public Dictionary <int, InstructionsHelper> GenerateData(CargoShipCollection ships, ref ContainersCollection containers)
        {
            Logger.Trace("Starting data generation");

            List <Container> sorted = containers.OrderBy(s => s.TurnCreated).ThenByDescending(s => s.Size).ToList();

            containers.RecreateFromList(sorted);

            Dictionary <int, InstructionsHelper> res = new Dictionary <int, InstructionsHelper>();

            foreach (Ship s in ships)
            {
                InstructionsHelper helper = FillShip(containers, s);

                res.Add(s.ID, helper);
            }

            Logger.Trace("Finished data generation");
            return(res);
        }