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
9950c9b5
Commit
9950c9b5
authored
Nov 27, 2018
by
Benedikt Zoennchen
Browse files
update PSO tests so they dont fail the evacuation test.
parent
e9d20529
Pipeline
#77378
failed with stages
in 101 minutes and 34 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
VadereModelTests/TestOSM/scenarios/rimea_09_public_room_2_exits_pso.scenario
View file @
9950c9b5
...
@@ -88,7 +88,7 @@
...
@@ -88,7 +88,7 @@
},
},
"org.vadere.state.attributes.models.AttributesOSM" : {
"org.vadere.state.attributes.models.AttributesOSM" : {
"stepCircleResolution" : 18,
"stepCircleResolution" : 18,
"numberOfCircles" :
1
,
"numberOfCircles" :
3
,
"varyStepDirection" : false,
"varyStepDirection" : false,
"stepLengthIntercept" : 0.4625,
"stepLengthIntercept" : 0.4625,
"stepLengthSlopeSpeed" : 0.2345,
"stepLengthSlopeSpeed" : 0.2345,
...
...
VadereModelTests/TestOSM/scenarios/rimea_09_public_room_4_exits_pso.scenario
View file @
9950c9b5
...
@@ -88,7 +88,7 @@
...
@@ -88,7 +88,7 @@
},
},
"org.vadere.state.attributes.models.AttributesOSM" : {
"org.vadere.state.attributes.models.AttributesOSM" : {
"stepCircleResolution" : 18,
"stepCircleResolution" : 18,
"numberOfCircles" :
1
,
"numberOfCircles" :
3
,
"varyStepDirection" : false,
"varyStepDirection" : false,
"stepLengthIntercept" : 0.4625,
"stepLengthIntercept" : 0.4625,
"stepLengthSlopeSpeed" : 0.2345,
"stepLengthSlopeSpeed" : 0.2345,
...
...
VadereUtils/src/org/vadere/util/math/pso/AttributesPSO.java
View file @
9950c9b5
...
@@ -6,7 +6,9 @@ package org.vadere.util.math.pso;
...
@@ -6,7 +6,9 @@ package org.vadere.util.math.pso;
public
class
AttributesPSO
{
public
class
AttributesPSO
{
final
int
numberOfInformedParticles
=
3
;
final
int
numberOfInformedParticles
=
3
;
final
int
swarmSize
=
30
;
final
int
swarmSize
=
30
;
final
int
maxIteration
=
15
;
final
int
minIteration
=
4
;
final
int
maxNoUpdate
=
6
;
final
int
maxIteration
=
10
;
final
int
problemDimension
=
2
;
final
int
problemDimension
=
2
;
final
double
c1
=
2.0
;
final
double
c1
=
2.0
;
final
double
c2
=
2.0
;
final
double
c2
=
2.0
;
...
...
VadereUtils/src/org/vadere/util/math/pso/PSO.java
View file @
9950c9b5
...
@@ -19,12 +19,14 @@ public class PSO {
...
@@ -19,12 +19,14 @@ public class PSO {
private
final
ICircleSector
circle
;
private
final
ICircleSector
circle
;
private
final
double
errorToleranz
=
0.0001
;
private
final
double
errorToleranz
=
0.0001
;
private
double
gBest
;
private
double
gBest
;
private
double
gLastBest
;
private
VPoint
gBestLocation
;
private
VPoint
gBestLocation
;
private
final
Function
<
VPoint
,
Double
>
f
;
private
final
Function
<
VPoint
,
Double
>
f
;
private
int
iterationCounter
;
private
int
iterationCounter
;
private
final
double
maxVelocity
;
private
final
double
maxVelocity
;
private
final
double
minAngle
;
private
final
double
minAngle
;
private
final
double
maxAngle
;
private
final
double
maxAngle
;
private
int
improvementIterations
;
public
PSO
(
public
PSO
(
@NotNull
final
Function
<
VPoint
,
Double
>
f
,
@NotNull
final
Function
<
VPoint
,
Double
>
f
,
...
@@ -44,6 +46,7 @@ public class PSO {
...
@@ -44,6 +46,7 @@ public class PSO {
this
.
minAngle
=
minAngle
;
this
.
minAngle
=
minAngle
;
this
.
maxAngle
=
maxAngle
;
this
.
maxAngle
=
maxAngle
;
this
.
particles
=
initialSwarm
(
swarmPositions
);
this
.
particles
=
initialSwarm
(
swarmPositions
);
this
.
improvementIterations
=
0
;
}
}
public
VPoint
getOptimumArg
()
{
public
VPoint
getOptimumArg
()
{
...
@@ -69,20 +72,21 @@ public class PSO {
...
@@ -69,20 +72,21 @@ public class PSO {
}
}
public
boolean
hasFinished
()
{
public
boolean
hasFinished
()
{
return
iterationCounter
>=
attributesPSO
.
maxIteration
||
hasConverged
();
return
iterationCounter
>=
attributesPSO
.
maxIteration
||
(
iterationCounter
>=
attributesPSO
.
minIteration
&&
hasConverged
()
)
;
}
}
public
boolean
hasConverged
()
{
public
boolean
hasConverged
()
{
return
fals
e
;
return
improvementIterations
>=
attributesPSO
.
maxNoUpdat
e
;
}
}
public
void
update
()
{
public
void
update
()
{
if
(
iterationCounter
<
attributesPSO
.
maxIteration
)
{
if
(
!
hasFinished
()
)
{
iterationCounter
++;
iterationCounter
++;
updateLocalBest
();
updateLocalBest
();
updateGlobalBest
();
updateGlobalBest
();
double
omega
=
attributesPSO
.
wUpperBound
-
(
iterationCounter
/
attributesPSO
.
maxIteration
)
*
(
attributesPSO
.
wUpperBound
-
attributesPSO
.
wLowerBound
);
double
omega
=
attributesPSO
.
wUpperBound
-
(
iterationCounter
/
attributesPSO
.
minIteration
)
*
(
attributesPSO
.
wUpperBound
-
attributesPSO
.
wLowerBound
);
particles
.
forEach
(
particle
->
updateParticle
(
particle
,
omega
));
particles
.
forEach
(
particle
->
updateParticle
(
particle
,
omega
));
}
}
}
}
...
@@ -134,7 +138,7 @@ public class PSO {
...
@@ -134,7 +138,7 @@ public class PSO {
* than the old one, particles inform each other about their best values and locations.
* than the old one, particles inform each other about their best values and locations.
*/
*/
private
void
updateGlobalBest
()
{
private
void
updateGlobalBest
()
{
double
l
ast
G
Best
=
gBest
;
gL
astBest
=
gBest
;
for
(
Particle
particle
:
particles
)
{
for
(
Particle
particle
:
particles
)
{
double
globalBest
=
particle
.
getGlobalBestFitnessValue
();
double
globalBest
=
particle
.
getGlobalBestFitnessValue
();
...
@@ -144,7 +148,16 @@ public class PSO {
...
@@ -144,7 +148,16 @@ public class PSO {
}
}
}
}
if
(
gBest
>=
lastGBest
)
{
// no or small improvement
if
(
gBest
>=
gLastBest
||
Math
.
abs
(
gBest
-
gLastBest
)
<
0.001
)
{
improvementIterations
++;
}
else
{
improvementIterations
=
0
;
}
// no global improvement
if
(
gBest
>=
gLastBest
)
{
informKParticle
();
informKParticle
();
}
}
}
}
...
...
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