DREAM:ManPy简单的服务器示例无法正常工作

时间:2017-04-05 13:56:59

标签: python simulation simpy

我正在尝试运行ManPy模拟引擎。我安装了所有依赖项并安装了DREAM模块。现在我试图从ManPy网站(http://www.manpy-simulation.org)运行简单的服务器示例:

from dream.simulation.imports import Source, Queue, Machine, Exit  
from dream.simulation.Globals import runSimulation

#define the objects of the model 
S=Source('S1','Source',interarrivalTime={'distributionType':'Fixed','mean':0.5}, entity='Dream.Part')
Q=Queue('Q1','Queue', capacity=1)
M=Machine('M1','Machine', processingTime={'distributionType':'Fixed','mean':0.25})
E=Exit('E1','Exit')  

#define predecessors and successors for the objects    
S.defineRouting(successorList=[Q])
Q.defineRouting(predecessorList=[S],successorList=[M])
M.defineRouting(predecessorList=[Q],successorList=[E])
E.defineRouting(predecessorList=[M])

# call the runSimulation giving the objects and the length of the experiment
runSimulation(objectList=[S,Q,M,E], maxSimTime=1440.0)

# calculate metrics
working_ratio = (M.totalWorkingTime/1440.0)*100 

#print the results
print "the system produced", E.numOfExits, "parts"
print "the total working ratio of the Machine is", working_ratio, "%"'

预期结果,根据网站

  

系统生产了2880份

     

机器的总工作比率为50.0%

但与此相反,当我执行脚本时,我会收到声明:

  

系统生产了1440个零件

     

机器的总工作比率为0.0%

生产零件的数量只是以秒为单位的最大模拟时间。

有任何建议或有同样问题的人吗?

1 个答案:

答案 0 :(得分:1)

这是因为ManPy API已更新,以便更灵活地声明分发。网站上的文档(我想http://www.manpy-simulation.org/?)从未更新过,实际上计划是在找到时间后做更多的例子(参见下面的PDF链接)。

此示例的正确代码如下: https://lab.nexedi.com/nexedi/dream/blob/master/dream/simulation/Examples/SingleServer.py

所以不是:

processingTime={'distributionType':'Fixed','mean':0.25}

但: processingTime={'Fixed':{'mean':0.25}}

通常,我们将分布类型作为外部字典的键和内部字典中的所有参数。

文档的更新版本(遗憾的是仍然是PDF,还没有在html版本中)在这里: https://lab.nexedi.com/nexedi/dream/blob/master/ManPy_documentation.pdf。这包含更多示例。

如果这不起作用,请通知

相关问题