本文整理汇总了Python中simulation.Simulation.start方法的典型用法代码示例。如果您正苦于以下问题:Python Simulation.start方法的具体用法?Python Simulation.start怎么用?Python Simulation.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类simulation.Simulation
的用法示例。
在下文中一共展示了Simulation.start方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from simulation import Simulation [as 别名]
# 或者: from simulation.Simulation import start [as 别名]
def main():
if len(sys.argv) != 2:
print("Usage: main.py conf_file")
sys.exit()
# Read configuration from file.
logger.info("Reading configuration from '%s'." % (sys.argv[1]))
config_file = open(sys.argv[1])
config = yaml.load(config_file, Loader = Loader)
config_file.close()
# Load all the organisms specified.
if "Organisms" not in config:
logger.fatal("Invalid config, needs 'Organisms' section.")
if ("GridXSize" not in config and "GridYSize" not in config):
logger.fatal("Invalid config, needs GridXSize and GridYSize")
if "IterationTime" not in config:
logger.fatal("Invalid config, needs IterationTime.")
simulation = Simulation(config["GridXSize"], config["GridYSize"],
config["IterationTime"])
# Add them to the simulation.
for organism in config["Organisms"]:
for i in range(0, organism["Quantity"]):
library = Library(organism["Library"])
simulation.add_organism(organism["Library"], organism["Name"])
# Start it running.
logger.info("Delegating to simulation process.")
simulation.start()
# Wait forever.
select.select([], [], [])
logger.critical("Exiting main.py.")
示例2: return
# 需要导入模块: from simulation import Simulation [as 别名]
# 或者: from simulation.Simulation import start [as 别名]
flow.start(time)
flow.dest(dest_device)
algorithm.initialize(flow)
source_device.connect(flow)
flows[name] = flow
# Measurables
elif curr_type == 4:
# TODO: track measurables
[name, type] = line.split(', ')
if type == "flow":
measure_flows[name] = flows[name]
elif type == "link":
measure_links[name] = links[name]
return (devices.values(), measure_flows, measure_links)
if __name__ == '__main__':
filename = argv[1]
config = Setup(filename)
devices = config.devices
measure_flows = config.flows
measure_links = config.links
sim = Simulation(devices, measure_flows, measure_links)
sim.start()