Exemple #1
0
            if petIndicator is not None:
                pet = petIndicator.getMostSevereValue(1) * sim.timeStep
                if pet < 20:
                    PETs[seed].append(pet)

    rearEndnInter10[seed] = [(np.array(readEndMinDistance[seed]) <= 10).sum()]
    rearEndnInter20[seed] = [(np.array(readEndMinDistance[seed]) <= 20).sum()]
    rearEndnInter50[seed] = [(np.array(readEndMinDistance[seed]) <= 50).sum()]

    sidenInter10[seed] = [(np.array(sideMinDistance[seed]) <= 10).sum()]
    sidenInter20[seed] = [(np.array(sideMinDistance[seed]) <= 20).sum()]
    sidenInter50[seed] = [(np.array(sideMinDistance[seed]) <= 50).sum()]

toolkit.saveYaml(data=[
    sidenInter10, sidenInter20, sidenInter50, rearEndnInter10, rearEndnInter20,
    rearEndnInter50, sideTTCs, readEndTTCs, PETs
],
                 filename='stabilization-results.yml')

# toolkit.plotVariations(sideMinDistance, 'side-minDistance.pdf', 'side minimum intervehicular distances (m)', 'minimum intervehicular distance (m)')
# toolkit.plotVariations(readEndMinDistance, 'readEnd-minDistance.pdf', 'rear end minimum intervehicular distances (m)', 'minimum intervehicular distance (m)')
#
# toolkit.plotVariations(sideTTCs, 'side-TTCs.pdf', 'side TTCs (s)', 'TTC (s)')
# toolkit.plotVariations(sidenInter10, 'side-nInter10.pdf', 'side $nInter_{10}^{latéral$', 'side $nInter_{10}$')
# toolkit.plotVariations(sidenInter20, 'side-nInter20.pdf', 'side $nInter_{20}$', 'side $nInter_{20}$')
# toolkit.plotVariations(sidenInter50, 'side-nInter50.pdf', 'side $nInter_{50}$', 'side $nInter_{50}$')
#
# toolkit.plotVariations(readEndTTCs, 'rearEnd-TTCs.pdf', 'rear end TTCs (s)','TTC (s)')
# toolkit.plotVariations(rearEndnInter10, 'rearEnd-nInter10.pdf', 'rear end $nInter_{10}$', 'rear end $nInter_{10}$')
# toolkit.plotVariations(rearEndnInter20, 'rearEnd-nInter20.pdf', 'rear end $nInter_{20}$', 'rear end $nInter_{20}$')
# toolkit.plotVariations(rearEndnInter50, 'rearEnd-nInter50.pdf', 'rear end $nInter_{50}$', 'rear end $nInter_{50}$')
Exemple #2
0
 def save(self, filename):
     toolkit.saveYaml(filename, self)
Exemple #3
0
stop_nInter10 = {
    1: np.mean(stop_rearEndnInter10),
    2: np.mean(stop_sidenInter10)
}
stop_nInter20 = {
    1: np.mean(stop_rearEndnInter20),
    2: np.mean(stop_sidenInter20)
}
stop_nInter50 = {
    1: np.mean(stop_rearEndnInter50),
    2: np.mean(stop_sidenInter50)
}

toolkit.callWhenDone()

stop_results = {
    'PETS': stop_PETs,
    'TTCs': stop_minTTCs,
    'side-nInter10': stop_sidenInter10,
    'side-nInter20': stop_sidenInter20,
    'side-nInter50': stop_sidenInter50,
    'rear-nInter10': stop_rearEndnInter10,
    'rear-nInter20': stop_rearEndnInter20,
    'rear-nInter50': stop_rearEndnInter50,
    'nInter10': stop_nInter10,
    'nInter20': stop_nInter20,
    'nInter50': stop_nInter50,
    'minDistances': stop_minDistances,
}
toolkit.saveYaml('stop_results.yml', stop_results)
Exemple #4
0
            (np.array(minDistances[surface][1][analysis.seed]) <= 50).sum())

    nInter10[surface] = {
        1: np.mean(rearEndnInter10[surface]),
        2: np.mean(sidenInter10[surface])
    }
    nInter20[surface] = {
        1: np.mean(rearEndnInter20[surface]),
        2: np.mean(sidenInter20[surface])
    }
    nInter50[surface] = {
        1: np.mean(rearEndnInter50[surface]),
        2: np.mean(sidenInter50[surface])
    }

toolkit.saveYaml('zone{}-nInter10.yml'.format(surface), nInter10)
toolkit.saveYaml('zone{}-nInter20.yml'.format(surface), nInter20)
toolkit.saveYaml('zone{}-nInter50.yml'.format(surface), nInter50)

toolkit.saveYaml('zone{}-rearEndnInter10.yml'.format(surface), rearEndnInter10)
toolkit.saveYaml('zone{}-rearEndnInter20.yml'.format(surface), rearEndnInter20)
toolkit.saveYaml('zone{}-rearEndnInter50.yml'.format(surface), rearEndnInter50)

toolkit.saveYaml('zone{}-sidenInter10.yml'.format(surface), sidenInter10)
toolkit.saveYaml('zone{}-sidenInter20.yml'.format(surface), sidenInter20)
toolkit.saveYaml('zone{}-sidenInter50.yml'.format(surface), sidenInter50)

toolkit.saveYaml('zone{}-PETs.yml'.format(surface), PETs)
toolkit.saveYaml('zone{}-minDistances.yml'.format(surface), minDistances)
toolkit.saveYaml('zone{}-minTTCs.yml'.format(surface), minTTCs)
Exemple #5
0
sQuo_nInter10 = {
    1: np.mean(sQuo_rearEndnInter10),
    2: np.mean(sQuo_sidenInter10)
}
sQuo_nInter20 = {
    1: np.mean(sQuo_rearEndnInter20),
    2: np.mean(sQuo_sidenInter20)
}
sQuo_nInter50 = {
    1: np.mean(sQuo_rearEndnInter50),
    2: np.mean(sQuo_sidenInter50)
}

toolkit.callWhenDone()

sQuo_results = {
    'PETS': sQuo_PETs,
    'TTCs': sQuo_minTTCs,
    'side-nInter10': sQuo_sidenInter10,
    'side-nInter20': sQuo_sidenInter20,
    'side-nInter50': sQuo_sidenInter50,
    'rear-nInter10': sQuo_rearEndnInter10,
    'rear-nInter20': sQuo_rearEndnInter20,
    'rear-nInter50': sQuo_rearEndnInter50,
    'nInter10': sQuo_nInter10,
    'nInter20': sQuo_nInter20,
    'nInter50': sQuo_nInter50,
    'minDistances': sQuo_minDistances,
}
toolkit.saveYaml('sQuo_results.yml', sQuo_results)
Exemple #6
0
    rearEndnInter50.append((np.array(tempMinDistances[1]) <= 50).sum())

    sidenInter10.append((np.array(tempMinDistances[2]) <= 10).sum())
    sidenInter20.append((np.array(tempMinDistances[2]) <= 20).sum())
    sidenInter50.append((np.array(tempMinDistances[2]) <= 50).sum())

nInter10 = {1: np.mean(rearEndnInter10), 2: np.mean(sidenInter10)}
nInter20 = {1: np.mean(rearEndnInter20), 2: np.mean(sidenInter20)}
nInter50 = {1: np.mean(rearEndnInter50), 2: np.mean(sidenInter50)}

baseCaseResults = {
    "minDistances": minDistances,
    "minTTCs": minTTCs,
    "PETs": PETs,
    "nInter10": nInter10,
    "nInter20": nInter20,
    "nInter50": nInter50,
    "rearEndnInter10": rearEndnInter10,
    "rearEndnInter20": rearEndnInter20,
    "rearEndnInter50": rearEndnInter50,
    "sidenInter10": sidenInter10,
    "sidenInter20": sidenInter20,
    "sidenInter50": sidenInter50,
    "completedUser0": numberOfcompletedUsers0,
    "completedUSers2": numberOfcompletedUsers2
}

toolkit.saveYaml('base-case-results.yml', baseCaseResults)

toolkit.callWhenDone()
Exemple #7
0
yield_nInter10 = {
    1: np.mean(yield_rearEndnInter10),
    2: np.mean(yield_sidenInter10)
}
yield_nInter20 = {
    1: np.mean(yield_rearEndnInter20),
    2: np.mean(yield_sidenInter20)
}
yield_nInter50 = {
    1: np.mean(yield_rearEndnInter50),
    2: np.mean(yield_sidenInter50)
}

toolkit.callWhenDone()

yield_results = {
    'PETS': yield_PETs,
    'TTCs': yield_minTTCs,
    'side-nInter10': yield_sidenInter10,
    'side-nInter20': yield_sidenInter20,
    'side-nInter50': yield_sidenInter50,
    'rear-nInter10': yield_rearEndnInter10,
    'rear-nInter20': yield_rearEndnInter20,
    'rear-nInter50': yield_rearEndnInter50,
    'nInter10': yield_nInter10,
    'nInter20': yield_nInter20,
    'nInter50': yield_nInter50,
    'minDistances': yield_minDistances,
}
toolkit.saveYaml('yield_results.yml', yield_results)
Exemple #8
0
    2: np.mean(pedestrians_sidenInter10)
}
pedestrians_nInter20 = {
    1: np.mean(pedestrians_rearEndnInter20),
    2: np.mean(pedestrians_sidenInter20)
}
pedestrians_nInter50 = {
    1: np.mean(pedestrians_rearEndnInter50),
    2: np.mean(pedestrians_sidenInter50)
}

resultsPedestriansStop = {
    'minTTCS': pedestrians_minTTC,
    'minDistances': pedestrians_minDistances,
    'PETs': pedestrians_PETs,
    'nInter10': pedestrians_nInter10,
    'nInter20': pedestrians_nInter20,
    'nInter50': pedestrians_nInter50,
    'rearEndnInter10': pedestrians_rearEndnInter10,
    'rearEndnInter20': pedestrians_rearEndnInter20,
    'rearEndnInter50': pedestrians_rearEndnInter50,
    'pedestrians_sidenInter10': pedestrians_sidenInter10,
    'pedestrians_sidenInter20': pedestrians_sidenInter20,
    'pedestrians_sidenInter50': pedestrians_sidenInter50
}

toolkit.saveYaml('pedestrians-results.yml', resultsPedestriansStop)

toolkit.saveYaml('pedestrians-minTTC.yml', pedestrians_minTTCs)
toolkit.saveYaml('pedestrians-minDistances.yml', pedestrians_minDistances)
toolkit.saveYaml('pedestrians-PETs.yml', pedestrians_PETs)
Exemple #9
0
            PETs = []
            interactions = []

            for seed in seeds:
                tempMinDistances = {1: [], 2: []}
                print('run {} ou of {}'.format(seeds.index(seed) + 1, len(seeds)))
                sim.seed = seed
                world = network.World.load('config files/stop.yml')
                if world.userInputs[1].distributions[distribution].loc is not None:
                    world.userInputs[1].distributions[distribution].loc *= (1 + variation)
                else:
                    world.userInputs[1].distributions[distribution].degeneratedConstant *= (1 + variation)
                sim.run(world)
                numberOfUsers0[distribution][variation].append(len([user for user in world.completed if user.getInitialAlignment().idx == 0]))
                numberOfUsers2[distribution][variation].append(len([user for user in world.completed if user.getInitialAlignment().idx == 2]))
                toolkit.saveYaml('numberOfUsers0-{}{}.yml'.format(distribution, variation), numberOfUsers0)
                toolkit.saveYaml('numberOfUsers2-{}{}.yml'.format(distribution, variation), numberOfUsers2)

                for inter in world.completedInteractions:
                    if inter.categoryNum is not None:
                        distance = inter.getIndicator(events.Interaction.indicatorNames[2])
                        if distance is not None:
                            minDistances[inter.categoryNum].append(distance.getMostSevereValue(1))
                            tempMinDistances[inter.categoryNum].append(distance.getMostSevereValue(1))

                        ttc = inter.getIndicator(events.Interaction.indicatorNames[7])
                        if ttc is not None:
                            minTTC = ttc.getMostSevereValue(1) * sim.timeStep  # seconds
                            if minTTC < 0:
                                print(inter.num, inter.categoryNum, ttc.values)
                            if minTTC < 20: