Commit 668a51d7 authored by Ioannis Papagiannopoulos's avatar Ioannis Papagiannopoulos Committed by Sebastien Robin

Test vs Topology22 added

parent db943eaa
......@@ -26,6 +26,9 @@ Created on 7 May 2013
main script. Reads data from JSON, generates and runs the simulation and prints the results to excel
'''
# ===========================================================================
# IMPORTS
# ===========================================================================
from warnings import warn
import logging
logger = logging.getLogger("dream.platform")
......@@ -81,15 +84,19 @@ from random import Random
import sys
import os.path
#reads general simulation inputs
# ===========================================================================
# reads general simulation inputs
# ===========================================================================
def readGeneralInput():
general=G.JSONData['general']
G.numberOfReplications=int(general.get('numberOfReplications', '1'))
G.maxSimTime=float(general.get('maxSimTime', '100'))
general=G.JSONData['general'] # read the dict with key 'general'
G.numberOfReplications=int(general.get('numberOfReplications', '1')) # read the number of replications
G.maxSimTime=float(general.get('maxSimTime', '100')) # get the maxSimTime
G.trace=general.get('trace', 'No')
G.confidenceLevel=float(general.get('confidenceLevel', '0.95'))
#creates the simulation objects
# ===========================================================================
# creates the simulation objects
# ===========================================================================
def createObjects():
json_data = G.JSONData
......@@ -463,19 +470,19 @@ def main(argv=[], input_data=None):
if input_data is None:
# user passes the topology filename as first argument to the program
filename = argv[0]
try:
G.JSONFile=open(filename, "r")
try: # try to open the file with the inputs
G.JSONFile=open(filename, "r") # global variable holding the file to be opened
except IOError:
print "%s could not be open" % filename
return "ERROR"
G.InputData=G.JSONFile.read()
G.InputData=G.JSONFile.read() # pass the contents of the input file to the global var InputData
else:
G.InputData = input_data
start=time.time() #start counting execution time
start=time.time() # start counting execution time
#read the input from the JSON file and create the line
G.JSONData=json.loads(G.InputData)
G.JSONData=json.loads(G.InputData) # create the dictionary JSONData
readGeneralInput()
createObjects()
setTopology()
......@@ -492,10 +499,12 @@ def main(argv=[], input_data=None):
setWIP()
activateObjects()
#if the simulation is ran until no more events are scheduled, then we have to find the end time as the time the last entity ended.
# if the simulation is ran until no more events are scheduled,
# then we have to find the end time as the time the last entity ended.
if G.maxSimTime==-1:
simulate(until=infinity) #simulate until there are no more events. If someone does it for a model that has always events, then it will run forever!
#identify from the exits what is the time that the last entity has ended.
simulate(until=infinity) # simulate until there are no more events.
# If someone does it for a model that has always events, then it will run forever!
# identify from the exits what is the time that the last entity has ended.
endList=[]
for exit in G.ExitList:
endList.append(exit.timeLastEntityLeft)
......
{
"elementList": [
{
"_class": "Dream.Exit",
"id": "E1",
"results": {
"throughput": 359,
"takt_time": 4.006963788300836,
"lifespan": 454.0
}
},
{
"_class": "Dream.Machine",
"id": "M1",
"results": {
"working_ratio": 50.06944444444444,
"blockage_ratio": 49.826388888888886,
"failure_ratio": 0.0,
"waiting_ratio": 0.10416666666666667
}
},
{
"_class": "Dream.Machine",
"id": "M2",
"results": {
"working_ratio": 99.89583333333333,
"blockage_ratio": 0.0,
"failure_ratio": 0.0,
"waiting_ratio": 0.10416666666666667
}
},
{
"_class": "Dream.Machine",
"id": "M3",
"results": {
"working_ratio": 24.930555555555557,
"blockage_ratio": 0.0,
"failure_ratio": 0.0,
"waiting_ratio": 75.06944444444444
}
}
],
"_class": "Dream.Simulation",
"general": {
"_class": "Dream.Configuration"
}
}
\ No newline at end of file
......@@ -66,7 +66,7 @@ class SimulationTopology(TestCase):
self.assertEquals(stable_result, dump_result, "outputs are different")
# Automatically create a test method for every topology
for x in range(1, 22):
for x in range(1, 23):
def getTestTopology():
filename = "Topology%02i" % x
def test_topology(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment