Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DRT Accessibility #3626

Draft
wants to merge 30 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
8e7d1c3
wip, cherrypick from drtAccessibility branch
jakobrehmann May 15, 2024
2059f9c
updated drt accessibility calculations to be stop-based.
jakobrehmann May 17, 2024
8fa3bc4
added comments
jakobrehmann May 23, 2024
ed1a1a6
make an internal method private
kainagel Jun 12, 2024
e8431c4
wip
jakobrehmann Jun 14, 2024
84235c6
updated esimation of params for DRT Estimator to be based on travelDi…
jakobrehmann Jul 30, 2024
a36b398
reset pt accessibility such that it checks the walk distance.
jakobrehmann Aug 20, 2024
0abcb21
updated pt accessibility to update use walk's ASC if pt isn't in fact…
jakobrehmann Aug 27, 2024
f99bba9
updated pt accessibility to update use walk's ASC if pt isn't in fact…
jakobrehmann Sep 10, 2024
3f36d0b
fixed conflicting changes
jakobrehmann Sep 10, 2024
526548f
added todos, refactored, added detour factors to access/egress walks
jakobrehmann Sep 25, 2024
b67058a
cleanup
jakobrehmann Sep 25, 2024
a15e215
added todo
jakobrehmann Sep 25, 2024
c3fb8f7
trying to fix TinyAccessibilibyTest for drt. Making some steps forwa…
kainagel Sep 25, 2024
e46ccd9
added potential plug-in points for DRT Estimator as comments
jakobrehmann Oct 9, 2024
ed447e4
added integration test for estimatedDRT accessibility calculation
jakobrehmann Oct 9, 2024
5ad80e6
commented out unfinished offline drt accessibility test
jakobrehmann Oct 9, 2024
b584354
Merge branch 'master' into drtAccessibility-merge-with-master
jakobrehmann Oct 9, 2024
2355757
updated version
jakobrehmann Oct 9, 2024
69c636a
integrated DRT Estimator into DRT Accessibility calculations
jakobrehmann Oct 9, 2024
64d3b55
tryout
kainagel Oct 10, 2024
efb7935
some changes
kainagel Oct 10, 2024
6b374ac
got runFromEventsDrt() to work
jakobrehmann Nov 6, 2024
5c325a3
added events test for congested network, started working on accessibi…
jakobrehmann Nov 6, 2024
254ba80
added StringSetter and StringGetter for computing modes in accessibil…
jakobrehmann Nov 20, 2024
5311040
allow AccessibilityFromEvents to calculate accessibility for multiple…
jakobrehmann Nov 20, 2024
29c584f
created accessibility dashboard and analysis scripts.
jakobrehmann Nov 20, 2024
5df0d3d
removed stopFinder access
jakobrehmann Nov 20, 2024
34adc6c
added comments
jakobrehmann Dec 3, 2024
ce4f0c5
Merge pull request #3622 from matsim-org/master
jakobrehmann Dec 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions contribs/accessibility/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,17 @@
<artifactId>gt-jdbc-postgis</artifactId>
<version>${geotools.version}</version>
</dependency>
<dependency>
<groupId>org.matsim.contrib</groupId>
<artifactId>dvrp</artifactId>
<version>2025.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.matsim.contrib</groupId>
<artifactId>drt</artifactId>
<version>2025.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ public void notifyShutdown(ShutdownEvent event) {
if (event.isUnexpected()) {
return;
}
// // consider refactoring the rest of this class into the method process and call this from the simwrapper (see kelheim emissions dashboard)

// process();
// }
//
// public void process() {
LOG.info("Initializing accessibility computation...");
accessibilityAggregator = new AccessibilityAggregator();
addFacilityDataExchangeListener(accessibilityAggregator);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@
package org.matsim.contrib.accessibility;

import java.util.*;
import java.util.stream.Collectors;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.matsim.api.core.v01.Id;
import org.matsim.core.config.ReflectiveConfigGroup;
import org.matsim.core.utils.collections.CollectionUtils;
import org.matsim.facilities.ActivityFacilities;
import org.matsim.facilities.ActivityFacility;

Expand All @@ -35,8 +37,9 @@
* @author thomas, nagel, dziemke
*/
public final class AccessibilityConfigGroup extends ReflectiveConfigGroup{
// yyyy todo: change in similar way as with other modes ("_mode")

// yyyy todo: change in similar way as with other modes ("_mode")

private static final String COMPUTING_MODES = "computingModes";
private static final String USING_CUSTOM_BOUNDING_BOX = "usingCustomBoundingBox";
private static final String BOUNDING_BOX_TOP = "boundingBoxTop";
private static final String BOUNDING_BOX_BOTTOM = "boundingBoxBottom";
Expand All @@ -47,43 +50,52 @@ public final class AccessibilityConfigGroup extends ReflectiveConfigGroup{
private static final Logger LOG = LogManager.getLogger(AccessibilityConfigGroup.class);

public static final String GROUP_NAME = "accessibility";

private static final String ACCESSIBILITY_MEASURE_TYPE = "accessibilityMeasureType";
public static enum AccessibilityMeasureType{logSum, rawSum, gravity}
private AccessibilityMeasureType accessibilityMeasureType = AccessibilityMeasureType.logSum;

private static final String USE_OPPORTUNITY_WEIGHTS = "useOpportunityWeights";
private boolean useOpportunityWeights = false;
private static final String WEIGHT_EXPONENT = "weightExponent";
private Double weightExponent = 1.;

private static final String USE_PARALLELIZATION = "useParallelization";
private boolean useParallelization = true;

// private static final String ACCESSIBILITY_DESTINATION_SAMPLING_RATE = "accessibilityDestinationSamplingRate";
// private Double accessibilityDestinationSamplingRate;

private static final String MEASURE_POINT_GEOMETRY_PROVISION = "measurePointGeometryProvision";
public static enum MeasurePointGeometryProvision{autoCreate, fromShapeFile}
public static enum MeasurePointGeometryProvision{autoCreate, fromShapeFile}
private MeasurePointGeometryProvision measurePointGeometryProvision = MeasurePointGeometryProvision.autoCreate;

private double boundingBoxTop;
private double boundingBoxLeft;
private double boundingBoxRight;
private double boundingBoxBottom;

private Integer tileSize_m;
private String shapeFileCellBasedAccessibility;
private static final String AREA_OF_ACC_COMP = "areaOfAccessibilityComputation";
public static enum AreaOfAccesssibilityComputation{fromNetwork, fromBoundingBox, fromBoundingBoxHexagons, fromShapeFile, fromFacilitiesFile, fromFacilitiesObject}

private static final String AREA_OF_ACC_COMP = "areaOfAccessibilityComputation";
public static enum AreaOfAccesssibilityComputation{fromNetwork, fromBoundingBox, fromBoundingBoxHexagons, fromShapeFile, fromFacilitiesFile, fromFacilitiesObject}
private AreaOfAccesssibilityComputation areaOfAccessibilityComputation = AreaOfAccesssibilityComputation.fromNetwork;
private Set<Modes4Accessibility> isComputingMode = EnumSet.noneOf(Modes4Accessibility.class);

private String outputCrs = null;
private static final String OUTPUT_CRS="outputCRS";


@StringSetter(COMPUTING_MODES)
private void setComputingModes(String value) {
isComputingMode = Arrays.stream(value.split(",")).map(String::trim).map(Modes4Accessibility::valueOf).collect(Collectors.toSet());
}
@StringGetter(COMPUTING_MODES)
private String getComputingModesAsString() {

return CollectionUtils.setToString(isComputingMode.stream().map(Enum::toString).collect(Collectors.toSet()));
}

@StringGetter(OUTPUT_CRS)
public final String getOutputCrs() {
return this.outputCrs;
Expand All @@ -95,17 +107,17 @@ public final void setOutputCrs(String outputCrs) {

private String measuringPointsFile;
private static final String MEASURING_POINTS_FILE="measuringPointsFile";

@StringGetter(MEASURING_POINTS_FILE)
public String getMeasuringPointsFile(){
return this.measuringPointsFile;
}

@StringSetter(MEASURING_POINTS_FILE)
public void setMeasuringPointsFile(String measuringPointsFile){
this.measuringPointsFile = measuringPointsFile;
}

// Optional; only used if measuring points are set directly
private ActivityFacilities measuringPointsFacilities;
private Map<Id<ActivityFacility>, Geometry> measurePointGeometryMap;
Expand All @@ -117,39 +129,40 @@ public AccessibilityConfigGroup() {
super(GROUP_NAME);
isComputingMode.add(Modes4Accessibility.freespeed);
}

@Override
public Map<String,String> getComments() {
Map<String,String> map = new TreeMap<>() ;

map.put(TIME_OF_DAY, "time of day at which trips for accessibility computations are assumed to start");

// map.put(ACCESSIBILITY_DESTINATION_SAMPLING_RATE, "if only a sample of destinations should be used " +
// "(reduces accuracy -- not recommended except when necessary for computational speed reasons)");

map.put(ACCESSIBILITY_MEASURE_TYPE, "defines type of measure for accessibility computation.");

map.put(USING_CUSTOM_BOUNDING_BOX, "true if custom bounding box should be used for accessibility computation (otherwise e.g. extent of network will be used)");
map.put(BOUNDING_BOX_BOTTOM,"custom bounding box parameters for accessibility computation (if enabled)");

StringBuilder stb = new StringBuilder() ;
for (AreaOfAccesssibilityComputation val : AreaOfAccesssibilityComputation.values()) {
stb.append(val.toString() ) ;
stb.append( " " ) ;
}
map.put(AREA_OF_ACC_COMP, "method to determine the area for which the accessibility will be computed; possible values: " + stb);

map.put(MEASURING_POINTS_FILE, "if the accibility is computed using the `fromFile` option, " +
"the this must be the file containing the measuring points' coordinates. ");
return map ;
}
public void setComputingAccessibilityForMode(Modes4Accessibility mode, boolean val) {

public AccessibilityConfigGroup setComputingAccessibilityForMode( Modes4Accessibility mode, boolean val ) {
if (val) {
this.isComputingMode.add(mode);
} else {
this.isComputingMode.remove(mode);
}
return this;
}

public Set<Modes4Accessibility> getIsComputingMode() {
Expand All @@ -163,15 +176,15 @@ public Set<String> getModes() {
return result ;
}


// NOTE: It seems ok to have the string constants immediately here since having them separately really does not help
// keeping the code compact
@StringGetter("tileSize_m")

@StringGetter("tileSize_m")
public Integer getTileSize() {
return this.tileSize_m;
}

/**
* Set the size of the tiles (in meters if a metric CRS is used).
* If a square grid is created, this value will be used as the side length of each square.
Expand All @@ -187,7 +200,7 @@ public void setTileSize_m(int value) {
}
this.tileSize_m = value;
}

@StringGetter("extentOfAccessibilityComputationShapeFile")
public String getShapeFileCellBasedAccessibility() {
return this.shapeFileCellBasedAccessibility;
Expand All @@ -201,91 +214,106 @@ public Double getTimeOfDay() {
return this.timeOfDay ;
}
@StringSetter(TIME_OF_DAY)
public void setTimeOfDay(Double timeOfDay) {
public AccessibilityConfigGroup setTimeOfDay(Double timeOfDay) {
this.timeOfDay = timeOfDay;
return this;
}

@StringGetter(MEASURE_POINT_GEOMETRY_PROVISION)
public MeasurePointGeometryProvision getMeasurePointGeometryProvision() {
return this.measurePointGeometryProvision;
}
@StringSetter(MEASURE_POINT_GEOMETRY_PROVISION)
public void setMeasurePointGeometryProvision(MeasurePointGeometryProvision measurePointGeometryProvision) {
public AccessibilityConfigGroup setMeasurePointGeometryProvision(MeasurePointGeometryProvision measurePointGeometryProvision) {
this.measurePointGeometryProvision = measurePointGeometryProvision;
return this;
}
@StringGetter(ACCESSIBILITY_MEASURE_TYPE)
public AccessibilityMeasureType getAccessibilityMeasureType() {
return this.accessibilityMeasureType;
}
@StringSetter(ACCESSIBILITY_MEASURE_TYPE)
public void setAccessibilityMeasureType(AccessibilityMeasureType accessibilityMeasureType) {
public AccessibilityConfigGroup setAccessibilityMeasureType(AccessibilityMeasureType accessibilityMeasureType) {
this.accessibilityMeasureType = accessibilityMeasureType;
return this;
}

// yyyy change the following Boolean to an enum
@StringGetter(USE_OPPORTUNITY_WEIGHTS)
public boolean isUseOpportunityWeights() {
return useOpportunityWeights;
}
@StringSetter(USE_OPPORTUNITY_WEIGHTS)
public void setUseOpportunityWeights(Boolean useOpportunityWeights) {
public AccessibilityConfigGroup setUseOpportunityWeights(Boolean useOpportunityWeights) {
this.useOpportunityWeights = useOpportunityWeights;
return this;
}

// yyyy change the following Boolean to an enum
@StringGetter(USE_PARALLELIZATION)
public boolean isUseParallelization() {
return useParallelization;
}
@StringSetter(USE_PARALLELIZATION)
public void setUseParallelization(Boolean useParallelization) {
public AccessibilityConfigGroup setUseParallelization(Boolean useParallelization) {
this.useParallelization = useParallelization;
return this;
}
@StringGetter(WEIGHT_EXPONENT)
public double getWeightExponent() {
return weightExponent;
}
@StringSetter(WEIGHT_EXPONENT)
public void setWeightExponent(double weightExponent) {
public AccessibilityConfigGroup setWeightExponent(double weightExponent) {
this.weightExponent = weightExponent;
return this;
}
@StringGetter(BOUNDING_BOX_TOP)
public double getBoundingBoxTop() {
return this.boundingBoxTop;
}
@StringSetter(BOUNDING_BOX_TOP)
public void setBoundingBoxTop(double value) {
public AccessibilityConfigGroup setBoundingBoxTop(double value) {
this.boundingBoxTop = value;
return this;
}
@StringGetter(BOUNDING_BOX_LEFT)
public double getBoundingBoxLeft() {
return this.boundingBoxLeft;
}
@StringSetter(BOUNDING_BOX_LEFT)
public void setBoundingBoxLeft(double value) {
public AccessibilityConfigGroup setBoundingBoxLeft(double value) {
this.boundingBoxLeft = value;
return this;
}
@StringGetter(BOUNDING_BOX_RIGHT)
public double getBoundingBoxRight() {
return this.boundingBoxRight;
}
@StringSetter(BOUNDING_BOX_RIGHT)
public void setBoundingBoxRight(double value) {
public AccessibilityConfigGroup setBoundingBoxRight(double value) {
this.boundingBoxRight = value;
return this;
}
@StringGetter(BOUNDING_BOX_BOTTOM)
public double getBoundingBoxBottom() {
return this.boundingBoxBottom;
}
@StringSetter(BOUNDING_BOX_BOTTOM)
public void setBoundingBoxBottom(double value) {
public AccessibilityConfigGroup setBoundingBoxBottom(double value) {
this.boundingBoxBottom = value;
return this;
}

/**
* helper method to set bounding box in code
*/
public void setEnvelope( Envelope envelope ) {
public AccessibilityConfigGroup setEnvelope( Envelope envelope ) {
this.boundingBoxBottom = envelope.getMinY() ;
this.boundingBoxLeft = envelope.getMinX() ;
this.boundingBoxRight = envelope.getMaxX() ;
this.boundingBoxTop = envelope.getMaxY() ;
return this;
}

@StringGetter(AREA_OF_ACC_COMP)
Expand All @@ -294,28 +322,29 @@ public AreaOfAccesssibilityComputation getAreaOfAccessibilityComputation() {
}

@StringSetter(AREA_OF_ACC_COMP)
public void setAreaOfAccessibilityComputation(AreaOfAccesssibilityComputation areaOfAccessibilityComputation) {
public AccessibilityConfigGroup setAreaOfAccessibilityComputation(AreaOfAccesssibilityComputation areaOfAccessibilityComputation) {
this.areaOfAccessibilityComputation = areaOfAccessibilityComputation ;
return this;
}

/**
* helper method to set measuring points in code
*/
public void setMeasuringPointsFacilities(ActivityFacilities measuringPointsFacilities) {
this.measuringPointsFacilities = measuringPointsFacilities;
}

public ActivityFacilities getMeasuringPointsFacilities(){
return this.measuringPointsFacilities;
}

public void setMeasurePointGeometryMap(Map<Id<ActivityFacility>, Geometry> measurePointGeometryMap) {
if (measuringPointsFacilities.getFacilities() == null) {
throw new RuntimeException("Setting geometries of measure points does not make sense if measure points are not yet set!");
}
this.measurePointGeometryMap = measurePointGeometryMap;
}

public Map<Id<ActivityFacility>, Geometry> getMeasurePointGeometryMap(){
return this.measurePointGeometryMap;
}
Expand Down
Loading
Loading