1
0
mirror of https://github.com/gsi-upm/soil synced 2024-11-14 15:32:29 +00:00
soil/simulator.py

37 lines
1.1 KiB
Python
Raw Permalink Normal View History

2017-12-15 16:59:50 +00:00
import os
2018-04-10 16:26:24 +00:00
import networkx as nx
2017-12-15 16:59:50 +00:00
from soil.simulation import SoilSimulation
2018-04-16 08:55:27 +00:00
class Simulator():
""" Simulator for running simulations. Using SOIL."""
2017-12-15 16:59:50 +00:00
2018-02-02 14:01:17 +00:00
def __init__(self, dump=False, dir_path='output'):
2018-02-01 18:37:10 +00:00
self.name = 'soil'
self.dump = dump
self.dir_path = dir_path
2017-12-15 16:59:50 +00:00
2018-02-01 18:37:10 +00:00
def run(self, config):
name = config['name']
print('Using config(s): {name}'.format(name=name))
2017-12-15 16:59:50 +00:00
2018-02-01 18:37:10 +00:00
sim = SoilSimulation(**config)
sim.dir_path = os.path.join(self.dir_path, name)
sim.dump = self.dump
2017-12-15 16:59:50 +00:00
2018-02-01 18:37:10 +00:00
print('Dumping results to {} : {}'.format(sim.dir_path, sim.dump))
2018-04-10 16:26:24 +00:00
simulation_results = sim.run_simulation()
2018-04-12 16:00:44 +00:00
# G = simulation_results[0].history_to_graph()
# for node in G.nodes():
# if 'pos' in G.node[node]:
# G.node[node]['viz'] = {"position": {"x": G.node[node]['pos'][0], "y": G.node[node]['pos'][1], "z": 0.0}}
# del (G.node[node]['pos'])
# nx.write_gexf(G, 'test.gexf', version='1.2draft')
2018-04-10 16:26:24 +00:00
return simulation_results
2017-12-15 16:59:50 +00:00
2018-02-01 18:37:10 +00:00
def reset(self):
pass