Algorithm to Minimize Number of Shipments from Multiple Warehouses

前端 未结 5 1690
伪装坚强ぢ
伪装坚强ぢ 2021-02-10 13:04

I have 10 warehouses across the US. Each of them may or may not have product A, B, C, D, E in stock. Someone orders all five items from my website.

I want to minimize th

5条回答
  •  野性不改
    2021-02-10 13:39

    Here is my psudeocode that does not take into account that the search depth could be more than 1, but I believe the basic algorithm is sound.

       ItemList = (A,B,C,D,E,F)
    //Iterate until all items have been scheduled  
        do while length of Itemlist > 0
        {
        var1=0;
        Warehouse="";
    
    //Search all the warehouses to find which has the most items in the list
        For w = 1 to 10
        {
        val2 = function[select no of items available from Itemlist](ItemList,w);
        if var2 > var1 then
        {var1=var2;
        Warehouse=w;}
        }
    
    //Return a list of the items available from the warehouse with the most items available
        DBrecordset = function[select no of items available from Itemlist](ItemList,Warehouse);
    //schedule them
        Output to file (Warehouse + DB recordset contents)
    //remove the scheduled items from the list
        function [Remove items from ItemList](ItemList,DBRecordset) 
    
        }
    

提交回复
热议问题