Revision 23c7ab1e util/ConfPars.py

View differences:

util/ConfPars.py
6 6
from milanoMob import milano_mob
7 7
import code  # code.interact(local=dict(globals(), **locals()))
8 8

  
9

  
9 10
class ConfSettings(object):
10 11

  
11 12
    def __init__(self, settingsFile, sectionExp):
......
13 14
        self.SEC = sectionExp
14 15
        # return self.getSimulationParameters(settingsFile, sectionExp)
15 16

  
17
    def getVelocity(self, kind):
18
        velMap = {'slow': (0.139, 0.556), 'pedestrian': (0.556, 1.667), 'jogging': (
19
            1.667, 3.332), 'bike': (3.332, 8.332), 'citycar': (8.332, 22.223)}
20
        if kind not in velMap:
21
            return velMap['pedestrian']
22
        else:
23
            return velMap[kind]
24

  
16 25
    def getSimulationParameters(self):
17 26
        settingsFile, sectionExp = self.SF, self.SEC
18 27
        retParameters = {}
......
44 53
                retParameters['max_x'] = int(arg)
45 54
            elif option == 'max_y':
46 55
                retParameters['max_y'] = int(arg)
56
            elif option == 'velocity':
57
                retParameters['velocity'] = arg
58
                min_v, max_v = self.getVelocity(arg)
59
                retParameters['min_velocity'] = min_v
60
                retParameters['max_velocity'] = max_v
47 61
            elif option == 'nodes_number':
48 62
                retParameters['nodes_number'] = int(arg)
49 63
            elif option == 'max_velocity':
......
60 74
                retParameters['nodes_x_group'] = int(arg)
61 75
            elif option == 'groups_number':
62 76
                retParameters['groups_number'] = int(arg)
77
            elif option == 'aggregation':
78
                retParameters['aggregation'] = float(arg)
63 79
            else:
64 80
                print 'Unparsed ', option, '=', settings.get(sectionExp, option)
65 81
        return retParameters
66 82

  
67 83
    def configMobility(self, params):
68 84
        userMobi = params['mob_model']
69
        supportedModels = ["RandomWayPoint", "TimeVariantCommunity", "Milan"]
85
        supportedModels = ["RandomWayPoint",
86
                           "TimeVariantCommunity", "Milan", "ReferencePointGroup"]
70 87
        if userMobi not in supportedModels:
71 88
            print userMobi + " is not supported now!\n" \
72 89
                "This moility models are currently supported:"
......
88 105
            elif userMobi == "Milan":
89 106
                return milano_mob()
90 107

  
108
            elif userMobi == "ReferencePointGroup":
109
                # Reference Point Group model
110
                NxG = params['nodes_x_group']
111
                NG = params['groups_number']
112
                aggreg = params['aggregation']
113
                max_x, max_y = params['max_x'], params['max_y']
114
                min_v, max_v = params['min_velocity'], params['max_velocity']
115
                groups = [NxG for _ in range(NG)]
116
                nr_nodes = sum(groups)
117
                params['nodes_number'] = nr_nodes
118
                rpg = reference_point_group(
119
                    groups, velocity=(min_v, max_v), dimensions=(max_x, max_y), aggregation=aggreg)
120

  
121
                return rpg
91 122

  
92 123
            elif userMobi == "TimeVariantCommunity":
93 124
                '''

Also available in: Unified diff