DREAM:ManPy简单服务器示例不起作用

2024-09-26 22:11:59 发布

您现在位置:Python中文网/ 问答频道 /正文

我试着运行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, "%"'

据网站报道,预期结果是

the system produced 2880 parts

the total working ratio of the Machine is 50.0 %

但与此相反,当我执行脚本时,我会收到以下语句:

the system produced 1440 parts

the total working ratio of the Machine is 0.0 %

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

有什么建议或是有同样问题的人吗?在


Tags: ofthesourceobjectsqueueexitmachineworking
1条回答
网友
1楼 · 发布于 2024-09-26 22:11:59

这是因为manpyapi被更新了,以便更灵活地声明发行版。网站上的文档(我想是http://www.manpy-simulation.org/?),从来没有更新,实际上计划是做更多的例子(见下面的PDF I链接)当时间找到。在

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

所以不是:

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

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

一般来说,我们将分布类型作为外部dict的键,并将所有参数赋给内部dict

文档的更新版本(遗憾的是仍然是PDF格式,而不是html版本)在这里: https://lab.nexedi.com/nexedi/dream/blob/master/ManPy_documentation.pdf。这包含了更多的例子。在

如果不起作用,请告知

相关问题 更多 >

    热门问题