爲了安全起見,我可能無法發佈我們的任何文件代碼,但我可以描述發生了什麼。基本上,我們有獨立的項目和其他由較小部分組成的項目。我們現有的系統就是這樣工作的。假設我們對每個工具包有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) –