1 | /************************************************************************************ |
---|
2 | * Copyright (C) 2008 by Politehnica University of Bucharest and Rutgers University |
---|
3 | * All rights reserved. |
---|
4 | * Refer to LICENSE for terms and conditions of use. |
---|
5 | ***********************************************************************************/ |
---|
6 | package vnsim.vehicular.simulator; |
---|
7 | |
---|
8 | import vnsim.map.object.Globals; |
---|
9 | import vnsim.map.object.Road; |
---|
10 | |
---|
11 | public class AggresivePersonality implements Personality { |
---|
12 | |
---|
13 | private double coef1, coef2, coef3, coef4, coef5, coef6, coef7, |
---|
14 | coef8, coef9, coef10, coef11, coef12; |
---|
15 | |
---|
16 | public AggresivePersonality() { |
---|
17 | coef1=0.0; |
---|
18 | coef2=1.0-Math.random()*2; |
---|
19 | coef3=0.1-Math.random()*0.2; |
---|
20 | coef4=5.0-Math.random()*10; |
---|
21 | coef5=0.1-Math.random()*0.2; |
---|
22 | coef6=1.0-Math.random()*2; |
---|
23 | coef7=1.0-Math.random()*2; |
---|
24 | coef8=1.0-Math.random()*2; |
---|
25 | coef9=5.0-Math.random()*10; |
---|
26 | coef10=0.1-Math.random()*0.2; |
---|
27 | coef11=0.5-Math.random(); |
---|
28 | coef12=0.5-Math.random(); |
---|
29 | } |
---|
30 | |
---|
31 | public double getSafetyDistance(double speed) { |
---|
32 | if(speed<10) |
---|
33 | return (0.14+coef1)*speed+8.0+coef2; |
---|
34 | |
---|
35 | return (0.9/1.8)*speed+coef4; |
---|
36 | } |
---|
37 | |
---|
38 | public double getInfluenceDistance(double speed) { |
---|
39 | return (1.4+coef3)*speed+30.0+coef4; |
---|
40 | } |
---|
41 | |
---|
42 | public double getDesiredDistance(double speed){ |
---|
43 | if(speed<10) { |
---|
44 | return 5.0; |
---|
45 | } |
---|
46 | return (0.3+coef5)*speed+10.0+coef6; |
---|
47 | } |
---|
48 | |
---|
49 | public double getAccelerationFreeDriving() { |
---|
50 | return 8.0+coef7; |
---|
51 | } |
---|
52 | |
---|
53 | public double getAccelerationMaximumBrake() { |
---|
54 | return -30.0+coef8; |
---|
55 | } |
---|
56 | |
---|
57 | public double getWantedSpeed(int roadIndex) { |
---|
58 | Road r=Globals.map.roads.get(roadIndex); |
---|
59 | switch(r.getRoadinfo()[1]) { |
---|
60 | case 49: |
---|
61 | return 110+coef9; |
---|
62 | case 50: |
---|
63 | return 100+coef9; |
---|
64 | case 51: |
---|
65 | return 90+coef9; |
---|
66 | case 52: |
---|
67 | return 80+coef9; |
---|
68 | default: |
---|
69 | return 60+coef9; |
---|
70 | } |
---|
71 | } |
---|
72 | |
---|
73 | public double getLaneChangeSafetyDistance(double mySpeed, double folSpeed) { |
---|
74 | double dif=folSpeed-mySpeed; |
---|
75 | if(dif<0) |
---|
76 | return 4.0; |
---|
77 | |
---|
78 | if(dif<2 && mySpeed < 10) |
---|
79 | return 4.0; |
---|
80 | |
---|
81 | return (dif)*(0.4+coef10) + (10.0+coef11); |
---|
82 | } |
---|
83 | |
---|
84 | public double getLaneChangeSafetyDistanceInFront(double mySpeed, double precSpeed) { |
---|
85 | double dif=mySpeed-precSpeed; |
---|
86 | if(dif<0) |
---|
87 | return 4.0; |
---|
88 | |
---|
89 | if(dif<5) |
---|
90 | return 6.0; |
---|
91 | |
---|
92 | return dif*0.4+8.0; |
---|
93 | } |
---|
94 | |
---|
95 | public double getWantedSpeedInfluenced(double distanceFromIntersection, double requiredSpeed) { |
---|
96 | //return requiredSpeed+distanceFromIntersection*1000/4.0; |
---|
97 | |
---|
98 | double distMeters=distanceFromIntersection*1000; |
---|
99 | |
---|
100 | if(distMeters>90) |
---|
101 | return 100; |
---|
102 | |
---|
103 | return requiredSpeed+(-1.0/90.0*distMeters*distMeters+19/9*distMeters); |
---|
104 | } |
---|
105 | |
---|
106 | public double getReactionTimeFreeDriving() { |
---|
107 | return 0.8+coef12; |
---|
108 | } |
---|
109 | |
---|
110 | public boolean estimateRoadChangePossible(double mySpeed, double otherSpeed, double myDist, double otherDist) { |
---|
111 | if(otherSpeed<10) { |
---|
112 | if(otherDist > 0.03 && myDist < 0.03) |
---|
113 | return true; |
---|
114 | return false; |
---|
115 | } |
---|
116 | |
---|
117 | if(mySpeed>otherSpeed) { |
---|
118 | if(otherDist > 0.04 && myDist < 0.03) return true; |
---|
119 | } |
---|
120 | |
---|
121 | if(otherDist > 0.05 && myDist < 0.02) return true; |
---|
122 | |
---|
123 | return false; |
---|
124 | } |
---|
125 | } |
---|