-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_nstreets.m
54 lines (48 loc) · 1.43 KB
/
main_nstreets.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
clc;
close all;
clear all;
% Anzahl der Kreuzungen
crossingNum=2;
% Anzahl Zellen zwischen Kreuzungen
cellNum=100;
% Tr�delwkt
pLinger=0.30;
% Maximale geschwindigkeit
vmax=5;
% Maximale geschwindigkeit nach Stop bei Hindernis
speedStart=1;
densityH=0.05;
densityV=repmat(0.01, crossingNum);
timesteps=100;
sims = cell(numel(densityV, 1));
for i = 1:size(densityV, 2)
% basic data
sim.timesteps = timesteps;
sim.vmax = vmax;
sim.pLinger = pLinger;
sim.densityV = densityV(:,i);
% horizontale straße
[CellsH, ObstaclesH, crossingH] = init_street(cellNum, crossingNum, densityH, vmax, timesteps);
sim.CellsH = CellsH;
sim.ObstaclesH = ObstaclesH;
sim.crossingH = crossingH;
% vertikale straßen
sim.vert = cell(numel(crossingNum), 1);
for j = 1:crossingNum
[CellsV, ObstaclesV, crossingV] = init_street(cellNum, 1, densityV(j, i), vmax, timesteps);
% Doppelbelegung der Kreuzung(en) verhindern
if( CellsV(crossingV,1,1) ~= 0)
CellsV(crossingV,1,1) = 0;
CellsV(crossingV,1,2) = 0;
end
sim.vert{j}.CellsV = CellsV;
sim.vert{j}.ObstaclesV = j.*ObstaclesH;
sim.vert{j}.crossingV = crossingV;
end
% Nagelschreckenbergs Zauberalgorithmus
sim = nagelschreckenberg(sim);
sims{i} = sim;
end
% plotCars2(CellsH, CellsV, cellsNumber);
% plotAll(CellsV, cellsNumber);
% plotAll(CellsH, cellsNumber);