Exemple #1
0
        public Drone FindOptimistDrone(WareHouse wh)
        {
            int min = int.MaxValue;
            Drone result = null;

            foreach (var d in Problem.Drones) {
                if (min > wh.Position.Distance (d.Position) + d.TotalTurn) {
                    result = d;
                    min = (int)wh.Position.Distance (d.Position) + d.TotalTurn;
                }
            }

            return result;
        }
Exemple #2
0
        public void DispacthOrder(WareHouse wh, Order o)
        {
            foreach (var p in o.Products) {
                int q = wh.UnloadProduct(p.Key, p.Value);
                o.Products[p.Key] -= q;

                int load = 0;
                while (q > 0) {
                    Drone d = FindOptimistDrone (wh);
                    d.MoveTo (wh.Position);
                    q -= d.LoadProduct (p.Key, q);
                    d.MoveTo (o.Destination);
                }
            }
        }
Exemple #3
0
        public Drone FindOptimistDrone(WareHouse wh)
        {
            int   min    = int.MaxValue;
            Drone result = null;

            foreach (var d in Problem.Drones)
            {
                if (min > wh.Position.Distance(d.Position) + d.TotalTurn)
                {
                    result = d;
                    min    = (int)wh.Position.Distance(d.Position) + d.TotalTurn;
                }
            }

            return(result);
        }
Exemple #4
0
        public void DispacthOrder(WareHouse wh, Order o)
        {
            foreach (var p in o.Products)
            {
                int q = wh.UnloadProduct(p.Key, p.Value);
                o.Products[p.Key] -= q;

                int load = 0;
                while (q > 0)
                {
                    Drone d = FindOptimistDrone(wh);
                    d.MoveTo(wh.Position);
                    q -= d.LoadProduct(p.Key, q);
                    d.MoveTo(o.Destination);
                }
            }
        }
Exemple #5
0
        /// <summary>
        /// Base on the previsionnal inventory, retrieve the stock for a given product type
        /// </summary>
        /// <returns>The products.</returns>
        /// <param name="warehouse">Warehouse.</param>
        /// <param name="type">Type.</param>
        int RemainingProducts(WareHouse warehouse, ProductType type)
        {
            // Get the wh prev inventory
            var inv = Inventories [warehouse];

            // How many product of this type left?
            var remainingProduct = 0;
            inv.TryGetValue(type, out remainingProduct);

            return remainingProduct;
        }
Exemple #6
0
        /// <summary>
        /// Create a monoProduct order and update the inventory
        /// </summary>
        /// <param name="warehouse">Warehouse.</param>
        /// <param name="cell">Cell.</param>
        /// <param name="type">Type.</param>
        /// <param name="qtt">Qtt.</param>
        void PlaceOrder(WareHouse warehouse, Cell cell, ProductType type, int qtt)
        {
            var detail = new Dictionary<ProductType, int>();
            detail.Add(type, qtt);

            Order order = new Order(detail, cell);

            Affect(order, warehouse);

            var inv = Inventories [warehouse];

            var value = inv [type];

            value -= qtt;

            if(value == 0)
            {
                inv.Remove(type);
            }
            else
            {
                inv [type] = value;
            }
        }
Exemple #7
0
        /// <summary>
        /// Affect the specified order to the given warehouse
        /// </summary>
        /// <param name="o">O.</param>
        /// <param name="h">The height.</param>
        void Affect(Order o, WareHouse h)
        {
            if(!DispatchResults.ContainsKey(h))
            {
                DispatchResults.Add(h, new List<Order>());
            }

            var orders = DispatchResults [h];

            orders.Add(o);
        }