def mpr(x,ss,s0, lt): #we initialize both gross requierement array and scheduled receipts array gr= [] sr= [] #we insert our values in both gross requierement array and scheduled receipts array for i in range(x): gr.append(int(input("insert :"))) for i in range(x): sr.append(int(input("insert scheduled receipts:"))) oh = [0] * x nr = [0] * x por = [0] * x if s0 + ss + sr[0] > gr[0] : nr[0]=0 oh[0]=(s0+sr[0])-gr[0] else : nr[0]=gr[0]- ( (s0-ss)+sr[0]) oh[0]=ss i=1 while i < x : if oh[(i-1)] + ss + sr[i] > gr[i] : nr[i]=0 oh[i]=(oh[i-1]+sr[i])-gr[i] else : nr[i]=gr[i]-((oh[i-1]-ss)+sr[i]) oh[i]=ss por[i-lt]=nr[i] sr[i]=por[i-lt] i+=1 return [gr,sr,oh,nr,por] # we call our fonction using : number of days/months, security stock, first stock on hand, and LT as entries to our function print(mpr(8,0,100,3))
时间: 2024-04-29 09:20:01 浏览: 61
mpr-6zhmaut-api:Monoprice 6 Zone Home Audio Multizone Controller and Amplifier Kit (MPR-6ZHMAUT) 的 RS-232 接口的 JSON API 包装器
此代码是一个物料需求计划(Material Requirements Planning, MRP)的模拟实现,输入参数为天数/月数、安全库存、初始库存和LT(交货时间),然后输出一个由五个数组组成的列表,分别是毛需求、计划收货、期初库存、净需求和计划在手量。这个函数的实现比较复杂,主要是在计算净需求和计划在手量时需要考虑上一个时间段的期末库存和安全库存的影响。
阅读全文