这是我的伪代码,它没有考虑到搜索深度可能超过 1,但我相信基本算法是合理的。
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)
}