为了安全起见,我可能无法发布我们的任何文件代码,但我可以描述发生了什么。基本上,我们有独立的项目和其他由较小部分组成的项目。我们现有的系统就是这样工作的。假设我们对每个工具包有n个项目和m个部分,其中m不是常数,在所有情况下都小于n。库存算法运行时的大O符号
for(all items){
if(standalone){
process item, record available quantity and associated costs
write to database
}
if(kit){
process item, get number of pre-assembled kits
for(each part){
determine how many are used to produce one kit
divide total number of this specific part by number required, keep track of smallest result
add cost of this item to total production cost of item
}
use smallest resulting number to determine total available quantity for this kit
write record to database
}
}
首先,我想说,采取这样做的总时间为O(n^2),但我不相信这是正确的因为所有项目的大约N/3包,一般中号范围在3到8个部分之间。这会发生什么?我测试了几次,感觉它没有优化。
如果套件中的部件的最大值可以忽略不计(如10),则认为该值不变。大O符号是关于当你有几百万个零件时会发生什么 - 当零件数以百万计时,那么10是微不足道的。如果套件中的最大零件数为10,那么它将是O(n) –