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
c69ac4f8
Commit
c69ac4f8
authored
Jul 31, 2020
by
Christina
Browse files
use maven lib instead of external jar file
parent
36031508
Pipeline
#302160
failed with stages
in 71 minutes and 42 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
VadereSimulator/pom.xml
View file @
c69ac4f8
...
...
@@ -119,14 +119,6 @@
<!-- module dependencies -->
<dependency>
<groupId>
net.sourceforge
</groupId>
<artifactId>
jFuzzyLogic
</artifactId>
<scope>
system
</scope>
<version>
1.0
</version>
<systemPath>
${basedir}/src/libs/jFuzzyLogic.jar
</systemPath>
</dependency>
<dependency>
<groupId>
${project.groupId}
</groupId>
<artifactId>
state
</artifactId>
...
...
VadereSimulator/src/libs/jFuzzyLogic.jar
deleted
100644 → 0
View file @
36031508
File deleted
VadereSimulator/src/org/vadere/simulator/models/strategy/RouteChoiceThreeCorridors.java
View file @
c69ac4f8
package
org.vadere.simulator.models.strategy
;
import
net.sourceforge.jFuzzyLogic.FIS
;
import
com.github.cschen1205.fuzzylogic.FuzzySet
;
import
com.github.cschen1205.fuzzylogic.*
;
import
com.github.cschen1205.fuzzylogic.memberships.*
;
import
org.vadere.simulator.control.strategy.models.navigation.INavigationModel
;
import
org.vadere.simulator.projects.dataprocessing.ProcessorManager
;
import
org.vadere.state.scenario.Pedestrian
;
...
...
@@ -8,17 +10,79 @@ import org.vadere.state.scenario.Pedestrian;
import
java.util.*
;
import
java.util.stream.Collectors
;
// https://github.com/cschen1205/java-fuzzy-logic
public
class
RouteChoiceThreeCorridors
implements
INavigationModel
{
private
FIS
fis
;
private
RuleInferenceEngine
rie
;
private
FuzzySet
corridor
;
private
FuzzySet
density
;
private
FuzzySet
density1
;
private
FuzzySet
density2
;
private
FuzzySet
density3
;
@Override
public
void
initialize
(
double
simTimeInSec
)
{
// load FuzzyControllLanguage file which stores the logic of the controller (heuristics)
String
fileName
=
"/home/christina/repos/vadere/VadereSimulator/src/org/vadere/simulator/models/strategy/fcl/tipper.fcl"
;
this
.
fis
=
FIS
.
load
(
fileName
,
true
);
// Load from 'FCL' file
this
.
rie
=
new
RuleInferenceEngine
();
double
dX
=
0.05
;
corridor
=
new
FuzzySet
(
"corridor"
,
2001
,
2004
,
dX
);
corridor
.
addMembership
(
"use3"
,
new
FuzzyReverseGrade
(
2001
,
2002
));
corridor
.
addMembership
(
"use2"
,
new
FuzzyTriangle
(
2001
,
2002
,
2003
));
corridor
.
addMembership
(
"use1"
,
new
FuzzyTriangle
(
2002
,
2003
,
2004
));
corridor
.
addMembership
(
"wait"
,
new
FuzzyGrade
(
2003
,
2004
));
rie
.
addFuzzySet
(
corridor
.
getName
(),
corridor
);
density
=
new
FuzzySet
(
"density"
,
0
,
5
,
dX
);
density
.
addMembership
(
"low"
,
new
FuzzyReverseGrade
(
0
,
0.5
));
density
.
addMembership
(
"high"
,
new
FuzzyGrade
(
0.4
,
5
));
rie
.
addFuzzySet
(
density
.
getName
(),
density
);
density1
=
new
FuzzySet
(
"density1"
,
0
,
5
,
dX
);
density1
.
addMembership
(
"low"
,
new
FuzzyReverseGrade
(
0
,
0.25
));
density1
.
addMembership
(
"high"
,
new
FuzzyGrade
(
0.2
,
5
));
rie
.
addFuzzySet
(
density1
.
getName
(),
density1
);
// density2 = new FuzzySet("density2", -4, 4, 0.05);
// density2.addMembership("low", new FuzzyReverseGrade(0, 0.25));
// density2.addMembership("high", new FuzzyGrade(0.2, 5));
// rie.addFuzzySet(density2.getName(), density2);
//
// density3 = new FuzzySet("density3", -4, 4, 0.05);
// density3.addMembership("low", new FuzzyReverseGrade(0, 0.25));
// density3.addMembership("high", new FuzzyGrade(0.2, 5));
// rie.addFuzzySet(density3.getName(), density3);
//
Rule
rule
=
new
Rule
(
"Rule 1"
);
rule
.
addAntecedent
(
new
Clause
(
density
,
"Is"
,
"low"
));
rule
.
addAntecedent
(
new
Clause
(
density1
,
"Is"
,
"low"
));
rule
.
setConsequent
(
new
Clause
(
corridor
,
"Is"
,
"use1"
));
rie
.
addRule
(
rule
);
Rule
rule2
=
new
Rule
(
"Rule 2"
);
rule2
.
addAntecedent
(
new
Clause
(
density
,
"Is"
,
"high"
));
rule2
.
addAntecedent
(
new
Clause
(
density1
,
"Is"
,
"low"
));
rule2
.
setConsequent
(
new
Clause
(
corridor
,
"Is"
,
"use3"
));
rie
.
addRule
(
rule2
);
Rule
rule3
=
new
Rule
(
"Rule 3"
);
rule3
.
addAntecedent
(
new
Clause
(
density
,
"Is"
,
"high"
));
rule3
.
addAntecedent
(
new
Clause
(
density1
,
"Is"
,
"high"
));
rule3
.
setConsequent
(
new
Clause
(
corridor
,
"Is"
,
"wait"
));
rie
.
addRule
(
rule3
);
Rule
rule4
=
new
Rule
(
"Rule 4"
);
rule4
.
addAntecedent
(
new
Clause
(
density
,
"Is"
,
"low"
));
rule4
.
addAntecedent
(
new
Clause
(
density1
,
"Is"
,
"high"
));
rule4
.
setConsequent
(
new
Clause
(
corridor
,
"Is"
,
"use3"
));
rie
.
addRule
(
rule4
);
}
...
...
@@ -28,21 +92,37 @@ public class RouteChoiceThreeCorridors implements INavigationModel {
if
(
simTimeInSec
>
0.0
)
{
// System.out.println(simTimeInSec);
double
densityCor1
=
getDensityFromDataProcessor
(
5
,
processorManager
);
double
densityCor2
=
getDensityFromDataProcessor
(
6
,
processorManager
);
double
densityCor3
=
getDensityFromDataProcessor
(
7
,
processorManager
);
double
density
=
getDensityFromDataProcessor
(
8
,
processorManager
);
double
densityC0
=
getDensityFromDataProcessor
(
8
,
processorManager
);
double
densityC1
=
getDensityFromDataProcessor
(
5
,
processorManager
);
double
densityC2
=
getDensityFromDataProcessor
(
6
,
processorManager
);
double
densityC3
=
getDensityFromDataProcessor
(
7
,
processorManager
);
density
.
setX
(
densityC0
);
density1
.
setX
(
densityC1
);
//density2.setX(densityC2);
//density3.setX(densityC3);
rie
.
Infer
(
corridor
);
double
targetD
=
corridor
.
getX
();
int
target
;
if
(
Double
.
isNaN
(
targetD
))
{
target
=
2002
;
}
else
{
target
=
(
int
)
Math
.
round
(
targetD
);
}
LinkedList
<
Integer
>
nextTargets
=
new
LinkedList
<
Integer
>();
int
target
=
getTargetFromFuzzyController
(
density
,
densityCor1
,
densityCor2
,
densityCor3
);
nextTargets
.
add
(
target
);
if
(
target
==
2004
)
{
nextTargets
.
add
(
2001
);
}
nextTargets
.
add
(
1
);
// System.out.println(simTimeInSec + " " + nextTargets + " \n");
List
<
Pedestrian
>
newAgents
=
pedestrians
.
stream
().
filter
(
p
->
p
.
getFootstepHistory
().
getFootSteps
().
size
()
==
0
).
collect
(
Collectors
.
toList
());
for
(
Pedestrian
pedestrian
:
newAgents
)
{
pedestrian
.
setTargets
(
nextTargets
);
...
...
@@ -52,26 +132,10 @@ public class RouteChoiceThreeCorridors implements INavigationModel {
}
private
int
getTargetFromFuzzyController
(
double
density
,
double
densityCor1
,
double
densityCor2
,
double
densityCor3
)
{
fis
.
setVariable
(
"density"
,
density
);
// Set inputs
fis
.
setVariable
(
"densityCor1"
,
densityCor3
);
fis
.
setVariable
(
"densityCor2"
,
densityCor2
);
fis
.
setVariable
(
"densityCor3"
,
densityCor1
);
fis
.
evaluate
();
// Evaluate
double
corridor
=
fis
.
getVariable
(
"corridor"
).
getValue
();
int
result
=
(
int
)
Math
.
round
(
corridor
);
//System.out.println("Densities: " + density + " " + densityCor1 + " " + densityCor2 +" " + densityCor3); // Show output variable
//System.out.println("Output value:" + corridor + ", rounded :" + result); // Show output variable
// Show each rule (and degree of support)
//for( Rule r : fis.getFunctionBlock("streamControl").getFuzzyRuleBlock("No1").getRules() ) System.out.println(r);
return
result
;
}
private
double
getDensityFromDataProcessor
(
int
processorId
,
ProcessorManager
processorManager
)
{
...
...
VadereSimulator/src/org/vadere/simulator/models/strategy/fcl/tipper.fcl
deleted
100644 → 0
View file @
36031508
/*
Example: A tip calculation FIS (fuzzy inference system)
Calculates tip based on 'servie' and 'food'
If you want to about this example (and fuzzy logic), please
read Matlab's tutorial on fuzzy logic toolbox
http://www.mathworks.com/access/helpdesk/help/pdf_doc/fuzzy/fuzzy.pdf
Pablo Cingolani
pcingola@users.sourceforge.net
*/
FUNCTION_BLOCK streamControl // Block definition (there may be more than one block per file)
VAR_INPUT // Define input variables
density : REAL;
densityCor1 : REAL;
densityCor2 : REAL;
densityCor3 : REAL;
END_VAR
VAR_OUTPUT // Define output variable
corridor : REAL;
END_VAR
FUZZIFY density
TERM low := (0, 1) (0.5, 0) ;
TERM high := (0.4, 0) (5.5,1);
END_FUZZIFY
FUZZIFY densityCor1
TERM low := (0, 1) (0.25, 0) ;
TERM high := (0.2, 0) (4.5, 1);
END_FUZZIFY
FUZZIFY densityCor2
TERM low := (0, 1) (0.25, 0) ;
TERM high := (0.2, 0) (4.5, 1);
END_FUZZIFY
FUZZIFY densityCor3
TERM low := (0, 1) (0.25, 0) ;
TERM high := (0.2, 0) (4.5, 1);
END_FUZZIFY
DEFUZZIFY corridor //
TERM use3 := (2000,0) (2001,1) (2002,0);
TERM use2 := (2001,0) (2002,1) (2003,0);
TERM use1 := (2002,0) (2003,1) (2004,0);
TERM sendAway := (2003,0) (2004,1) (2005,0);
METHOD : COG; // Use 'Center Of Gravity' defuzzification method
DEFAULT := 2004; // Default value is 0 (if no rule activates defuzzifier)
END_DEFUZZIFY
RULEBLOCK No1
AND : MIN; // Use 'min' for 'and' (also implicit use 'max' for 'or' to fulfill DeMorgan's Law)
ACT : MIN; // Use 'min' activation method
ACCU : MAX; // Use 'max' accumulation method
RULE 1 : If density IS low AND densityCor1 IS low AND densityCor2 is low AND densityCor3 IS low THEN corridor is use1;
RULE 2 : If density IS low AND densityCor1 IS high AND densityCor2 is low AND densityCor3 IS low THEN corridor is use2;
RULE 3 : If density IS low AND densityCor1 IS high AND densityCor2 is high AND densityCor3 IS low THEN corridor is use3;
RULE 4 : If density IS low AND densityCor1 IS high AND densityCor2 is high AND densityCor3 IS high THEN corridor is sendAway;
RULE 5 : If density IS high AND densityCor1 IS low AND densityCor2 is low AND densityCor3 IS low THEN corridor is use3;
RULE 6 : If density IS high AND densityCor1 IS high AND densityCor2 is low AND densityCor3 IS low THEN corridor is use3;
RULE 7 : If density IS high AND densityCor1 IS high AND densityCor2 is high AND densityCor3 IS low THEN corridor is use3;
RULE 8 : If density IS high AND densityCor1 IS high AND densityCor2 is high AND densityCor3 IS high THEN corridor is sendAway;
END_RULEBLOCK
END_FUNCTION_BLOCK
pom.xml
View file @
c69ac4f8
...
...
@@ -135,6 +135,12 @@
<!-- <version>1.2.1</version>-->
<!-- </dependency>-->
<dependency>
<groupId>
com.github.cschen1205
</groupId>
<artifactId>
java-fuzzy-logic
</artifactId>
<version>
1.0.1
</version>
</dependency>
<dependency>
<groupId>
com.google.guava
</groupId>
<artifactId>
guava
</artifactId>
...
...
Write
Preview
Supports
Markdown
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