Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
vadere
vadere
Commits
bbd98c0b
Commit
bbd98c0b
authored
May 18, 2020
by
Christina
Browse files
finish sim before end time simplified version
parent
e1bb6ac6
Pipeline
#257298
passed with stages
in 136 minutes and 45 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
VadereSimulator/src/org/vadere/simulator/control/simulation/Simulation.java
View file @
bbd98c0b
...
...
@@ -288,7 +288,12 @@ public class Simulation {
c
.
postUpdate
(
simTimeInSec
);
}
double
stopTime
=
Math
.
min
(
runTimeInSec
,
this
.
simulationState
.
getStopTime
());
double
stopTime
=
runTimeInSec
;
if
(
this
.
simulationState
.
isSimStop
())
{
// get stopTime if the simulation should finish before finish time. New finish time = stop time
stopTime
=
this
.
simTimeInSec
;
}
if
(
stopTime
+
startTimeInSec
>
simTimeInSec
+
1
e
-
7
)
{
// do nothing here. This is done after the Remote Control Hook
}
else
{
...
...
VadereSimulator/src/org/vadere/simulator/control/simulation/SimulationState.java
View file @
bbd98c0b
...
...
@@ -16,7 +16,7 @@ public class SimulationState {
private
final
int
step
;
private
final
String
name
;
private
final
MainModel
mainModel
;
private
double
stopTime
=
Float
.
POSITIVE_INFINITY
;
private
boolean
simStop
=
false
;
protected
SimulationState
(
final
String
name
,
final
Topography
topography
,
...
...
@@ -76,11 +76,11 @@ public class SimulationState {
return
Optional
.
ofNullable
(
mainModel
);
}
public
double
getStopTime
(
){
return
this
.
stopTime
;
public
void
setSimStop
(
boolean
stop
){
this
.
simStop
=
stop
;
}
public
void
setStopTime
(
double
stopTime
)
{
this
.
stopTime
=
stopTime
;
public
boolean
isSimStop
(
)
{
return
simStop
;
}
}
VadereSimulator/src/org/vadere/simulator/projects/dataprocessing/processor/DataProcessor.java
View file @
bbd98c0b
...
...
@@ -45,6 +45,8 @@ public abstract class DataProcessor<K extends DataKey<K>, V> {
private
int
lastStep
;
private
boolean
stopSimBeforeSimFinish
;
protected
DataProcessor
()
{
this
(
new
String
[]
{
});
}
...
...
@@ -54,6 +56,7 @@ public abstract class DataProcessor<K extends DataKey<K>, V> {
this
.
data
=
new
TreeMap
<>();
// TreeMap to avoid sorting data later
this
.
lastStep
=
0
;
this
.
stopSimBeforeSimFinish
=
false
;
}
...
...
@@ -116,10 +119,13 @@ public abstract class DataProcessor<K extends DataKey<K>, V> {
public
final
void
update
(
final
SimulationState
state
)
{
int
step
=
state
.
getStep
();
if
(
this
.
lastStep
<
step
)
{
if
(
this
.
lastStep
<
step
)
{
this
.
doUpdate
(
state
);
this
.
lastStep
=
step
;
}
// stop simulation if a criteria defined in your data processor is fulfilled
state
.
setSimStop
(
this
.
stopSimBeforeSimFinish
);
}
public
Optional
<
Model
>
getSubModel
(
SimulationState
state
,
Class
clazz
){
...
...
@@ -152,6 +158,10 @@ public abstract class DataProcessor<K extends DataKey<K>, V> {
return
getClass
().
getSimpleName
();
}
public
void
setStopSimBeforeSimFinish
(
boolean
stopSimBeforeSimFinish
)
{
this
.
stopSimBeforeSimFinish
=
stopSimBeforeSimFinish
;
}
@Override
public
String
toString
()
{
return
id
+
": "
+
getSimpleProcessorTypeName
();
...
...
VadereSimulator/src/org/vadere/simulator/projects/dataprocessing/processor/PedStimulusCountingProcessor.java
View file @
bbd98c0b
...
...
@@ -21,9 +21,6 @@ public class PedStimulusCountingProcessor extends DataProcessor<TimestepKey, Inf
private
Predicate
<
Pedestrian
>
filter_by_stimuli
;
private
Pattern
filter_pattern
=
null
;
private
double
stopIfPercentageIsInformed
=
0.95
;
private
int
numberOfAdditionalTimeFrames
=
20
;
private
double
dynamicFinishTime
=
-
1.0
;
private
boolean
dynamicFinishTimeSet
=
false
;
public
PedStimulusCountingProcessor
()
{
super
(
"numberPedsInformed"
,
"numberPedsAll"
,
"percentageInformed"
);
...
...
@@ -43,7 +40,6 @@ public class PedStimulusCountingProcessor extends DataProcessor<TimestepKey, Inf
}
stopIfPercentageIsInformed
=
attr
.
getStopIfPercentageIsInformed
();
numberOfAdditionalTimeFrames
=
attr
.
getNumberOfAdditionalTimeFrames
();
}
...
...
@@ -55,19 +51,11 @@ public class PedStimulusCountingProcessor extends DataProcessor<TimestepKey, Inf
int
numberPedsAll
=
(
int
)
peds
.
stream
().
filter
(
p
->
p
.
getFootstepHistory
().
getFootSteps
().
size
()
>
1
).
count
();
numberPedsAll
=
Math
.
max
(
numberPedsAll
,
numberPedsInformed
);
// test wihtout omnet: if (state.getSimTimeInSec() > 1.0){ numberPedsInformed = numberPedsAll; }
InformationDegree
informationDegree
=
new
InformationDegree
(
numberPedsInformed
,
numberPedsAll
);
// force stop before simulation time defined in json is reached.
if
((!
dynamicFinishTimeSet
)
&&
(
informationDegree
.
getPercentageInformed
()
>=
stopIfPercentageIsInformed
))
{
dynamicFinishTime
=
state
.
getSimTimeInSec
()
+
state
.
getScenarioStore
().
getAttributesSimulation
().
getSimTimeStepLength
()
*
Math
.
max
(
numberOfAdditionalTimeFrames
,
1
);
dynamicFinishTimeSet
=
true
;
}
if
(
dynamicFinishTimeSet
){
state
.
setStopTime
(
dynamicFinishTime
);
if
(
informationDegree
.
getPercentageInformed
()
>=
stopIfPercentageIsInformed
)
{
setStopSimBeforeSimFinish
(
true
);
}
putValue
(
new
TimestepKey
(
state
.
getStep
()),
informationDegree
);
...
...
@@ -92,4 +80,6 @@ public class PedStimulusCountingProcessor extends DataProcessor<TimestepKey, Inf
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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