2017-04-05 41 views
0

我試圖運行ManPy仿真引擎。我安裝了所有依賴項並安裝了DREAM模塊。現在我試圖運行簡單的服務器從ManPy網站(http://www.manpy-simulation.org)例如:DREAM:ManPy簡單服務器示例不起作用

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%

但與此相反,當我執行腳本時,我收到了stat EMENT:

系統產生1440份

機器的總加工率是0.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。這包含更多的例子。

請告知這是行不通的