我创建了一个带有 if 流控制的函数,我想知道一些关于它的事情。
class Supplier(Process):
def weeklySupply(self):
global D1Vals
xMeet = D1Vals[0]
lead = 0
capac = 150.0
supply = 0
if stocked.amount >= 15000:
supply = 0
yield put, self, stocked, supply
S1Vals.append(0)
elif supply >= capac:
supply = capac
yield put, self, stocked, supply
S1Vals.append(capac)
else:
supply = random.triangular(.70 * xMeet , xMeet , xMeet * 1.05)
yield put, self, stocked, supply
print ('Week:'+'%6.0f:Supplied: %6.0f units. CurSupply = %6.0f' %
(now() + 1., supply, stocked.amount))
yield hold, self, lead
S1Vals.append(supply)
del D1Vals[0]
我虽然编码的是:
如果库存对象中的数量 >= 15000,则该对象生成零供应,或者如果生成的供应值大于预定义的“capac”数量,则供应值 =“capac”。
如果以上均不成立,则供应值生成为随机分布。但是,当我得到输出时,供应值确实超过了 150 的“容量”值。
我是否误解了如何进行流程?