-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LinkTravelTimeContainer: Change internal representation (#813)
* Use mutable collection and change format to be `Map[Id[Link], Array[Double]]` * Whenever is needed use `TravelTimeCalculatorConfigGroup.getMaxTime()` to get max time for iteration: - Warm start - PhyssimCalcLinkStats - BeamCalcLinkStats - LinkTravelTimeContainer * Merge remote-tracking branch 'origin/master' into art/reduce-memory-consumption-for-link-traveltime-container-4ci * Fix after merge * Added `VolumesAnalyzerFixed` which respects `maxTime` * Update BeamCalcLinkStatsSpec.scala * Merge remote-tracking branch 'origin/master' into art/reduce-memory-consumption-for-link-traveltime-container-4ci * Fixed failing test * Dummy commit
- Loading branch information
1 parent
3381c5b
commit 672c46d
Showing
15 changed files
with
157 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package beam.utils; | ||
|
||
import org.apache.log4j.Logger; | ||
import org.matsim.analysis.VolumesAnalyzer; | ||
import org.matsim.api.core.v01.Id; | ||
import org.matsim.api.core.v01.network.Link; | ||
import org.matsim.api.core.v01.network.Network; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
|
||
public class VolumesAnalyzerFixed extends VolumesAnalyzer { | ||
private final static Logger log = Logger.getLogger(VolumesAnalyzerFixed.class); | ||
|
||
private final int timeBinSize; | ||
private final int maxTime; | ||
private final int maxSlotIndex; | ||
private final int maxHour; | ||
|
||
public VolumesAnalyzerFixed(int timeBinSize, int maxTime, Network network) { | ||
super(timeBinSize, maxTime, network); | ||
this.timeBinSize = timeBinSize; | ||
this.maxTime = maxTime; | ||
this.maxSlotIndex = (this.maxTime / this.timeBinSize) + 1; | ||
this.maxHour = (int)TimeUnit.SECONDS.toHours(this.maxTime + 1); | ||
} | ||
@Override | ||
public double[] getVolumesPerHourForLink(final Id<Link> linkId) { | ||
if (3600.0 % this.timeBinSize != 0) log.error("Volumes per hour and per link probably not correct!"); | ||
|
||
double[] volumes = new double[this.maxHour]; | ||
|
||
int[] volumesForLink = this.getVolumesForLink(linkId); | ||
if (volumesForLink == null) return volumes; | ||
|
||
int slotsPerHour = (int)(3600.0 / this.timeBinSize); | ||
for (int hour = 0; hour < this.maxHour; hour++) { | ||
double time = hour * 3600.0; | ||
for (int i = 0; i < slotsPerHour; i++) { | ||
volumes[hour] += volumesForLink[this.getTimeSlotIndex(time)]; | ||
time += this.timeBinSize; | ||
} | ||
} | ||
return volumes; | ||
} | ||
|
||
private int getTimeSlotIndex(final double time) { | ||
if (time > this.maxTime) { | ||
return this.maxSlotIndex; | ||
} | ||
return ((int)time / this.timeBinSize); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.