Пример #1
0
        /// <summary>
        /// Vygeneruji náhodné objednávky
        /// </summary>
        public void generateRandomOrders()
        {
            List <string> remainingCities = InputOutput.getUniqueColumnsValuesActiveOrders(1);

            var    rnd       = new Random();
            int    a         = rnd.Next(0, remainingCities.Count);
            string city      = remainingCities[a];
            int    cityCount = remainingCities.Count - 1;

            string newOrder   = remainingCities[a];
            string newOrderId = Cities.getId(remainingCities[a]);

            remainingCities.RemoveAt(a);
            int newOrderValue = Convert.ToInt32(Controller.activeOrdersTable.Rows[a]["Count"].ToString());

            for (int i = 0; i < cityCount; i++)
            {
                a = rnd.Next(0, remainingCities.Count);
                if (newOrderValue + Convert.ToInt32(Controller.activeOrdersTable.Rows[a]["Count"].ToString()) < ORDER_CAPACITY)
                {
                    newOrder   = newOrder + "-" + remainingCities[a];
                    newOrderId = newOrderId + "-" + Cities.getId(remainingCities[a]);
                    remainingCities.RemoveAt(a);
                    newOrderValue = newOrderValue + Convert.ToInt32(Controller.activeOrdersTable.Rows[a]["Count"].ToString());
                }
                else
                {
                    newOrder   = newOrder + ":" + newOrderValue;
                    newOrderId = newOrderId + ":" + newOrderValue;
                    this.ordersList.Add(newOrder);
                    this.ordersListIds.Add(newOrderId);
                    newOrder   = remainingCities[a];
                    newOrderId = Cities.getId(remainingCities[a]);
                    remainingCities.RemoveAt(a);
                    newOrderValue = Convert.ToInt32(Controller.activeOrdersTable.Rows[a]["Count"].ToString());
                }
            }

            if (newOrder.Length > 0)
            {
                newOrder   = newOrder + ":" + newOrderValue;
                newOrderId = newOrderId + ":" + newOrderValue;
                this.ordersList.Add(newOrder);
                this.ordersListIds.Add(newOrderId);
            }
        }
Пример #2
0
        /// <summary>
        /// Vytvorim cestu nahodne s ohledem na maximalni kapacitu
        /// </summary>
        public SuperInvidual()
        {
            routes = new int[InputOutput.getActiveOrdersCount()];

            List <string> remainingCities = InputOutput.getUniqueColumnsValuesActiveOrders(1);

            // Vybiram nahodne mesto
            var rnd = new Random();
            // Ukazuji na aktualni mesto
            int a = rnd.Next(0, remainingCities.Count);
            // Aktualni ridic
            int driver = 1;

            // aktualni hodnota nakladu
            int routeValue = 0;

            for (int i = 0; i < remainingCities.Count; i++)
            {
                while (remainingCities[a] == "X")
                {
                    a = rnd.Next(0, remainingCities.Count);
                }

                if (routeValue + Convert.ToInt32(Controller.activeOrdersTable.Rows[a]["Count"].ToString()) < ORDER_CAPACITY)
                {
                    routeValue         = routeValue + Convert.ToInt32(Controller.activeOrdersTable.Rows[a]["Count"].ToString());
                    routes[a]          = driver;
                    remainingCities[a] = "X";
                }
                else
                {
                    driver             = driver + 1;
                    routeValue         = Convert.ToInt32(Controller.activeOrdersTable.Rows[a]["Count"].ToString());
                    routes[a]          = driver;
                    remainingCities[a] = "X";
                }
            }

            this.driverCount = driver;

            startAlgorithm();
        }