当前位置: 首页>>代码示例>>Python>>正文


Python Simulation.start方法代码示例

本文整理汇总了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.")
开发者ID:djpetti,项目名称:ecosystem,代码行数:38,代码来源: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()
开发者ID:visemet,项目名称:netman,代码行数:32,代码来源:setup.py


注:本文中的simulation.Simulation.start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。