Пример #1
0
 def get_db_params():
     if len(App.__ds) is 0:
         try:
             App.__ds = config.read_params('config/main.ini', 'data_source')
         except Exception:
             App.msg_error()
     return App.__ds
Пример #2
0
 def get_language():
     if len(App.__lang) is 0:
         try:
             App.__lang = config.read_params('config/main.ini',
                                             'location')['language']
         except Exception:
             App.msg_error()
     return App.__lang
Пример #3
0
 def get_license():
     if len(App.__license) is 0:
         try:
             App.__license = config.read_params('config/main.ini',
                                                'main')['license']
         except Exception:
             App.msg_error()
     return App.__license
Пример #4
0
 def get_description():
     if len(App.__description) is 0:
         try:
             App.__description = config.read_params('config/main.ini',
                                                    'main')['description']
         except Exception:
             App.msg_error()
     return App.__description
Пример #5
0
 def get_author():
     if len(App.__author) is 0:
         try:
             App.__author = config.read_params('config/main.ini',
                                               'main')['author']
         except Exception:
             App.msg_error()
     return App.__author
 def test_read_params(self):
     """
     Test if the configuration file reading function.
     
     Test if the returned dictionary is what we expect to be.
     """
     test_dict = {'road_length':3 ,'density_max':120, 'free_v':50,
                    'mean_time_gap':0.6, 'simulation_time':0.2,
                    'source':0.8, 'sink':1}
     params = read_params('configuration.csv')
     
     self.assertDictEqual(params,test_dict)
from argparse import ArgumentParser
from os import mkdir
from shutil import copyfile
from datetime import datetime

parser = ArgumentParser(description='Simulate the density evolution of a road') 
parser.add_argument('-f','--filename',
                    help='Filename of the output')
parser.add_argument('-p','--params',
                    help='csv file with model parameters')
parser.add_argument('-b','--bottlenecks',
                    help='csv file with bottlenecks parameters')
args = parser.parse_args()

#reading model parameters from configuration file
params = read_params(args.params)

#building the road
road = Road(**params)
road.make_cells()

#reading bottleneks
bns = read_bottlenecks(road, args.bottlenecks)

#simulation with the chosen bottlenecks
road.simulation(bns)


#saving output
if args.filename:
    name = args.filename