77
88import org .apache .logging .log4j .LogManager ;
99import org .apache .logging .log4j .Logger ;
10+ import org .eqasim .core .scenario .cutter .extent .ScenarioExtent ;
1011import org .eqasim .core .simulation .vdf .VDFScope ;
1112import org .eqasim .core .simulation .vdf .travel_time .function .VolumeDelayFunction ;
1213import org .matsim .api .core .v01 .Id ;
@@ -27,18 +28,25 @@ public class VDFTravelTime implements TravelTime {
2728
2829 private final Network network ;
2930 private final VolumeDelayFunction vdf ;
31+ private final ScenarioExtent updateAreaExtent ;
3032
3133 private final IdMap <Link , List <Double >> travelTimes = new IdMap <>(Link .class );
3234
3335 private final Logger logger = LogManager .getLogger (VDFTravelTime .class );
3436
35- public VDFTravelTime (VDFScope scope , double minimumSpeed , double capacityFacotor , double samplingRate ,
36- Network network , VolumeDelayFunction vdf , double crossingPenalty ) {
37+ public VDFTravelTime (VDFScope scope , double minimumSpeed , double capacityFactor , double samplingRate ,
38+ Network network , VolumeDelayFunction vdf , double crossingPenalty ) {
39+ this (scope , minimumSpeed , capacityFactor , samplingRate , network , vdf , crossingPenalty , null );
40+ }
41+
42+ public VDFTravelTime (VDFScope scope , double minimumSpeed , double capacityFactor , double samplingRate ,
43+ Network network , VolumeDelayFunction vdf , double crossingPenalty , ScenarioExtent updateAreaExtent ) {
3744 this .scope = scope ;
3845 this .network = network ;
3946 this .vdf = vdf ;
47+ this .updateAreaExtent = updateAreaExtent ;
4048 this .minimumSpeed = minimumSpeed ;
41- this .capacityFactor = capacityFacotor ;
49+ this .capacityFactor = capacityFactor ;
4250 this .samplingRate = samplingRate ;
4351 this .crossingPenalty = crossingPenalty ;
4452
@@ -57,13 +65,32 @@ public double getLinkTravelTime(Link link, double time, Person person, Vehicle v
5765 }
5866
5967 public void update (IdMap <Link , List <Double >> counts ) {
60- logger .info (String .format ("Updating VDFTravelTime ..." ));
68+ update (counts , false );
69+ }
70+
71+ public void update (IdMap <Link , List <Double >> counts , boolean forceUpdateAllLinks ) {
72+ String logMessage = "Updating VDFTravelTime " ;
73+ if (updateAreaExtent != null && !forceUpdateAllLinks ) {
74+ logMessage += " using update extent ..." ;
75+ } else {
76+ logMessage += " ..." ;
77+ }
78+ logger .info (logMessage );
6179
6280 long totalCount = counts .size () * scope .getIntervals ();
6381 long nonFreespeedCount = 0 ;
6482
6583 for (Map .Entry <Id <Link >, List <Double >> entry : counts .entrySet ()) {
6684 Link link = network .getLinks ().get (entry .getKey ());
85+ if (link == null ) {
86+ continue ;
87+ }
88+
89+ if (updateAreaExtent != null && !forceUpdateAllLinks ) {
90+ if (!updateAreaExtent .isInside (link .getFromNode ().getCoord ()) || !updateAreaExtent .isInside (link .getToNode ().getCoord ())) {
91+ continue ;
92+ }
93+ }
6794
6895 List <Double > linkCounts = entry .getValue ();
6996 List <Double > linkTravelTimes = travelTimes .get (entry .getKey ());
0 commit comments