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

noiseAnalysis: defaults for networkModesToIgnore + consistency checks/warnings #3557

Merged
merged 1 commit into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public class NoiseAnalysis implements MATSimAppCommand {

@CommandLine.Option(names = "--consider-activities", split = ",", description = "Considered activities for noise calculation." +
" Use asterisk ('*') for acttype prefixes, if all such acts shall be considered.", defaultValue = "home*,work*,educ*,leisure*")
private Set<String> considerActivities;
private Set<String> consideredActivities;

@CommandLine.Option(names = "--noise-barrier", description = "Path to the noise barrier File", defaultValue = "")
private String noiseBarrierFile;
Expand All @@ -86,19 +86,20 @@ public Integer call() throws Exception {
boolean overrideParameters = ! ConfigUtils.hasModule(config, NoiseConfigGroup.class);
NoiseConfigGroup noiseParameters = ConfigUtils.addOrGetModule(config, NoiseConfigGroup.class);

if(overrideParameters){
if (overrideParameters){
log.warn("no NoiseConfigGroup was configured before. Will set some standards. You should check the next lines in the log file and the output_config.xml!");
noiseParameters.setConsideredActivitiesForReceiverPointGridArray(considerActivities.toArray(String[]::new));
noiseParameters.setConsideredActivitiesForDamageCalculationArray(considerActivities.toArray(String[]::new));
noiseParameters.setConsideredActivitiesForReceiverPointGridArray(consideredActivities.toArray(String[]::new));
noiseParameters.setConsideredActivitiesForDamageCalculationArray(consideredActivities.toArray(String[]::new));

{
Set<String> set = CollectionUtils.stringArrayToSet( new String[]{TransportMode.bike, TransportMode.walk, TransportMode.transit_walk, TransportMode.non_network_walk} );
noiseParameters.setNetworkModesToIgnoreSet( set );
}
{
String[] set = new String[]{"freight"};
noiseParameters.setHgvIdPrefixesArray( set );
//the default settings are now actually the same as what we 'override' here, but let's leave it here for clarity.
Set<String> ignoredNetworkModes = CollectionUtils.stringArrayToSet( new String[]{TransportMode.bike, TransportMode.walk, TransportMode.transit_walk, TransportMode.non_network_walk} );
noiseParameters.setNetworkModesToIgnoreSet( ignoredNetworkModes );

String[] hgvIdPrefixes = {"lkw", "truck", "freight"};
noiseParameters.setHgvIdPrefixesArray( hgvIdPrefixes );
}

//use actual speed and not freespeed
noiseParameters.setUseActualSpeedLevel(true);
//use the valid speed range (recommended by IK)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.matsim.api.core.v01.Id;
import org.matsim.api.core.v01.TransportMode;
import org.matsim.api.core.v01.network.Link;
import org.matsim.core.config.Config;
import org.matsim.core.config.ConfigGroup;
Expand Down Expand Up @@ -134,9 +135,9 @@ public enum NoiseAllocationApproach {
private NoiseAllocationApproach noiseAllocationApproach = NoiseAllocationApproach.AverageCost;

private String[] hgvIdPrefixes = {"lkw", "truck", "freight"};
private Set<String> networkModesToIgnore = CollectionUtils.stringArrayToSet( new String[]{TransportMode.bike, TransportMode.walk, TransportMode.transit_walk, TransportMode.non_network_walk} );
private Set<String> busIdIdentifier = new HashSet<>();
private Set<Id<Link>> tunnelLinkIDs = new HashSet<>();
private Set<String> networkModesToIgnore = new HashSet<>();

private double noiseTollFactor = 1.0;

Expand Down Expand Up @@ -209,7 +210,7 @@ public Map<String, String> getComments() {
comments.put(USE_DEM, "Set to 'true' if a DEM (digital elevation model) should be used for road gradients. Otherwise set to 'false'.");
comments.put(DEM_FILE, "Path to the geoTiff file of the DEM.");

comments.put(NETWORK_MODES_TO_IGNORE, "Specifies the network modes to be excluded from the noise computation, e.g. 'bike'.");
comments.put(NETWORK_MODES_TO_IGNORE, "Specifies the network modes to be excluded from the noise computation. By default, the following modes are excluded: [bike, walk, transit_walk, non_network_walk].");

comments.put(NOISE_COMPUTATION_METHOD, "Specifies the computation method of different guidelines: " + Arrays.toString(NoiseComputationMethod.values()));

Expand Down Expand Up @@ -313,6 +314,37 @@ private void checkNoiseParametersForConsistency(Config config) {
this.considerNoiseBarriers = false;
}
}

List<String> walkAndBikeModes = List.of(TransportMode.bike, TransportMode.walk, TransportMode.transit_walk, TransportMode.non_network_walk);
String exclude = "[";
for (String mode : walkAndBikeModes){
exclude += mode + ",";
}
exclude = exclude.substring(0, exclude.lastIndexOf(',')) + "]";
String warning = "You should set networkModesToIgnore such that all of the standard walk and bike modes are included!" +
" These are " + exclude + ".";
if (this.networkModesToIgnore.isEmpty() ||
! this.networkModesToIgnore.containsAll(walkAndBikeModes)){
boolean bikeOrWalkIsNetworkMode = config.routing().getNetworkModes().stream()
.filter(networkMode -> networkModesToIgnore.contains(networkMode))
.findAny()
.isPresent();
if (bikeOrWalkIsNetworkMode){
//TODO: use enum for consistencyCheckLevel and replace all RunTimeExceptions thrown within this class.
throw new RuntimeException(warning + " You configured one of these modes as networkMode in config().routing.getNetworkModes()! This will lead to wrong results!" +
"Make sure ignore all network modes that do not model a car, a heavy-goods-vehicle (HGV) or a transit vehicle to be considered by the noise analysis!!! Will abort now...");
} else {
log.warn( warning +
" Otherwise, your results will turn wrong as soon as you are routing these modes on the network (which luckily appears not to be the case in your current setup).");
}
}

Set<String> defaultHGVIdPrefixes = Set.of("lkw", "truck", "freight");

if (! defaultHGVIdPrefixes.stream().allMatch(defaultPrefix ->
Arrays.stream(this.hgvIdPrefixes).anyMatch(prefix -> defaultPrefix.equals(prefix)))){
log.warn("You are not considering all of [lkw, truck, freight] as HGV prefixes, which you should! Especially when you use scenarios created by VSP!!");
}
}

// ########################################################################################################
Expand Down
Loading