Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
vadere
vadere
Commits
b8b9ceb7
Commit
b8b9ceb7
authored
Aug 26, 2020
by
Christina
Browse files
use strategyLayer
parent
55f3dd9e
Pipeline
#313319
passed with stages
in 134 minutes and 35 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Scenarios/Demos/Density_controller/scenarios/TwoCorridors_forced_controller.scenario
View file @
b8b9ceb7
...
...
@@ -88,14 +88,6 @@
"edgeLength" : 1.5,
"displayMesh" : false
}
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.ReadAndSetControllerInput",
"id" : 11,
"attributesType" : "org.vadere.state.attributes.processor.AttributesReadAndSetControllerInput",
"attributes" : {
"controllerInputFile" : "Scenarios/Demos/Density_controller/scenarios/TwoCorridors_forced_controller_input.csv",
"useFile" : true
}
} ],
"isTimestamped" : true,
"isWriteMetaData" : false
...
...
@@ -176,8 +168,8 @@
}
},
"attributesStrategy" : {
"useStrategyModel" :
fals
e,
"strategyModel" : "R
outeChoiceThreeCorridor
s"
"useStrategyModel" :
tru
e,
"strategyModel" : "R
eadSetControllerInput
s"
},
"topography" : {
"attributes" : {
...
...
VadereSimulator/src/org/vadere/simulator/models/strategy/ReadSetControllerInputs.java
0 → 100644
View file @
b8b9ceb7
package
org.vadere.simulator.models.strategy
;
import
com.github.cschen1205.fuzzylogic.Clause
;
import
com.github.cschen1205.fuzzylogic.FuzzySet
;
import
com.github.cschen1205.fuzzylogic.Rule
;
import
com.github.cschen1205.fuzzylogic.RuleInferenceEngine
;
import
com.github.cschen1205.fuzzylogic.memberships.FuzzyGrade
;
import
com.github.cschen1205.fuzzylogic.memberships.FuzzyReverseGrade
;
import
com.github.cschen1205.fuzzylogic.memberships.FuzzyTriangle
;
import
org.vadere.simulator.control.strategy.models.navigation.INavigationModel
;
import
org.vadere.simulator.projects.dataprocessing.ProcessorManager
;
import
org.vadere.simulator.projects.dataprocessing.processor.AreaDensityCountingProcessor
;
import
org.vadere.state.scenario.Pedestrian
;
import
java.io.IOException
;
import
java.nio.file.Files
;
import
java.nio.file.Paths
;
import
java.util.*
;
import
java.util.stream.Collectors
;
// https://github.com/cschen1205/java-fuzzy-logic
public
class
ReadSetControllerInputs
implements
INavigationModel
{
private
double
[][]
controllerInputs
;
private
int
counter
=
0
;
@Override
public
void
initialize
(
double
simTimeInSec
)
{
String
fileName
=
"Scenarios/Demos/Density_controller/scenarios/TwoCorridors_forced_controller_input.csv"
;
try
{
this
.
controllerInputs
=
Files
.
lines
(
Paths
.
get
(
fileName
)).
map
(
s
->
s
.
split
(
" "
)).
map
(
s
->
Arrays
.
stream
(
s
).
mapToDouble
(
Double:
:
parseDouble
).
toArray
()).
toArray
(
double
[][]::
new
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
System
.
out
.
println
(
this
.
controllerInputs
[
0
][
0
]
);
}
public
void
update
(
double
simTimeInSec
,
Collection
<
Pedestrian
>
pedestrians
,
ProcessorManager
processorManager
)
{
double
percentageLeft
=
controllerInputs
[
counter
][
1
];
List
<
Pedestrian
>
newAgents
=
pedestrians
.
stream
().
filter
(
p
->
p
.
getFootstepHistory
().
getFootSteps
().
size
()
==
0
).
collect
(
Collectors
.
toList
());
int
numberLeft
=
(
int
)
(
newAgents
.
size
()*
percentageLeft
);
int
numberRight
=
newAgents
.
size
()
-
numberLeft
;
LinkedList
<
Integer
>
targets
=
new
LinkedList
<
Integer
>();
for
(
int
i
=
0
;
i
<
numberLeft
;
i
++)
{
targets
.
add
(
2001
);
}
for
(
int
i
=
0
;
i
<
numberRight
;
i
++)
{
targets
.
add
(
2002
);
}
int
c
=
0
;
for
(
Pedestrian
pedestrian
:
newAgents
)
{
LinkedList
<
Integer
>
nextTargets
=
new
LinkedList
<
Integer
>();
nextTargets
.
add
(
targets
.
get
(
c
));
nextTargets
.
add
(
1
);
pedestrian
.
setTargets
(
nextTargets
);
c
+=
1
;
}
counter
+=
1
;
}
}
VadereSimulator/src/org/vadere/simulator/projects/dataprocessing/processor/ReadAndSetControllerInput.java
deleted
100644 → 0
View file @
55f3dd9e
package
org.vadere.simulator.projects.dataprocessing.processor
;
import
org.vadere.annotation.factories.dataprocessors.DataProcessorClass
;
import
org.vadere.simulator.control.simulation.SimulationState
;
import
org.vadere.simulator.projects.dataprocessing.datakey.TimestepKey
;
import
org.vadere.state.attributes.processor.AttributesReadAndSetControllerInput
;
import
java.io.IOException
;
import
java.nio.file.Files
;
import
java.nio.file.Paths
;
import
java.util.Arrays
;
/**
* @author Christina Mayr
* reads and sets controller input defined in an external file
*/
@DataProcessorClass
()
public
class
ReadAndSetControllerInput
extends
DataProcessor
<
TimestepKey
,
Double
>
{
private
double
[][]
controllerInputs
;
public
ReadAndSetControllerInput
()
{
super
(
"percentageLeftRealized"
);
setAttributes
(
new
AttributesReadAndSetControllerInput
());
}
@Override
public
void
preLoop
(
SimulationState
state
)
{
String
fileName
=
getAttributes
().
getControllerInputFile
();
// fileName = "Scenarios/Demos/Density_controller/scenarios/TwoCorridors_forced_controller_input.csv";
try
{
this
.
controllerInputs
=
Files
.
lines
(
Paths
.
get
(
fileName
)).
map
(
s
->
s
.
split
(
" "
)).
map
(
s
->
Arrays
.
stream
(
s
).
mapToDouble
(
Double:
:
parseDouble
).
toArray
()).
toArray
(
double
[][]::
new
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
System
.
out
.
println
(
this
.
controllerInputs
[
0
][
0
]
);
int
i
=
0
;
}
@Override
protected
void
doUpdate
(
SimulationState
state
)
{
}
@Override
public
AttributesReadAndSetControllerInput
getAttributes
()
{
if
(
super
.
getAttributes
()
==
null
)
{
setAttributes
(
new
AttributesReadAndSetControllerInput
());
}
return
(
AttributesReadAndSetControllerInput
)
super
.
getAttributes
();
}
}
VadereState/src/org/vadere/state/attributes/processor/AttributesReadAndSetControllerInput.java
deleted
100644 → 0
View file @
55f3dd9e
package
org.vadere.state.attributes.processor
;
public
class
AttributesReadAndSetControllerInput
extends
AttributesProcessor
{
private
String
controllerInputFile
=
null
;
private
boolean
useFile
=
false
;
public
String
getControllerInputFile
()
{
return
controllerInputFile
;
}
public
void
setControllerInputFile
(
String
controllerInputFile
)
{
this
.
controllerInputFile
=
controllerInputFile
;
}
public
boolean
isUseFile
()
{
return
useFile
;
}
public
void
setUseFile
(
boolean
useFile
)
{
this
.
useFile
=
useFile
;
}
}
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