def run(source_file, options, xsl_pp_cb): try: print('Parsing model file') parser = LEMSParser(xsl_pp_cb, options.include_dirs, ['neuroml']) parser.parse_file(source_file) model = parser.get_model() #print model print('Resolving model') model.resolve_model() #print model print('Building simulation') sim = SimulationBuilder(model).build() #sim.dump() print('Running simulation') sim.run() process_simulation_output(sim, options) except ParseError as e: print('Caught ParseError - ' + str(e)) except ModelError as e: print('Caught ModelError - ' + str(e)) #except SimBuildError as e: #print('Caught SimBuildError - ' + str(e)) except SimError as e: print('Caught SimError - ' + str(e))
def main(): """ Program entry point. """ args = process_args() print('Parsing and resolving model: ' + args.lems_file) model = Model() if args.I is not None: for dir in args.I: model.add_include_directory(dir) model.import_from_file(args.lems_file) resolved_model = model.resolve() print('Building simulation') sim = SimulationBuilder(resolved_model).build() #sim.dump("Afterbuild:") if args.dlems: print('Exporting as: ' + dlems_info) from lems.dlems.exportdlems import export_component target = model.targets[0] sim_comp = model.components[target] target_net = sim_comp.parameters['target'] target_comp = model.components[target_net] dlems_file_name = args.lems_file.replace('.xml', '.json') if dlems_file_name == args.lems_file: dlems_file_name = args.lems_file + '.json' if target_comp.type == 'network': for child in target_comp.children: if child.type == 'population': comp = model.components[child.parameters['component']] export_component(model, comp, sim_comp, child.id, file_name=dlems_file_name) else: export_component(model, sim_comp, target_comp) else: print('Running simulation') sim.run() process_simulation_output(sim, args)
def main(args=None): """ Program entry point. """ if args is None: args = process_args() print('Parsing and resolving model: '+args.lems_file) model = Model() if args.I is not None: for dir in args.I: model.add_include_directory(dir) model.import_from_file(args.lems_file) resolved_model = model.resolve() print('Building simulation') sim = SimulationBuilder(resolved_model).build() #sim.dump("Afterbuild:") if args.dlems: print('Exporting as: '+dlems_info) from lems.dlems.exportdlems import export_component target = model.targets[0] sim_comp = model.components[target] target_net = sim_comp.parameters['target'] target_comp = model.components[target_net] dlems_file_name = args.lems_file.replace('.xml', '.json') if dlems_file_name == args.lems_file: dlems_file_name = args.lems_file + '.json' if target_comp.type == 'network': for child in target_comp.children: if child.type == 'population': comp = model.components[child.parameters['component']] export_component(model, comp, sim_comp, child.id, file_name=dlems_file_name) else: export_component(model, sim_comp, target_comp) else: print('Running simulation') sim.run() process_simulation_output(sim, model, args)
parser.parse_file(model_file) model = parser.get_model() #print model print('Resolving model') model.resolve_model() #print model #sys.exit(0) print('Building simulation') sim = SimulationBuilder(model).build() #dump_runnables(sim) #sys.exit(0) print('Running simulation') sim.run() #sys.exit(0) if not nogui: import matplotlib.pyplot as plt import numpy print('Plotting graphs') rq = [] for rn in sim.runnables: rq.append(sim.runnables[rn]) while rq != []: runnable = rq[0] rq = rq[1:] for c in runnable.children:
print 'Building simulation' sim = SimulationBuilder(model).build() def print_run(run, offset): print offset, run.id for rn in run.children: r = run.children[rn] print_run(r, ' ' + offset) print 'Runnables:' for r in sim.runnables: print_run(sim.runnables[r], '') print 'Running simulation' sim.run() #sys.exit(0) if not nogui: import matplotlib.pyplot as plt import numpy print 'Plotting graphs' rq = [] for rn in sim.runnables: rq.append(sim.runnables[rn]) while rq != []: runnable = rq[0] rq = rq[1:] for c in runnable.children: