Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Simonstrator
API
Commits
6de41a46
Commit
6de41a46
authored
May 09, 2019
by
Tobias Meuser
Browse files
Updated road properties
parent
dedd4810
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/costs/DefaultVehicularPropertyCostEstimator.java
View file @
6de41a46
...
...
@@ -54,7 +54,7 @@ public class DefaultVehicularPropertyCostEstimator implements VehicularPropertyC
@Override
public
double
calculateCostsIfKnown
(
Class
<?
extends
RoadProperty
>
pProperty
)
{
if
(
pProperty
.
equals
(
JamProperty
.
class
))
{
return
5
*
Math
.
pow
(
10
,
2
);
return
3
*
Math
.
pow
(
10
,
2
);
}
else
if
(
pProperty
.
equals
(
RainProperty
.
class
))
{
return
1
;
}
else
if
(
pProperty
.
equals
(
FogProperty
.
class
))
{
...
...
src/de/tudarmstadt/maki/simonstrator/api/component/sensor/environment/generator/lifetime/ExponentialLifetimeDistribution.java
View file @
6de41a46
...
...
@@ -32,26 +32,25 @@ public class ExponentialLifetimeDistribution implements LifetimeDistribution {
private
long
_averageEventDuration
;
private
double
_existProbability
;
private
long
_granularity
=
10
*
Time
.
SECOND
;
@XMLConfigurableConstructor
({
"duration"
})
public
ExponentialLifetimeDistribution
(
long
pEventDuration
)
{
_averageEventDuration
=
pEventDuration
;
_existProbability
=
1
-
1
/
(
double
)
(
pEventDuration
/
Time
.
SECOND
);
_existProbability
=
1
-
1
/
(
double
)
(
pEventDuration
/
_granularity
);
}
@Override
public
long
getLifetime
()
{
long
delay
=
0
;
while
(
true
)
{
double
random
=
eventDurationRandom
.
nextDouble
();
if
(
random
>
_existProbability
)
{
break
;
}
else
{
delay
+=
Time
.
SECOND
;
}
}
return
delay
;
double
random
=
eventDurationRandom
.
nextDouble
();
long
theoreticLifetime
=
(
long
)
Math
.
ceil
(
Math
.
log
(
random
)
/
Math
.
log
(
_existProbability
));
long
lifetime
=
Math
.
max
(
theoreticLifetime
*
_granularity
,
_granularity
*
2
);
System
.
out
.
println
(
"Random lifetime: "
+
random
+
" with duration: "
+
theoreticLifetime
*
_granularity
+
" (final: "
+
lifetime
+
")"
);
return
lifetime
;
}
@Override
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment